@fabriktor/fx 0.0.13 → 0.0.14
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/src/fx.d.ts +3 -1
- package/dist/src/fx.js +11 -2
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +3 -0
- package/dist/src/session/session.d.ts +9 -1
- package/dist/src/session/session.js +16 -2
- package/dist/src/session/signup.d.ts +34 -0
- package/dist/src/session/signup.js +42 -0
- package/dist/src/users/phone.d.ts +4 -0
- package/dist/src/users/phone.js +17 -0
- package/dist/src/users/username.d.ts +7 -0
- package/dist/src/users/username.js +48 -0
- package/dist/src/users/users.d.ts +32 -6
- package/dist/src/users/users.js +88 -1
- package/package.json +2 -2
package/dist/src/fx.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UsersOperator } from "@fabriktor/client";
|
|
1
|
+
import type { TmpPhonesOperator, TmpUsernamesOperator, UsersOperator } from "@fabriktor/client";
|
|
2
2
|
import type { AuthOperator } from "./auth/auth.js";
|
|
3
3
|
import type { SessionFX, SessionFXOperator } from "./session/session.js";
|
|
4
4
|
import type { UsersFX, UsersFXOperator } from "./users/users.js";
|
|
@@ -6,6 +6,8 @@ export type FXOptions = {
|
|
|
6
6
|
base_url: string;
|
|
7
7
|
auth: AuthOperator;
|
|
8
8
|
users: UsersOperator;
|
|
9
|
+
tmp_usernames: TmpUsernamesOperator;
|
|
10
|
+
tmp_phones: TmpPhonesOperator;
|
|
9
11
|
};
|
|
10
12
|
export type DefaultFXOptions = {
|
|
11
13
|
base_url: string;
|
package/dist/src/fx.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
4
4
|
// not use this file except in compliance with the License. You may obtain
|
|
5
5
|
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
import { newHTTPClient, newUsersClient } from "@fabriktor/client";
|
|
6
|
+
import { newHTTPClient, newTmpPhonesClient, newTmpUsernamesClient, newUsersClient, } from "@fabriktor/client";
|
|
7
7
|
import { newSessionFX } from "./session/session.js";
|
|
8
8
|
import { newUsersFX } from "./users/users.js";
|
|
9
9
|
export class FX {
|
|
@@ -14,6 +14,8 @@ export class FX {
|
|
|
14
14
|
base_url: opts.base_url,
|
|
15
15
|
auth: opts.auth,
|
|
16
16
|
users: opts.users,
|
|
17
|
+
tmp_usernames: opts.tmp_usernames,
|
|
18
|
+
tmp_phones: opts.tmp_phones,
|
|
17
19
|
});
|
|
18
20
|
this.session = newSessionFX({
|
|
19
21
|
auth: opts.auth,
|
|
@@ -25,11 +27,18 @@ export function newFX(opts) {
|
|
|
25
27
|
return new FX(opts);
|
|
26
28
|
}
|
|
27
29
|
export function newDefaultFX(opts) {
|
|
30
|
+
const http = newHTTPClient();
|
|
28
31
|
return newFX({
|
|
29
32
|
base_url: opts.base_url,
|
|
30
33
|
auth: opts.auth,
|
|
31
34
|
users: newUsersClient({
|
|
32
|
-
http
|
|
35
|
+
http,
|
|
36
|
+
}),
|
|
37
|
+
tmp_usernames: newTmpUsernamesClient({
|
|
38
|
+
http,
|
|
39
|
+
}),
|
|
40
|
+
tmp_phones: newTmpPhonesClient({
|
|
41
|
+
http,
|
|
33
42
|
}),
|
|
34
43
|
});
|
|
35
44
|
}
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InUser, UpsertResult } from "@fabriktor/schema";
|
|
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
4
|
import type { UsersFXOperator } from "../users/users.js";
|
|
@@ -18,7 +18,11 @@ export type SessionFXOptions = {
|
|
|
18
18
|
export interface SessionFXOperator {
|
|
19
19
|
signUpAndBootstrap(opts: SignUpAndBootstrapOptions): Promise<Op<UpsertResult>>;
|
|
20
20
|
signIn(opts: SignInOptions): Promise<void>;
|
|
21
|
+
signInWithEmail(opts: AuthEmailOptions): Promise<void>;
|
|
21
22
|
signOut(): Promise<void>;
|
|
23
|
+
forgotPassword(opts: PLUsersForgotPassword): Promise<void>;
|
|
24
|
+
sendSignInLink(opts: PLUsersSignInLink): Promise<void>;
|
|
25
|
+
sendEmailVerification(): Promise<void>;
|
|
22
26
|
}
|
|
23
27
|
export declare class SessionFX implements SessionFXOperator {
|
|
24
28
|
private auth;
|
|
@@ -26,6 +30,10 @@ export declare class SessionFX implements SessionFXOperator {
|
|
|
26
30
|
constructor(opts: SessionFXOptions);
|
|
27
31
|
signUpAndBootstrap(opts: SignUpAndBootstrapOptions): Promise<Op<UpsertResult>>;
|
|
28
32
|
signIn(opts: SignInOptions): Promise<void>;
|
|
33
|
+
signInWithEmail(opts: AuthEmailOptions): Promise<void>;
|
|
29
34
|
signOut(): Promise<void>;
|
|
35
|
+
forgotPassword(opts: PLUsersForgotPassword): Promise<void>;
|
|
36
|
+
sendSignInLink(opts: PLUsersSignInLink): Promise<void>;
|
|
37
|
+
sendEmailVerification(): Promise<void>;
|
|
30
38
|
}
|
|
31
39
|
export declare function newSessionFX(opts: SessionFXOptions): SessionFX;
|
|
@@ -15,9 +15,11 @@ export class SessionFX {
|
|
|
15
15
|
email: opts.email,
|
|
16
16
|
password: opts.password,
|
|
17
17
|
});
|
|
18
|
-
|
|
18
|
+
const out = await this.users.bootstrap({
|
|
19
19
|
in: opts.in,
|
|
20
20
|
});
|
|
21
|
+
await this.users.sendEmailVerification();
|
|
22
|
+
return out;
|
|
21
23
|
}
|
|
22
24
|
async signIn(opts) {
|
|
23
25
|
const email = opts.mode === "email"
|
|
@@ -25,15 +27,27 @@ export class SessionFX {
|
|
|
25
27
|
: await this.users.resolveUsername({
|
|
26
28
|
username: opts.identifier,
|
|
27
29
|
});
|
|
28
|
-
await this.
|
|
30
|
+
await this.signInWithEmail({
|
|
29
31
|
email,
|
|
30
32
|
password: opts.password,
|
|
31
33
|
});
|
|
34
|
+
}
|
|
35
|
+
async signInWithEmail(opts) {
|
|
36
|
+
await this.auth.signIn(opts);
|
|
32
37
|
await this.users.sync();
|
|
33
38
|
}
|
|
34
39
|
async signOut() {
|
|
35
40
|
await this.auth.signOut();
|
|
36
41
|
}
|
|
42
|
+
async forgotPassword(opts) {
|
|
43
|
+
await this.users.forgotPassword(opts);
|
|
44
|
+
}
|
|
45
|
+
async sendSignInLink(opts) {
|
|
46
|
+
await this.users.sendSignInLink(opts);
|
|
47
|
+
}
|
|
48
|
+
async sendEmailVerification() {
|
|
49
|
+
await this.users.sendEmailVerification();
|
|
50
|
+
}
|
|
37
51
|
}
|
|
38
52
|
export function newSessionFX(opts) {
|
|
39
53
|
return new SessionFX(opts);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { UserTypeClient, UserTypeEmployee, UserTypeEmployer } from "@fabriktor/schema";
|
|
2
|
+
import type { InUser, Owner, Privacy } from "@fabriktor/schema";
|
|
3
|
+
export type SignUpUserType = typeof UserTypeClient | typeof UserTypeEmployee | typeof UserTypeEmployer;
|
|
4
|
+
export type SignUpAddressInput = {
|
|
5
|
+
address_timezone?: string;
|
|
6
|
+
lat?: number;
|
|
7
|
+
lon?: number;
|
|
8
|
+
street?: string;
|
|
9
|
+
city?: string;
|
|
10
|
+
state?: string;
|
|
11
|
+
postal_code?: string;
|
|
12
|
+
country?: string;
|
|
13
|
+
formatted_address?: string;
|
|
14
|
+
place_name?: string;
|
|
15
|
+
place_id?: string;
|
|
16
|
+
};
|
|
17
|
+
export type SignUpInput = {
|
|
18
|
+
email: string;
|
|
19
|
+
password: string;
|
|
20
|
+
username: string;
|
|
21
|
+
first_name: string;
|
|
22
|
+
last_name: string;
|
|
23
|
+
company_name?: string;
|
|
24
|
+
user_type: SignUpUserType;
|
|
25
|
+
preferred_language: string;
|
|
26
|
+
phone?: string;
|
|
27
|
+
address?: SignUpAddressInput;
|
|
28
|
+
privacy?: Privacy;
|
|
29
|
+
picture_id?: string;
|
|
30
|
+
qr_id?: string;
|
|
31
|
+
};
|
|
32
|
+
export declare function newInUserFromSignUp(opts: SignUpInput): InUser;
|
|
33
|
+
export declare function newDefaultPrivacy(): Privacy;
|
|
34
|
+
export declare function newZeroOwner(): Owner;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Copyright (C) Fabriktor, Inc. 2025-present.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
4
|
+
// not use this file except in compliance with the License. You may obtain
|
|
5
|
+
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
export function newInUserFromSignUp(opts) {
|
|
7
|
+
return {
|
|
8
|
+
address_timezone: opts.address?.address_timezone ?? "",
|
|
9
|
+
lat: opts.address?.lat ?? 0,
|
|
10
|
+
lon: opts.address?.lon ?? 0,
|
|
11
|
+
street: opts.address?.street ?? "",
|
|
12
|
+
city: opts.address?.city ?? "",
|
|
13
|
+
state: opts.address?.state ?? "",
|
|
14
|
+
postal_code: opts.address?.postal_code ?? "",
|
|
15
|
+
country: opts.address?.country ?? "",
|
|
16
|
+
formatted_address: opts.address?.formatted_address ?? "",
|
|
17
|
+
place_name: opts.address?.place_name ?? "",
|
|
18
|
+
place_id: opts.address?.place_id ?? "",
|
|
19
|
+
username: opts.username,
|
|
20
|
+
first_name: opts.first_name,
|
|
21
|
+
last_name: opts.last_name,
|
|
22
|
+
phone: opts.phone ?? "",
|
|
23
|
+
company_name: opts.company_name ?? "",
|
|
24
|
+
user_type: opts.user_type,
|
|
25
|
+
user_type_switch: opts.user_type,
|
|
26
|
+
privacy: opts.privacy ?? newDefaultPrivacy(),
|
|
27
|
+
picture_id: opts.picture_id ?? "",
|
|
28
|
+
qr_id: opts.qr_id ?? "",
|
|
29
|
+
ExternalOwner: newZeroOwner(),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function newDefaultPrivacy() {
|
|
33
|
+
return {
|
|
34
|
+
is_searchable: true,
|
|
35
|
+
is_messageable: true,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function newZeroOwner() {
|
|
39
|
+
return {
|
|
40
|
+
owner_id: "",
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright (C) Fabriktor, Inc. 2025-present.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
4
|
+
// not use this file except in compliance with the License. You may obtain
|
|
5
|
+
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
export function normalizePhone(v) {
|
|
7
|
+
return v.trim();
|
|
8
|
+
}
|
|
9
|
+
export function normalizePhoneCode(v) {
|
|
10
|
+
return v.trim();
|
|
11
|
+
}
|
|
12
|
+
export function validatePhone(v) {
|
|
13
|
+
return normalizePhone(v).length > 0;
|
|
14
|
+
}
|
|
15
|
+
export function validatePhoneCode(v) {
|
|
16
|
+
return normalizePhoneCode(v).length > 0;
|
|
17
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Copyright (C) Fabriktor, Inc. 2025-present.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
4
|
+
// not use this file except in compliance with the License. You may obtain
|
|
5
|
+
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
const usernameMinLength = 3;
|
|
7
|
+
const usernameMaxLength = 40;
|
|
8
|
+
const usernamePattern = /^[a-z][a-z0-9_]*$/;
|
|
9
|
+
const usernameLetterPattern = /[a-z]/;
|
|
10
|
+
export function normalizeUsername(v) {
|
|
11
|
+
return v.trim().toLowerCase();
|
|
12
|
+
}
|
|
13
|
+
export function validateUsernameFormat(v) {
|
|
14
|
+
const normalized = normalizeUsername(v);
|
|
15
|
+
if (normalized.length < usernameMinLength) {
|
|
16
|
+
return {
|
|
17
|
+
valid: false,
|
|
18
|
+
normalized,
|
|
19
|
+
error: "Username must contain at least 3 characters.",
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (normalized.length > usernameMaxLength) {
|
|
23
|
+
return {
|
|
24
|
+
valid: false,
|
|
25
|
+
normalized,
|
|
26
|
+
error: "Username must contain at most 40 characters.",
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (!usernamePattern.test(normalized)) {
|
|
30
|
+
return {
|
|
31
|
+
valid: false,
|
|
32
|
+
normalized,
|
|
33
|
+
error: "Username must start with a lowercase letter and contain only lowercase letters, digits, and underscores.",
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (!usernameLetterPattern.test(normalized)) {
|
|
37
|
+
return {
|
|
38
|
+
valid: false,
|
|
39
|
+
normalized,
|
|
40
|
+
error: "Username must contain at least one letter.",
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
valid: true,
|
|
45
|
+
normalized,
|
|
46
|
+
error: "",
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -1,31 +1,57 @@
|
|
|
1
|
-
import type { InUser, OperationResult, UpsertResult } from "@fabriktor/schema";
|
|
2
|
-
import type { Op, UsersOperator } from "@fabriktor/client";
|
|
1
|
+
import type { InUser, OperationResult, PLUsersContactList, PLUsersForgotPassword, PLUsersResolveUsername, PLUsersSendCode, PLUsersSignInLink, PLUsersUsername, PLUsersVerifyCode, UpsertResult, User } from "@fabriktor/schema";
|
|
2
|
+
import type { MatchResult, Op, TmpPhonesOperator, TmpUsernamesOperator, UsernameVerification, UsersOperator } from "@fabriktor/client";
|
|
3
3
|
import type { AuthOperator } from "../auth/auth.js";
|
|
4
4
|
export type UsersFXOptions = {
|
|
5
5
|
base_url: string;
|
|
6
6
|
auth: AuthOperator;
|
|
7
7
|
users: UsersOperator;
|
|
8
|
+
tmp_usernames: TmpUsernamesOperator;
|
|
9
|
+
tmp_phones: TmpPhonesOperator;
|
|
8
10
|
};
|
|
9
11
|
export type BootstrapOptions = {
|
|
10
12
|
in: InUser;
|
|
11
13
|
};
|
|
12
|
-
export type
|
|
13
|
-
|
|
14
|
+
export type SearchOptions = {
|
|
15
|
+
q: string;
|
|
16
|
+
limit?: number;
|
|
17
|
+
};
|
|
18
|
+
export type GetByUIDOptions = {
|
|
19
|
+
uid: string;
|
|
14
20
|
};
|
|
15
21
|
export interface UsersFXOperator {
|
|
16
22
|
bootstrap(opts: BootstrapOptions): Promise<Op<UpsertResult>>;
|
|
17
23
|
sync(): Promise<OperationResult>;
|
|
18
24
|
sendEmailVerification(): Promise<void>;
|
|
19
|
-
|
|
25
|
+
forgotPassword(opts: PLUsersForgotPassword): Promise<void>;
|
|
26
|
+
sendSignInLink(opts: PLUsersSignInLink): Promise<void>;
|
|
27
|
+
resolveUsername(opts: PLUsersResolveUsername): Promise<string>;
|
|
28
|
+
verifyUsername(opts: PLUsersUsername): Promise<Op<UsernameVerification>>;
|
|
29
|
+
generateUsernames(opts: PLUsersUsername): Promise<Op<UsernameVerification>>;
|
|
30
|
+
sendPhoneCode(opts: PLUsersSendCode): Promise<void>;
|
|
31
|
+
verifyPhoneCode(opts: PLUsersVerifyCode): Promise<void>;
|
|
32
|
+
match(opts: PLUsersContactList): Promise<Op<MatchResult>>;
|
|
33
|
+
search(opts: SearchOptions): Promise<Op<User[]>>;
|
|
34
|
+
getByUID(opts: GetByUIDOptions): Promise<Op<User>>;
|
|
20
35
|
}
|
|
21
36
|
export declare class UsersFX implements UsersFXOperator {
|
|
22
37
|
private base_url;
|
|
23
38
|
private auth;
|
|
24
39
|
private users;
|
|
40
|
+
private tmp_usernames;
|
|
41
|
+
private tmp_phones;
|
|
25
42
|
constructor(opts: UsersFXOptions);
|
|
26
43
|
bootstrap(opts: BootstrapOptions): Promise<Op<UpsertResult>>;
|
|
27
44
|
sync(): Promise<OperationResult>;
|
|
28
45
|
sendEmailVerification(): Promise<void>;
|
|
29
|
-
|
|
46
|
+
forgotPassword(opts: PLUsersForgotPassword): Promise<void>;
|
|
47
|
+
sendSignInLink(opts: PLUsersSignInLink): Promise<void>;
|
|
48
|
+
resolveUsername(opts: PLUsersResolveUsername): Promise<string>;
|
|
49
|
+
verifyUsername(opts: PLUsersUsername): Promise<Op<UsernameVerification>>;
|
|
50
|
+
generateUsernames(opts: PLUsersUsername): Promise<Op<UsernameVerification>>;
|
|
51
|
+
sendPhoneCode(opts: PLUsersSendCode): Promise<void>;
|
|
52
|
+
verifyPhoneCode(opts: PLUsersVerifyCode): Promise<void>;
|
|
53
|
+
match(opts: PLUsersContactList): Promise<Op<MatchResult>>;
|
|
54
|
+
search(opts: SearchOptions): Promise<Op<User[]>>;
|
|
55
|
+
getByUID(opts: GetByUIDOptions): Promise<Op<User>>;
|
|
30
56
|
}
|
|
31
57
|
export declare function newUsersFX(opts: UsersFXOptions): UsersFX;
|
package/dist/src/users/users.js
CHANGED
|
@@ -3,14 +3,20 @@
|
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
4
4
|
// not use this file except in compliance with the License. You may obtain
|
|
5
5
|
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
import { normalizePhone, normalizePhoneCode, validatePhone, validatePhoneCode, } from "./phone.js";
|
|
7
|
+
import { normalizeUsername, validateUsernameFormat } from "./username.js";
|
|
6
8
|
export class UsersFX {
|
|
7
9
|
base_url;
|
|
8
10
|
auth;
|
|
9
11
|
users;
|
|
12
|
+
tmp_usernames;
|
|
13
|
+
tmp_phones;
|
|
10
14
|
constructor(opts) {
|
|
11
15
|
this.base_url = opts.base_url;
|
|
12
16
|
this.auth = opts.auth;
|
|
13
17
|
this.users = opts.users;
|
|
18
|
+
this.tmp_usernames = opts.tmp_usernames;
|
|
19
|
+
this.tmp_phones = opts.tmp_phones;
|
|
14
20
|
}
|
|
15
21
|
async bootstrap(opts) {
|
|
16
22
|
const token = await this.auth.getToken();
|
|
@@ -34,16 +40,97 @@ export class UsersFX {
|
|
|
34
40
|
token,
|
|
35
41
|
});
|
|
36
42
|
}
|
|
43
|
+
async forgotPassword(opts) {
|
|
44
|
+
return await this.users.forgotPassword({
|
|
45
|
+
base_url: this.base_url,
|
|
46
|
+
email: opts.email,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async sendSignInLink(opts) {
|
|
50
|
+
return await this.users.sendSignInLink({
|
|
51
|
+
base_url: this.base_url,
|
|
52
|
+
email: opts.email,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
37
55
|
async resolveUsername(opts) {
|
|
56
|
+
const username = normalizeUsername(opts.username);
|
|
38
57
|
const out = await this.users.resolveUsername({
|
|
39
58
|
base_url: this.base_url,
|
|
40
|
-
username
|
|
59
|
+
username,
|
|
41
60
|
});
|
|
42
61
|
if (out.value === undefined) {
|
|
43
62
|
throw new Error("Unable to resolve username.");
|
|
44
63
|
}
|
|
45
64
|
return out.value;
|
|
46
65
|
}
|
|
66
|
+
async verifyUsername(opts) {
|
|
67
|
+
const check = validateUsernameFormat(opts.to_validate);
|
|
68
|
+
if (!check.valid) {
|
|
69
|
+
throw new Error(check.error);
|
|
70
|
+
}
|
|
71
|
+
return await this.tmp_usernames.verify({
|
|
72
|
+
base_url: this.base_url,
|
|
73
|
+
words: opts.words,
|
|
74
|
+
to_validate: check.normalized,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async generateUsernames(opts) {
|
|
78
|
+
return await this.tmp_usernames.verify({
|
|
79
|
+
base_url: this.base_url,
|
|
80
|
+
words: opts.words,
|
|
81
|
+
to_validate: "",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async sendPhoneCode(opts) {
|
|
85
|
+
const phone = normalizePhone(opts.phone);
|
|
86
|
+
if (!validatePhone(phone)) {
|
|
87
|
+
throw new Error("Phone number is required.");
|
|
88
|
+
}
|
|
89
|
+
return await this.tmp_phones.send({
|
|
90
|
+
base_url: this.base_url,
|
|
91
|
+
phone,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
async verifyPhoneCode(opts) {
|
|
95
|
+
const phone = normalizePhone(opts.phone);
|
|
96
|
+
const code = normalizePhoneCode(opts.code);
|
|
97
|
+
if (!validatePhone(phone)) {
|
|
98
|
+
throw new Error("Phone number is required.");
|
|
99
|
+
}
|
|
100
|
+
if (!validatePhoneCode(code)) {
|
|
101
|
+
throw new Error("Verification code is required.");
|
|
102
|
+
}
|
|
103
|
+
return await this.tmp_phones.verify({
|
|
104
|
+
base_url: this.base_url,
|
|
105
|
+
phone,
|
|
106
|
+
code,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
async match(opts) {
|
|
110
|
+
const token = await this.auth.getToken();
|
|
111
|
+
return await this.users.match({
|
|
112
|
+
base_url: this.base_url,
|
|
113
|
+
token,
|
|
114
|
+
contacts: opts.contacts,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
async search(opts) {
|
|
118
|
+
const token = await this.auth.getToken();
|
|
119
|
+
return await this.users.search({
|
|
120
|
+
base_url: this.base_url,
|
|
121
|
+
token,
|
|
122
|
+
q: opts.q,
|
|
123
|
+
limit: opts.limit,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
async getByUID(opts) {
|
|
127
|
+
const token = await this.auth.getToken();
|
|
128
|
+
return await this.users.getByUID({
|
|
129
|
+
base_url: this.base_url,
|
|
130
|
+
token,
|
|
131
|
+
uid: opts.uid,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
47
134
|
}
|
|
48
135
|
export function newUsersFX(opts) {
|
|
49
136
|
return new UsersFX(opts);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabriktor/fx",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"typescript": "^6.0.3"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@fabriktor/client": "^0.0.
|
|
20
|
+
"@fabriktor/client": "^0.0.12",
|
|
21
21
|
"@fabriktor/schema": "^0.0.11"
|
|
22
22
|
}
|
|
23
23
|
}
|