@fabriktor/client 0.0.10 → 0.0.11
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/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/users/tmp_phones.d.ts +24 -0
- package/dist/src/users/tmp_phones.js +44 -0
- package/dist/src/users/tmp_usernames.d.ts +22 -0
- package/dist/src/users/tmp_usernames.js +34 -0
- package/dist/src/users/users.d.ts +39 -1
- package/dist/src/users/users.js +55 -1
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HTTPDoer } from "../core/http.js";
|
|
2
|
+
export type SendPhoneVerificationOptions = {
|
|
3
|
+
base_url: string;
|
|
4
|
+
phone: string;
|
|
5
|
+
};
|
|
6
|
+
export type VerifyPhoneOptions = {
|
|
7
|
+
base_url: string;
|
|
8
|
+
phone: string;
|
|
9
|
+
code: string;
|
|
10
|
+
};
|
|
11
|
+
export interface TmpPhonesOperator {
|
|
12
|
+
send(opts: SendPhoneVerificationOptions): Promise<void>;
|
|
13
|
+
verify(opts: VerifyPhoneOptions): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export type TmpPhonesClientOptions = {
|
|
16
|
+
http: HTTPDoer;
|
|
17
|
+
};
|
|
18
|
+
export declare class TmpPhonesClient implements TmpPhonesOperator {
|
|
19
|
+
private http;
|
|
20
|
+
constructor(opts: TmpPhonesClientOptions);
|
|
21
|
+
send(opts: SendPhoneVerificationOptions): Promise<void>;
|
|
22
|
+
verify(opts: VerifyPhoneOptions): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export declare function newTmpPhonesClient(opts: TmpPhonesClientOptions): TmpPhonesClient;
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
import { ColUsersTmpPhones, HTTPMethodPost, PathUsersSend, PathUsersVerify, SvcUsers, } from "@fabriktor/schema";
|
|
7
|
+
import { buildPath } from "../core/path.js";
|
|
8
|
+
export class TmpPhonesClient {
|
|
9
|
+
http;
|
|
10
|
+
constructor(opts) {
|
|
11
|
+
this.http = opts.http;
|
|
12
|
+
}
|
|
13
|
+
async send(opts) {
|
|
14
|
+
return await this.http.do({
|
|
15
|
+
base_url: opts.base_url,
|
|
16
|
+
path: tmpPhonePath(PathUsersSend),
|
|
17
|
+
method: HTTPMethodPost,
|
|
18
|
+
body: {
|
|
19
|
+
phone: opts.phone,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async verify(opts) {
|
|
24
|
+
return await this.http.do({
|
|
25
|
+
base_url: opts.base_url,
|
|
26
|
+
path: tmpPhonePath(PathUsersVerify),
|
|
27
|
+
method: HTTPMethodPost,
|
|
28
|
+
body: {
|
|
29
|
+
phone: opts.phone,
|
|
30
|
+
code: opts.code,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function newTmpPhonesClient(opts) {
|
|
36
|
+
return new TmpPhonesClient(opts);
|
|
37
|
+
}
|
|
38
|
+
function tmpPhonePath(action) {
|
|
39
|
+
return buildPath({
|
|
40
|
+
svc: SvcUsers,
|
|
41
|
+
col: ColUsersTmpPhones,
|
|
42
|
+
action,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HTTPDoer, Op } from "../core/http.js";
|
|
2
|
+
export type VerifyUsernameOptions = {
|
|
3
|
+
base_url: string;
|
|
4
|
+
to_validate?: string;
|
|
5
|
+
words: string[];
|
|
6
|
+
};
|
|
7
|
+
export type UsernameVerification = {
|
|
8
|
+
username: string;
|
|
9
|
+
suggestions: string[];
|
|
10
|
+
};
|
|
11
|
+
export interface TmpUsernamesOperator {
|
|
12
|
+
verify(opts: VerifyUsernameOptions): Promise<Op<UsernameVerification>>;
|
|
13
|
+
}
|
|
14
|
+
export type TmpUsernamesClientOptions = {
|
|
15
|
+
http: HTTPDoer;
|
|
16
|
+
};
|
|
17
|
+
export declare class TmpUsernamesClient implements TmpUsernamesOperator {
|
|
18
|
+
private http;
|
|
19
|
+
constructor(opts: TmpUsernamesClientOptions);
|
|
20
|
+
verify(opts: VerifyUsernameOptions): Promise<Op<UsernameVerification>>;
|
|
21
|
+
}
|
|
22
|
+
export declare function newTmpUsernamesClient(opts: TmpUsernamesClientOptions): TmpUsernamesClient;
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
import { ColUsersTmpUsernames, HTTPMethodPost, PathUsersVerify, SvcUsers, } from "@fabriktor/schema";
|
|
7
|
+
import { buildPath } from "../core/path.js";
|
|
8
|
+
export class TmpUsernamesClient {
|
|
9
|
+
http;
|
|
10
|
+
constructor(opts) {
|
|
11
|
+
this.http = opts.http;
|
|
12
|
+
}
|
|
13
|
+
async verify(opts) {
|
|
14
|
+
return await this.http.do({
|
|
15
|
+
base_url: opts.base_url,
|
|
16
|
+
path: tmpUsernamePath(PathUsersVerify),
|
|
17
|
+
method: HTTPMethodPost,
|
|
18
|
+
body: {
|
|
19
|
+
to_validate: opts.to_validate,
|
|
20
|
+
words: opts.words,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function newTmpUsernamesClient(opts) {
|
|
26
|
+
return new TmpUsernamesClient(opts);
|
|
27
|
+
}
|
|
28
|
+
function tmpUsernamePath(action) {
|
|
29
|
+
return buildPath({
|
|
30
|
+
svc: SvcUsers,
|
|
31
|
+
col: ColUsersTmpUsernames,
|
|
32
|
+
action,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InUser, OperationResult, UpsertResult } from "@fabriktor/schema";
|
|
1
|
+
import type { InUser, OperationResult, UpsertResult, User } from "@fabriktor/schema";
|
|
2
2
|
import type { HTTPDoer, Op } from "../core/http.js";
|
|
3
3
|
export type AuthOptions = {
|
|
4
4
|
base_url: string;
|
|
@@ -11,11 +11,44 @@ export type ResolveUsernameOptions = {
|
|
|
11
11
|
base_url: string;
|
|
12
12
|
username: string;
|
|
13
13
|
};
|
|
14
|
+
export type ForgotPasswordOptions = {
|
|
15
|
+
base_url: string;
|
|
16
|
+
email: string;
|
|
17
|
+
};
|
|
18
|
+
export type SendSignInLinkOptions = {
|
|
19
|
+
base_url: string;
|
|
20
|
+
email: string;
|
|
21
|
+
};
|
|
22
|
+
export type ContactMatchEntry = {
|
|
23
|
+
first_name?: string;
|
|
24
|
+
last_name?: string;
|
|
25
|
+
full_name?: string;
|
|
26
|
+
phones?: string[];
|
|
27
|
+
emails?: string[];
|
|
28
|
+
};
|
|
29
|
+
export type MatchOptions = AuthOptions & {
|
|
30
|
+
contacts: ContactMatchEntry[];
|
|
31
|
+
};
|
|
32
|
+
export type MatchResult = {
|
|
33
|
+
users: User[];
|
|
34
|
+
};
|
|
35
|
+
export type SearchOptions = AuthOptions & {
|
|
36
|
+
q: string;
|
|
37
|
+
limit?: number;
|
|
38
|
+
};
|
|
39
|
+
export type GetByUIDOptions = AuthOptions & {
|
|
40
|
+
uid: string;
|
|
41
|
+
};
|
|
14
42
|
export interface UsersOperator {
|
|
15
43
|
bootstrap(opts: BootstrapOptions): Promise<Op<UpsertResult>>;
|
|
16
44
|
sync(opts: AuthOptions): Promise<OperationResult>;
|
|
17
45
|
sendEmailVerification(opts: AuthOptions): Promise<void>;
|
|
46
|
+
forgotPassword(opts: ForgotPasswordOptions): Promise<void>;
|
|
47
|
+
sendSignInLink(opts: SendSignInLinkOptions): Promise<void>;
|
|
18
48
|
resolveUsername(opts: ResolveUsernameOptions): Promise<Op<string>>;
|
|
49
|
+
match(opts: MatchOptions): Promise<Op<MatchResult>>;
|
|
50
|
+
search(opts: SearchOptions): Promise<Op<User[]>>;
|
|
51
|
+
getByUID(opts: GetByUIDOptions): Promise<Op<User>>;
|
|
19
52
|
}
|
|
20
53
|
export type UsersClientOptions = {
|
|
21
54
|
http: HTTPDoer;
|
|
@@ -26,6 +59,11 @@ export declare class UsersClient implements UsersOperator {
|
|
|
26
59
|
bootstrap(opts: BootstrapOptions): Promise<Op<UpsertResult>>;
|
|
27
60
|
sync(opts: AuthOptions): Promise<OperationResult>;
|
|
28
61
|
sendEmailVerification(opts: AuthOptions): Promise<void>;
|
|
62
|
+
forgotPassword(opts: ForgotPasswordOptions): Promise<void>;
|
|
63
|
+
sendSignInLink(opts: SendSignInLinkOptions): Promise<void>;
|
|
29
64
|
resolveUsername(opts: ResolveUsernameOptions): Promise<Op<string>>;
|
|
65
|
+
match(opts: MatchOptions): Promise<Op<MatchResult>>;
|
|
66
|
+
search(opts: SearchOptions): Promise<Op<User[]>>;
|
|
67
|
+
getByUID(opts: GetByUIDOptions): Promise<Op<User>>;
|
|
30
68
|
}
|
|
31
69
|
export declare function newUsersClient(opts: UsersClientOptions): UsersClient;
|
package/dist/src/users/users.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 { ColUsersUsers, HTTPMethodPost, PathUsersBootstrap, PathUsersResolveUsername, PathUsersSendEmailVerification, PathUsersSync, SvcUsers, } from "@fabriktor/schema";
|
|
6
|
+
import { ColUsersUsers, HTTPMethodGet, HTTPMethodPost, PathSearch, PathUsersBootstrap, PathUsersForgotPassword, PathUsersMatch, PathUsersResolveUsername, PathUsersSendEmailVerification, PathUsersSendSignInLink, PathUsersSync, SvcUsers, } from "@fabriktor/schema";
|
|
7
7
|
import { buildPath } from "../core/path.js";
|
|
8
8
|
export class UsersClient {
|
|
9
9
|
http;
|
|
@@ -35,6 +35,26 @@ export class UsersClient {
|
|
|
35
35
|
token: opts.token,
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
+
async forgotPassword(opts) {
|
|
39
|
+
return await this.http.do({
|
|
40
|
+
base_url: opts.base_url,
|
|
41
|
+
path: userPath(PathUsersForgotPassword),
|
|
42
|
+
method: HTTPMethodPost,
|
|
43
|
+
body: {
|
|
44
|
+
email: opts.email,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async sendSignInLink(opts) {
|
|
49
|
+
return await this.http.do({
|
|
50
|
+
base_url: opts.base_url,
|
|
51
|
+
path: userPath(PathUsersSendSignInLink),
|
|
52
|
+
method: HTTPMethodPost,
|
|
53
|
+
body: {
|
|
54
|
+
email: opts.email,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
38
58
|
async resolveUsername(opts) {
|
|
39
59
|
return await this.http.do({
|
|
40
60
|
base_url: opts.base_url,
|
|
@@ -45,10 +65,44 @@ export class UsersClient {
|
|
|
45
65
|
},
|
|
46
66
|
});
|
|
47
67
|
}
|
|
68
|
+
async match(opts) {
|
|
69
|
+
return await this.http.do({
|
|
70
|
+
base_url: opts.base_url,
|
|
71
|
+
path: userPath(PathUsersMatch),
|
|
72
|
+
method: HTTPMethodPost,
|
|
73
|
+
token: opts.token,
|
|
74
|
+
body: {
|
|
75
|
+
contacts: opts.contacts,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async search(opts) {
|
|
80
|
+
return await this.http.do({
|
|
81
|
+
base_url: opts.base_url,
|
|
82
|
+
path: userPath(PathSearch),
|
|
83
|
+
method: HTTPMethodPost,
|
|
84
|
+
token: opts.token,
|
|
85
|
+
body: opts,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async getByUID(opts) {
|
|
89
|
+
return await this.http.do({
|
|
90
|
+
base_url: opts.base_url,
|
|
91
|
+
path: `${collectionPath()}?uid=${encodeURIComponent(opts.uid)}`,
|
|
92
|
+
method: HTTPMethodGet,
|
|
93
|
+
token: opts.token,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
48
96
|
}
|
|
49
97
|
export function newUsersClient(opts) {
|
|
50
98
|
return new UsersClient(opts);
|
|
51
99
|
}
|
|
100
|
+
function collectionPath() {
|
|
101
|
+
return buildPath({
|
|
102
|
+
svc: SvcUsers,
|
|
103
|
+
col: ColUsersUsers,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
52
106
|
function userPath(action) {
|
|
53
107
|
return buildPath({
|
|
54
108
|
svc: SvcUsers,
|