@fonderie/client 0.1.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/LICENSE +21 -0
- package/README.md +58 -0
- package/dist/index.cjs +236 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +178 -0
- package/dist/index.d.ts +178 -0
- package/dist/index.js +207 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fonderie, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @fonderie/client
|
|
2
|
+
|
|
3
|
+
Isomorphic TypeScript client for Fonderie-powered APIs. Fully typed request
|
|
4
|
+
and response shapes end to end, zero runtime dependencies — works in the
|
|
5
|
+
browser, Node, and edge runtimes alike.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @fonderie/client
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Use
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { FonderieClient, FonderieApiError } from '@fonderie/client';
|
|
17
|
+
|
|
18
|
+
const api = new FonderieClient({ baseUrl: 'https://api.example.com/v1' });
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const { tokens } = await api.auth.login({ email, password });
|
|
22
|
+
const user = await api.auth.getUser();
|
|
23
|
+
} catch (err) {
|
|
24
|
+
if (err instanceof FonderieApiError) {
|
|
25
|
+
// typed status, code, and message from the API's error envelope
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The client is organised into modules mirroring the server packages —
|
|
31
|
+
`api.auth` covers register/login/refresh, email verification, password reset,
|
|
32
|
+
phone OTP, profile updates, and MFA setup/verify/disable, with every DTO
|
|
33
|
+
(`IUserDTO`, `ITokens`, `ILoginResult`, …) exported for your own signatures.
|
|
34
|
+
|
|
35
|
+
Pairs with any API built on
|
|
36
|
+
[@fonderie/core](https://github.com/fonderie-js/sdk/tree/main/packages/core);
|
|
37
|
+
the types stay in lockstep because both sides live in the same monorepo.
|
|
38
|
+
|
|
39
|
+
## Why this exists
|
|
40
|
+
|
|
41
|
+
You've shipped this plumbing before — auth, teams, billing, messaging —
|
|
42
|
+
and the next project will ask for it again. Fonderie packages it once:
|
|
43
|
+
plain TypeScript modules for
|
|
44
|
+
[`@fonderie/core`](https://github.com/fonderie-js/sdk/tree/main/packages/core),
|
|
45
|
+
PostgreSQL-backed, self-hosted, MIT. No external control plane, no
|
|
46
|
+
per-seat anything. Register the modules you need; skip the ones you don't.
|
|
47
|
+
|
|
48
|
+
**This package owns** the consumer side. Typed access to any Fonderie-powered API from
|
|
49
|
+
browser, Node, or edge — with request/response shapes that stay in lockstep
|
|
50
|
+
with the server because both live in this monorepo.
|
|
51
|
+
|
|
52
|
+
Browse the whole set at
|
|
53
|
+
[fonderie-js/sdk](https://github.com/fonderie-js/sdk) · follow
|
|
54
|
+
[@fonderiejs](https://x.com/fonderiejs)
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
MIT © Fonderie, Inc.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
AuthClient: () => AuthClient,
|
|
24
|
+
FonderieApiError: () => FonderieApiError,
|
|
25
|
+
FonderieClient: () => FonderieClient
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
|
|
29
|
+
// src/http.ts
|
|
30
|
+
var FonderieApiError = class extends Error {
|
|
31
|
+
constructor(reason, explanation, status, details) {
|
|
32
|
+
super(explanation);
|
|
33
|
+
this.reason = reason;
|
|
34
|
+
this.explanation = explanation;
|
|
35
|
+
this.status = status;
|
|
36
|
+
this.details = details;
|
|
37
|
+
this.name = "FonderieApiError";
|
|
38
|
+
}
|
|
39
|
+
reason;
|
|
40
|
+
explanation;
|
|
41
|
+
status;
|
|
42
|
+
details;
|
|
43
|
+
};
|
|
44
|
+
var HttpClient = class {
|
|
45
|
+
constructor(baseUrl) {
|
|
46
|
+
this.baseUrl = baseUrl;
|
|
47
|
+
}
|
|
48
|
+
baseUrl;
|
|
49
|
+
async request(opts) {
|
|
50
|
+
const headers = {
|
|
51
|
+
"Content-Type": "application/json"
|
|
52
|
+
};
|
|
53
|
+
if (opts.token) headers["Authorization"] = `Bearer ${opts.token}`;
|
|
54
|
+
if (opts.cookie) headers["Cookie"] = opts.cookie;
|
|
55
|
+
const fetchInit = {
|
|
56
|
+
method: opts.method,
|
|
57
|
+
headers,
|
|
58
|
+
credentials: "include"
|
|
59
|
+
};
|
|
60
|
+
if (opts.body !== void 0) fetchInit.body = JSON.stringify(opts.body);
|
|
61
|
+
const res = await fetch(`${this.baseUrl}${opts.path}`, fetchInit);
|
|
62
|
+
const data = await res.json();
|
|
63
|
+
if (!res.ok || res.status === 202) {
|
|
64
|
+
const err = data;
|
|
65
|
+
throw new FonderieApiError(err.reason, err.explanation, res.status, err.details);
|
|
66
|
+
}
|
|
67
|
+
return data;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// src/modules/auth.ts
|
|
72
|
+
var PhoneClient = class {
|
|
73
|
+
constructor(http) {
|
|
74
|
+
this.http = http;
|
|
75
|
+
}
|
|
76
|
+
http;
|
|
77
|
+
sendVerification(phone) {
|
|
78
|
+
return this.http.request({
|
|
79
|
+
method: "POST",
|
|
80
|
+
path: "/auth/phone/send-verification",
|
|
81
|
+
body: { phone }
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
verify(phone, otp) {
|
|
85
|
+
return this.http.request({
|
|
86
|
+
method: "POST",
|
|
87
|
+
path: "/auth/phone/verify",
|
|
88
|
+
body: { phone, otp }
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var MfaClient = class {
|
|
93
|
+
constructor(http, token) {
|
|
94
|
+
this.http = http;
|
|
95
|
+
this.token = token;
|
|
96
|
+
}
|
|
97
|
+
http;
|
|
98
|
+
token;
|
|
99
|
+
setup() {
|
|
100
|
+
return this.http.request({
|
|
101
|
+
method: "POST",
|
|
102
|
+
path: "/auth/mfa/setup",
|
|
103
|
+
token: this.token()
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
verify(code) {
|
|
107
|
+
return this.http.request({
|
|
108
|
+
method: "POST",
|
|
109
|
+
path: "/auth/mfa/verify",
|
|
110
|
+
body: { token: code },
|
|
111
|
+
token: this.token()
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
disable(code) {
|
|
115
|
+
return this.http.request({
|
|
116
|
+
method: "POST",
|
|
117
|
+
path: "/auth/mfa/disable",
|
|
118
|
+
body: { code },
|
|
119
|
+
token: this.token()
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
var AuthClient = class {
|
|
124
|
+
constructor(http, accessToken) {
|
|
125
|
+
this.http = http;
|
|
126
|
+
this.accessToken = accessToken;
|
|
127
|
+
this.phone = new PhoneClient(http);
|
|
128
|
+
this.mfa = new MfaClient(http, () => this.accessToken);
|
|
129
|
+
}
|
|
130
|
+
http;
|
|
131
|
+
accessToken;
|
|
132
|
+
phone;
|
|
133
|
+
mfa;
|
|
134
|
+
setAccessToken(token) {
|
|
135
|
+
this.accessToken = token;
|
|
136
|
+
}
|
|
137
|
+
// ── Public ─────────────────────────────────────────────────────────────────
|
|
138
|
+
register(input) {
|
|
139
|
+
return this.http.request({
|
|
140
|
+
method: "POST",
|
|
141
|
+
path: "/auth/register",
|
|
142
|
+
body: input
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
login(input) {
|
|
146
|
+
return this.http.request({
|
|
147
|
+
method: "POST",
|
|
148
|
+
path: "/auth/login",
|
|
149
|
+
body: input
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
refreshTokens(refreshToken) {
|
|
153
|
+
return this.http.request({
|
|
154
|
+
method: "POST",
|
|
155
|
+
path: "/auth/refresh",
|
|
156
|
+
body: refreshToken ? { refreshToken } : void 0
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
forgotPassword(email) {
|
|
160
|
+
return this.http.request({
|
|
161
|
+
method: "POST",
|
|
162
|
+
path: "/auth/email/forgot",
|
|
163
|
+
body: { email }
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
resetPassword(input) {
|
|
167
|
+
return this.http.request({
|
|
168
|
+
method: "POST",
|
|
169
|
+
path: "/auth/email/reset",
|
|
170
|
+
body: input
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
verifyEmail(pin) {
|
|
174
|
+
return this.http.request({
|
|
175
|
+
method: "POST",
|
|
176
|
+
path: "/auth/email/verify",
|
|
177
|
+
body: { pin }
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
// ── Protected ──────────────────────────────────────────────────────────────
|
|
181
|
+
logout(refreshToken) {
|
|
182
|
+
return this.http.request({
|
|
183
|
+
method: "POST",
|
|
184
|
+
path: "/auth/logout",
|
|
185
|
+
body: refreshToken ? { refreshToken } : void 0,
|
|
186
|
+
token: this.accessToken
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
sendVerificationEmail() {
|
|
190
|
+
return this.http.request({
|
|
191
|
+
method: "POST",
|
|
192
|
+
path: "/auth/email/send-verification",
|
|
193
|
+
token: this.accessToken
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
// ── Protected + Verified ───────────────────────────────────────────────────
|
|
197
|
+
getUser() {
|
|
198
|
+
return this.http.request({
|
|
199
|
+
method: "GET",
|
|
200
|
+
path: "/users",
|
|
201
|
+
token: this.accessToken
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
updateUser(input) {
|
|
205
|
+
return this.http.request({
|
|
206
|
+
method: "PUT",
|
|
207
|
+
path: "/users/update",
|
|
208
|
+
body: input,
|
|
209
|
+
token: this.accessToken
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
deleteUser() {
|
|
213
|
+
return this.http.request({
|
|
214
|
+
method: "DELETE",
|
|
215
|
+
path: "/users",
|
|
216
|
+
token: this.accessToken
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// src/client.ts
|
|
222
|
+
var FonderieClient = class {
|
|
223
|
+
auth;
|
|
224
|
+
http;
|
|
225
|
+
constructor(opts) {
|
|
226
|
+
this.http = new HttpClient(opts.baseUrl);
|
|
227
|
+
this.auth = new AuthClient(this.http, opts.accessToken);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
231
|
+
0 && (module.exports = {
|
|
232
|
+
AuthClient,
|
|
233
|
+
FonderieApiError,
|
|
234
|
+
FonderieClient
|
|
235
|
+
});
|
|
236
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/http.ts","../src/modules/auth.ts","../src/client.ts"],"sourcesContent":["export { FonderieClient } from './client';\nexport type { IFonderieClientOptions } from './client';\nexport { FonderieApiError } from './http';\nexport { AuthClient } from './modules/auth';\nexport type {\n\tIRegisterInput,\n\tILoginInput,\n\tIResetPasswordInput,\n\tIUpdateUserInput,\n} from './modules/auth';\nexport type {\n\tIApiResponse,\n\tIApiError,\n\tIUserDTO,\n\tIUserPreferences,\n\tIUserSkill,\n\tITokens,\n\tIRegisterResult,\n\tILoginResult,\n\tIRefreshResult,\n\tIVerifyEmailResult,\n\tIResendVerificationResult,\n\tIMeResult,\n\tIMfaSetupResult,\n\tIMfaEnabledResult,\n} from './types';\n","import type { IApiError } from './types';\n\nexport class FonderieApiError extends Error {\n\tconstructor(\n\t\tpublic readonly reason: string,\n\t\tpublic readonly explanation: string,\n\t\tpublic readonly status: number,\n\t\tpublic readonly details?: unknown,\n\t) {\n\t\tsuper(explanation);\n\t\tthis.name = 'FonderieApiError';\n\t}\n}\n\nexport interface IRequestOptions {\n\tmethod: string;\n\tpath: string;\n\tbody?: unknown;\n\ttoken?: string | undefined;\n\tcookie?: string | undefined;\n}\n\nexport class HttpClient {\n\tconstructor(private baseUrl: string) {}\n\n\tasync request<T>(opts: IRequestOptions): Promise<T> {\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Content-Type': 'application/json',\n\t\t};\n\n\t\tif (opts.token) headers['Authorization'] = `Bearer ${opts.token}`;\n\t\tif (opts.cookie) headers['Cookie'] = opts.cookie;\n\n\t\tconst fetchInit: RequestInit = {\n\t\t\tmethod: opts.method,\n\t\t\theaders,\n\t\t\tcredentials: 'include',\n\t\t};\n\t\tif (opts.body !== undefined) fetchInit.body = JSON.stringify(opts.body);\n\n\t\tconst res = await fetch(`${this.baseUrl}${opts.path}`, fetchInit);\n\n\t\tconst data = (await res.json()) as T | IApiError;\n\n\t\tif (!res.ok || res.status === 202) {\n\t\t\tconst err = data as IApiError;\n\t\t\tthrow new FonderieApiError(err.reason, err.explanation, res.status, err.details);\n\t\t}\n\n\t\treturn data as T;\n\t}\n}\n","import type { HttpClient } from '../http';\nimport type {\n\tIApiResponse,\n\tIRegisterResult,\n\tILoginResult,\n\tIRefreshResult,\n\tIVerifyEmailResult,\n\tIResendVerificationResult,\n\tIMeResult,\n\tIMfaSetupResult,\n\tIMfaEnabledResult,\n\tIPhoneVerifyResult,\n} from '../types';\n\n// ── Input shapes ─────────────────────────────────────────────────────────────\n\nexport interface IRegisterInput {\n\temail: string;\n\tpassword: string;\n\tfirstName?: string;\n\tlastName?: string;\n}\n\nexport interface ILoginInput {\n\temail: string;\n\tpassword: string;\n}\n\nexport interface IResetPasswordInput {\n\tresetToken: string;\n\tpassword: string;\n}\n\nexport interface IUpdateUserInput {\n\tfirstName?: string;\n\tlastName?: string;\n\tphoneNumber?: string;\n\tavatarUrl?: string;\n\tlocale?: string;\n\ttimezone?: string;\n\tpreferences?: Record<string, unknown>;\n}\n\n// ── Phone sub-client ─────────────────────────────────────────────────────────\n\nclass PhoneClient {\n\tconstructor(private http: HttpClient) {}\n\n\tsendVerification(phone: string) {\n\t\treturn this.http.request<IApiResponse<undefined>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/phone/send-verification',\n\t\t\tbody: { phone },\n\t\t});\n\t}\n\n\tverify(phone: string, otp: string) {\n\t\treturn this.http.request<IApiResponse<IPhoneVerifyResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/phone/verify',\n\t\t\tbody: { phone, otp },\n\t\t});\n\t}\n}\n\n// ── MFA sub-client ───────────────────────────────────────────────────────────\n\nclass MfaClient {\n\tconstructor(\n\t\tprivate http: HttpClient,\n\t\tprivate token: () => string | undefined,\n\t) {}\n\n\tsetup() {\n\t\treturn this.http.request<IApiResponse<IMfaSetupResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/mfa/setup',\n\t\t\ttoken: this.token(),\n\t\t});\n\t}\n\n\tverify(code: string) {\n\t\treturn this.http.request<IApiResponse<IMfaEnabledResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/mfa/verify',\n\t\t\tbody: { token: code },\n\t\t\ttoken: this.token(),\n\t\t});\n\t}\n\n\tdisable(code: string) {\n\t\treturn this.http.request<IApiResponse<undefined>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/mfa/disable',\n\t\t\tbody: { code },\n\t\t\ttoken: this.token(),\n\t\t});\n\t}\n}\n\n// ── Auth client ──────────────────────────────────────────────────────────────\n\nexport class AuthClient {\n\treadonly phone: PhoneClient;\n\treadonly mfa: MfaClient;\n\n\tconstructor(\n\t\tprivate http: HttpClient,\n\t\tprivate accessToken?: string,\n\t) {\n\t\tthis.phone = new PhoneClient(http);\n\t\tthis.mfa = new MfaClient(http, () => this.accessToken);\n\t}\n\n\tsetAccessToken(token: string | undefined) {\n\t\tthis.accessToken = token;\n\t}\n\n\t// ── Public ─────────────────────────────────────────────────────────────────\n\n\tregister(input: IRegisterInput) {\n\t\treturn this.http.request<IApiResponse<IRegisterResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/register',\n\t\t\tbody: input,\n\t\t});\n\t}\n\n\tlogin(input: ILoginInput) {\n\t\treturn this.http.request<IApiResponse<ILoginResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/login',\n\t\t\tbody: input,\n\t\t});\n\t}\n\n\trefreshTokens(refreshToken?: string) {\n\t\treturn this.http.request<IApiResponse<IRefreshResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/refresh',\n\t\t\tbody: refreshToken ? { refreshToken } : undefined,\n\t\t});\n\t}\n\n\tforgotPassword(email: string) {\n\t\treturn this.http.request<IApiResponse<undefined>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/email/forgot',\n\t\t\tbody: { email },\n\t\t});\n\t}\n\n\tresetPassword(input: IResetPasswordInput) {\n\t\treturn this.http.request<IApiResponse<undefined>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/email/reset',\n\t\t\tbody: input,\n\t\t});\n\t}\n\n\tverifyEmail(pin: string) {\n\t\treturn this.http.request<IApiResponse<IVerifyEmailResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/email/verify',\n\t\t\tbody: { pin },\n\t\t});\n\t}\n\n\t// ── Protected ──────────────────────────────────────────────────────────────\n\n\tlogout(refreshToken?: string) {\n\t\treturn this.http.request<IApiResponse<undefined>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/logout',\n\t\t\tbody: refreshToken ? { refreshToken } : undefined,\n\t\t\ttoken: this.accessToken,\n\t\t});\n\t}\n\n\tsendVerificationEmail() {\n\t\treturn this.http.request<IApiResponse<IResendVerificationResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/email/send-verification',\n\t\t\ttoken: this.accessToken,\n\t\t});\n\t}\n\n\t// ── Protected + Verified ───────────────────────────────────────────────────\n\n\tgetUser() {\n\t\treturn this.http.request<IApiResponse<IMeResult>>({\n\t\t\tmethod: 'GET',\n\t\t\tpath: '/users',\n\t\t\ttoken: this.accessToken,\n\t\t});\n\t}\n\n\tupdateUser(input: IUpdateUserInput) {\n\t\treturn this.http.request<IApiResponse<IMeResult>>({\n\t\t\tmethod: 'PUT',\n\t\t\tpath: '/users/update',\n\t\t\tbody: input,\n\t\t\ttoken: this.accessToken,\n\t\t});\n\t}\n\n\tdeleteUser() {\n\t\treturn this.http.request<IApiResponse<undefined>>({\n\t\t\tmethod: 'DELETE',\n\t\t\tpath: '/users',\n\t\t\ttoken: this.accessToken,\n\t\t});\n\t}\n}\n","import { HttpClient } from './http';\nimport { AuthClient } from './modules/auth';\n\nexport interface IFonderieClientOptions {\n\tbaseUrl: string;\n\taccessToken?: string;\n}\n\nexport class FonderieClient {\n\treadonly auth: AuthClient;\n\n\tprivate http: HttpClient;\n\n\tconstructor(opts: IFonderieClientOptions) {\n\t\tthis.http = new HttpClient(opts.baseUrl);\n\t\tthis.auth = new AuthClient(this.http, opts.accessToken);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EAC3C,YACiB,QACA,aACA,QACA,SACf;AACD,UAAM,WAAW;AALD;AACA;AACA;AACA;AAGhB,SAAK,OAAO;AAAA,EACb;AAAA,EAPiB;AAAA,EACA;AAAA,EACA;AAAA,E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BAAN,MAAqB;AAAA,EAClB;AAAA,EAED;AAAA,EAER,YAAY,MAA8B;AACzC,SAAK,OAAO,IAAI,WAAW,KAAK,OAAO;AACvC,SAAK,OAAO,IAAI,WAAW,KAAK,MAAM,KAAK,WAAW;AAAA,EACvD;AACD;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
declare class FonderieApiError extends Error {
|
|
2
|
+
readonly reason: string;
|
|
3
|
+
readonly explanation: string;
|
|
4
|
+
readonly status: number;
|
|
5
|
+
readonly details?: unknown | undefined;
|
|
6
|
+
constructor(reason: string, explanation: string, status: number, details?: unknown | undefined);
|
|
7
|
+
}
|
|
8
|
+
interface IRequestOptions {
|
|
9
|
+
method: string;
|
|
10
|
+
path: string;
|
|
11
|
+
body?: unknown;
|
|
12
|
+
token?: string | undefined;
|
|
13
|
+
cookie?: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
declare class HttpClient {
|
|
16
|
+
private baseUrl;
|
|
17
|
+
constructor(baseUrl: string);
|
|
18
|
+
request<T>(opts: IRequestOptions): Promise<T>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface IApiResponse<T = undefined> {
|
|
22
|
+
reason: string;
|
|
23
|
+
explanation: string;
|
|
24
|
+
result: T;
|
|
25
|
+
}
|
|
26
|
+
interface IApiError {
|
|
27
|
+
reason: string;
|
|
28
|
+
explanation: string;
|
|
29
|
+
details?: unknown;
|
|
30
|
+
}
|
|
31
|
+
interface IUserPreferences {
|
|
32
|
+
locale: string;
|
|
33
|
+
timezone: string;
|
|
34
|
+
notifications: {
|
|
35
|
+
email: boolean;
|
|
36
|
+
inApp: boolean;
|
|
37
|
+
sms: boolean;
|
|
38
|
+
push: boolean;
|
|
39
|
+
};
|
|
40
|
+
emailDigest: string;
|
|
41
|
+
dateFormat: string;
|
|
42
|
+
timeFormat: string;
|
|
43
|
+
}
|
|
44
|
+
interface IUserSkill {
|
|
45
|
+
name: string;
|
|
46
|
+
level: string;
|
|
47
|
+
}
|
|
48
|
+
interface IUserDTO {
|
|
49
|
+
id: string;
|
|
50
|
+
email: string;
|
|
51
|
+
firstName: string;
|
|
52
|
+
lastName: string;
|
|
53
|
+
phone: string;
|
|
54
|
+
profileImageUrl: string;
|
|
55
|
+
isActive: boolean;
|
|
56
|
+
lastLogin: string;
|
|
57
|
+
skills: IUserSkill[];
|
|
58
|
+
preferences: IUserPreferences;
|
|
59
|
+
isEmailVerified: boolean;
|
|
60
|
+
mfaEnabled: boolean;
|
|
61
|
+
suspended: boolean;
|
|
62
|
+
whitelist: boolean;
|
|
63
|
+
ipWhitelist: string[];
|
|
64
|
+
createdAt: string;
|
|
65
|
+
updatedAt: string;
|
|
66
|
+
}
|
|
67
|
+
interface ITokens {
|
|
68
|
+
access: string;
|
|
69
|
+
refresh: string;
|
|
70
|
+
}
|
|
71
|
+
interface IRegisterResult {
|
|
72
|
+
tokens: ITokens;
|
|
73
|
+
user: IUserDTO;
|
|
74
|
+
}
|
|
75
|
+
interface ILoginResult {
|
|
76
|
+
tokens: ITokens;
|
|
77
|
+
user: IUserDTO;
|
|
78
|
+
}
|
|
79
|
+
interface IRefreshResult {
|
|
80
|
+
tokens: ITokens;
|
|
81
|
+
}
|
|
82
|
+
interface IVerifyEmailResult {
|
|
83
|
+
verified: boolean;
|
|
84
|
+
email: string;
|
|
85
|
+
}
|
|
86
|
+
interface IResendVerificationResult {
|
|
87
|
+
stat: string;
|
|
88
|
+
message: string;
|
|
89
|
+
data: {
|
|
90
|
+
token: string;
|
|
91
|
+
expiresAt: string;
|
|
92
|
+
email: string;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
interface IMeResult {
|
|
96
|
+
user: IUserDTO;
|
|
97
|
+
}
|
|
98
|
+
interface IMfaSetupResult {
|
|
99
|
+
secret: string;
|
|
100
|
+
uri: string;
|
|
101
|
+
}
|
|
102
|
+
interface IMfaEnabledResult {
|
|
103
|
+
tokens: ITokens;
|
|
104
|
+
user: IUserDTO;
|
|
105
|
+
}
|
|
106
|
+
interface IPhoneVerifyResult {
|
|
107
|
+
tokens: ITokens;
|
|
108
|
+
user: IUserDTO;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface IRegisterInput {
|
|
112
|
+
email: string;
|
|
113
|
+
password: string;
|
|
114
|
+
firstName?: string;
|
|
115
|
+
lastName?: string;
|
|
116
|
+
}
|
|
117
|
+
interface ILoginInput {
|
|
118
|
+
email: string;
|
|
119
|
+
password: string;
|
|
120
|
+
}
|
|
121
|
+
interface IResetPasswordInput {
|
|
122
|
+
resetToken: string;
|
|
123
|
+
password: string;
|
|
124
|
+
}
|
|
125
|
+
interface IUpdateUserInput {
|
|
126
|
+
firstName?: string;
|
|
127
|
+
lastName?: string;
|
|
128
|
+
phoneNumber?: string;
|
|
129
|
+
avatarUrl?: string;
|
|
130
|
+
locale?: string;
|
|
131
|
+
timezone?: string;
|
|
132
|
+
preferences?: Record<string, unknown>;
|
|
133
|
+
}
|
|
134
|
+
declare class PhoneClient {
|
|
135
|
+
private http;
|
|
136
|
+
constructor(http: HttpClient);
|
|
137
|
+
sendVerification(phone: string): Promise<IApiResponse<undefined>>;
|
|
138
|
+
verify(phone: string, otp: string): Promise<IApiResponse<IPhoneVerifyResult>>;
|
|
139
|
+
}
|
|
140
|
+
declare class MfaClient {
|
|
141
|
+
private http;
|
|
142
|
+
private token;
|
|
143
|
+
constructor(http: HttpClient, token: () => string | undefined);
|
|
144
|
+
setup(): Promise<IApiResponse<IMfaSetupResult>>;
|
|
145
|
+
verify(code: string): Promise<IApiResponse<IMfaEnabledResult>>;
|
|
146
|
+
disable(code: string): Promise<IApiResponse<undefined>>;
|
|
147
|
+
}
|
|
148
|
+
declare class AuthClient {
|
|
149
|
+
private http;
|
|
150
|
+
private accessToken?;
|
|
151
|
+
readonly phone: PhoneClient;
|
|
152
|
+
readonly mfa: MfaClient;
|
|
153
|
+
constructor(http: HttpClient, accessToken?: string | undefined);
|
|
154
|
+
setAccessToken(token: string | undefined): void;
|
|
155
|
+
register(input: IRegisterInput): Promise<IApiResponse<IRegisterResult>>;
|
|
156
|
+
login(input: ILoginInput): Promise<IApiResponse<ILoginResult>>;
|
|
157
|
+
refreshTokens(refreshToken?: string): Promise<IApiResponse<IRefreshResult>>;
|
|
158
|
+
forgotPassword(email: string): Promise<IApiResponse<undefined>>;
|
|
159
|
+
resetPassword(input: IResetPasswordInput): Promise<IApiResponse<undefined>>;
|
|
160
|
+
verifyEmail(pin: string): Promise<IApiResponse<IVerifyEmailResult>>;
|
|
161
|
+
logout(refreshToken?: string): Promise<IApiResponse<undefined>>;
|
|
162
|
+
sendVerificationEmail(): Promise<IApiResponse<IResendVerificationResult>>;
|
|
163
|
+
getUser(): Promise<IApiResponse<IMeResult>>;
|
|
164
|
+
updateUser(input: IUpdateUserInput): Promise<IApiResponse<IMeResult>>;
|
|
165
|
+
deleteUser(): Promise<IApiResponse<undefined>>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
interface IFonderieClientOptions {
|
|
169
|
+
baseUrl: string;
|
|
170
|
+
accessToken?: string;
|
|
171
|
+
}
|
|
172
|
+
declare class FonderieClient {
|
|
173
|
+
readonly auth: AuthClient;
|
|
174
|
+
private http;
|
|
175
|
+
constructor(opts: IFonderieClientOptions);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export { AuthClient, FonderieApiError, FonderieClient, type IApiError, type IApiResponse, type IFonderieClientOptions, type ILoginInput, type ILoginResult, type IMeResult, type IMfaEnabledResult, type IMfaSetupResult, type IRefreshResult, type IRegisterInput, type IRegisterResult, type IResendVerificationResult, type IResetPasswordInput, type ITokens, type IUpdateUserInput, type IUserDTO, type IUserPreferences, type IUserSkill, type IVerifyEmailResult };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
declare class FonderieApiError extends Error {
|
|
2
|
+
readonly reason: string;
|
|
3
|
+
readonly explanation: string;
|
|
4
|
+
readonly status: number;
|
|
5
|
+
readonly details?: unknown | undefined;
|
|
6
|
+
constructor(reason: string, explanation: string, status: number, details?: unknown | undefined);
|
|
7
|
+
}
|
|
8
|
+
interface IRequestOptions {
|
|
9
|
+
method: string;
|
|
10
|
+
path: string;
|
|
11
|
+
body?: unknown;
|
|
12
|
+
token?: string | undefined;
|
|
13
|
+
cookie?: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
declare class HttpClient {
|
|
16
|
+
private baseUrl;
|
|
17
|
+
constructor(baseUrl: string);
|
|
18
|
+
request<T>(opts: IRequestOptions): Promise<T>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface IApiResponse<T = undefined> {
|
|
22
|
+
reason: string;
|
|
23
|
+
explanation: string;
|
|
24
|
+
result: T;
|
|
25
|
+
}
|
|
26
|
+
interface IApiError {
|
|
27
|
+
reason: string;
|
|
28
|
+
explanation: string;
|
|
29
|
+
details?: unknown;
|
|
30
|
+
}
|
|
31
|
+
interface IUserPreferences {
|
|
32
|
+
locale: string;
|
|
33
|
+
timezone: string;
|
|
34
|
+
notifications: {
|
|
35
|
+
email: boolean;
|
|
36
|
+
inApp: boolean;
|
|
37
|
+
sms: boolean;
|
|
38
|
+
push: boolean;
|
|
39
|
+
};
|
|
40
|
+
emailDigest: string;
|
|
41
|
+
dateFormat: string;
|
|
42
|
+
timeFormat: string;
|
|
43
|
+
}
|
|
44
|
+
interface IUserSkill {
|
|
45
|
+
name: string;
|
|
46
|
+
level: string;
|
|
47
|
+
}
|
|
48
|
+
interface IUserDTO {
|
|
49
|
+
id: string;
|
|
50
|
+
email: string;
|
|
51
|
+
firstName: string;
|
|
52
|
+
lastName: string;
|
|
53
|
+
phone: string;
|
|
54
|
+
profileImageUrl: string;
|
|
55
|
+
isActive: boolean;
|
|
56
|
+
lastLogin: string;
|
|
57
|
+
skills: IUserSkill[];
|
|
58
|
+
preferences: IUserPreferences;
|
|
59
|
+
isEmailVerified: boolean;
|
|
60
|
+
mfaEnabled: boolean;
|
|
61
|
+
suspended: boolean;
|
|
62
|
+
whitelist: boolean;
|
|
63
|
+
ipWhitelist: string[];
|
|
64
|
+
createdAt: string;
|
|
65
|
+
updatedAt: string;
|
|
66
|
+
}
|
|
67
|
+
interface ITokens {
|
|
68
|
+
access: string;
|
|
69
|
+
refresh: string;
|
|
70
|
+
}
|
|
71
|
+
interface IRegisterResult {
|
|
72
|
+
tokens: ITokens;
|
|
73
|
+
user: IUserDTO;
|
|
74
|
+
}
|
|
75
|
+
interface ILoginResult {
|
|
76
|
+
tokens: ITokens;
|
|
77
|
+
user: IUserDTO;
|
|
78
|
+
}
|
|
79
|
+
interface IRefreshResult {
|
|
80
|
+
tokens: ITokens;
|
|
81
|
+
}
|
|
82
|
+
interface IVerifyEmailResult {
|
|
83
|
+
verified: boolean;
|
|
84
|
+
email: string;
|
|
85
|
+
}
|
|
86
|
+
interface IResendVerificationResult {
|
|
87
|
+
stat: string;
|
|
88
|
+
message: string;
|
|
89
|
+
data: {
|
|
90
|
+
token: string;
|
|
91
|
+
expiresAt: string;
|
|
92
|
+
email: string;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
interface IMeResult {
|
|
96
|
+
user: IUserDTO;
|
|
97
|
+
}
|
|
98
|
+
interface IMfaSetupResult {
|
|
99
|
+
secret: string;
|
|
100
|
+
uri: string;
|
|
101
|
+
}
|
|
102
|
+
interface IMfaEnabledResult {
|
|
103
|
+
tokens: ITokens;
|
|
104
|
+
user: IUserDTO;
|
|
105
|
+
}
|
|
106
|
+
interface IPhoneVerifyResult {
|
|
107
|
+
tokens: ITokens;
|
|
108
|
+
user: IUserDTO;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface IRegisterInput {
|
|
112
|
+
email: string;
|
|
113
|
+
password: string;
|
|
114
|
+
firstName?: string;
|
|
115
|
+
lastName?: string;
|
|
116
|
+
}
|
|
117
|
+
interface ILoginInput {
|
|
118
|
+
email: string;
|
|
119
|
+
password: string;
|
|
120
|
+
}
|
|
121
|
+
interface IResetPasswordInput {
|
|
122
|
+
resetToken: string;
|
|
123
|
+
password: string;
|
|
124
|
+
}
|
|
125
|
+
interface IUpdateUserInput {
|
|
126
|
+
firstName?: string;
|
|
127
|
+
lastName?: string;
|
|
128
|
+
phoneNumber?: string;
|
|
129
|
+
avatarUrl?: string;
|
|
130
|
+
locale?: string;
|
|
131
|
+
timezone?: string;
|
|
132
|
+
preferences?: Record<string, unknown>;
|
|
133
|
+
}
|
|
134
|
+
declare class PhoneClient {
|
|
135
|
+
private http;
|
|
136
|
+
constructor(http: HttpClient);
|
|
137
|
+
sendVerification(phone: string): Promise<IApiResponse<undefined>>;
|
|
138
|
+
verify(phone: string, otp: string): Promise<IApiResponse<IPhoneVerifyResult>>;
|
|
139
|
+
}
|
|
140
|
+
declare class MfaClient {
|
|
141
|
+
private http;
|
|
142
|
+
private token;
|
|
143
|
+
constructor(http: HttpClient, token: () => string | undefined);
|
|
144
|
+
setup(): Promise<IApiResponse<IMfaSetupResult>>;
|
|
145
|
+
verify(code: string): Promise<IApiResponse<IMfaEnabledResult>>;
|
|
146
|
+
disable(code: string): Promise<IApiResponse<undefined>>;
|
|
147
|
+
}
|
|
148
|
+
declare class AuthClient {
|
|
149
|
+
private http;
|
|
150
|
+
private accessToken?;
|
|
151
|
+
readonly phone: PhoneClient;
|
|
152
|
+
readonly mfa: MfaClient;
|
|
153
|
+
constructor(http: HttpClient, accessToken?: string | undefined);
|
|
154
|
+
setAccessToken(token: string | undefined): void;
|
|
155
|
+
register(input: IRegisterInput): Promise<IApiResponse<IRegisterResult>>;
|
|
156
|
+
login(input: ILoginInput): Promise<IApiResponse<ILoginResult>>;
|
|
157
|
+
refreshTokens(refreshToken?: string): Promise<IApiResponse<IRefreshResult>>;
|
|
158
|
+
forgotPassword(email: string): Promise<IApiResponse<undefined>>;
|
|
159
|
+
resetPassword(input: IResetPasswordInput): Promise<IApiResponse<undefined>>;
|
|
160
|
+
verifyEmail(pin: string): Promise<IApiResponse<IVerifyEmailResult>>;
|
|
161
|
+
logout(refreshToken?: string): Promise<IApiResponse<undefined>>;
|
|
162
|
+
sendVerificationEmail(): Promise<IApiResponse<IResendVerificationResult>>;
|
|
163
|
+
getUser(): Promise<IApiResponse<IMeResult>>;
|
|
164
|
+
updateUser(input: IUpdateUserInput): Promise<IApiResponse<IMeResult>>;
|
|
165
|
+
deleteUser(): Promise<IApiResponse<undefined>>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
interface IFonderieClientOptions {
|
|
169
|
+
baseUrl: string;
|
|
170
|
+
accessToken?: string;
|
|
171
|
+
}
|
|
172
|
+
declare class FonderieClient {
|
|
173
|
+
readonly auth: AuthClient;
|
|
174
|
+
private http;
|
|
175
|
+
constructor(opts: IFonderieClientOptions);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export { AuthClient, FonderieApiError, FonderieClient, type IApiError, type IApiResponse, type IFonderieClientOptions, type ILoginInput, type ILoginResult, type IMeResult, type IMfaEnabledResult, type IMfaSetupResult, type IRefreshResult, type IRegisterInput, type IRegisterResult, type IResendVerificationResult, type IResetPasswordInput, type ITokens, type IUpdateUserInput, type IUserDTO, type IUserPreferences, type IUserSkill, type IVerifyEmailResult };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// src/http.ts
|
|
2
|
+
var FonderieApiError = class extends Error {
|
|
3
|
+
constructor(reason, explanation, status, details) {
|
|
4
|
+
super(explanation);
|
|
5
|
+
this.reason = reason;
|
|
6
|
+
this.explanation = explanation;
|
|
7
|
+
this.status = status;
|
|
8
|
+
this.details = details;
|
|
9
|
+
this.name = "FonderieApiError";
|
|
10
|
+
}
|
|
11
|
+
reason;
|
|
12
|
+
explanation;
|
|
13
|
+
status;
|
|
14
|
+
details;
|
|
15
|
+
};
|
|
16
|
+
var HttpClient = class {
|
|
17
|
+
constructor(baseUrl) {
|
|
18
|
+
this.baseUrl = baseUrl;
|
|
19
|
+
}
|
|
20
|
+
baseUrl;
|
|
21
|
+
async request(opts) {
|
|
22
|
+
const headers = {
|
|
23
|
+
"Content-Type": "application/json"
|
|
24
|
+
};
|
|
25
|
+
if (opts.token) headers["Authorization"] = `Bearer ${opts.token}`;
|
|
26
|
+
if (opts.cookie) headers["Cookie"] = opts.cookie;
|
|
27
|
+
const fetchInit = {
|
|
28
|
+
method: opts.method,
|
|
29
|
+
headers,
|
|
30
|
+
credentials: "include"
|
|
31
|
+
};
|
|
32
|
+
if (opts.body !== void 0) fetchInit.body = JSON.stringify(opts.body);
|
|
33
|
+
const res = await fetch(`${this.baseUrl}${opts.path}`, fetchInit);
|
|
34
|
+
const data = await res.json();
|
|
35
|
+
if (!res.ok || res.status === 202) {
|
|
36
|
+
const err = data;
|
|
37
|
+
throw new FonderieApiError(err.reason, err.explanation, res.status, err.details);
|
|
38
|
+
}
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// src/modules/auth.ts
|
|
44
|
+
var PhoneClient = class {
|
|
45
|
+
constructor(http) {
|
|
46
|
+
this.http = http;
|
|
47
|
+
}
|
|
48
|
+
http;
|
|
49
|
+
sendVerification(phone) {
|
|
50
|
+
return this.http.request({
|
|
51
|
+
method: "POST",
|
|
52
|
+
path: "/auth/phone/send-verification",
|
|
53
|
+
body: { phone }
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
verify(phone, otp) {
|
|
57
|
+
return this.http.request({
|
|
58
|
+
method: "POST",
|
|
59
|
+
path: "/auth/phone/verify",
|
|
60
|
+
body: { phone, otp }
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var MfaClient = class {
|
|
65
|
+
constructor(http, token) {
|
|
66
|
+
this.http = http;
|
|
67
|
+
this.token = token;
|
|
68
|
+
}
|
|
69
|
+
http;
|
|
70
|
+
token;
|
|
71
|
+
setup() {
|
|
72
|
+
return this.http.request({
|
|
73
|
+
method: "POST",
|
|
74
|
+
path: "/auth/mfa/setup",
|
|
75
|
+
token: this.token()
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
verify(code) {
|
|
79
|
+
return this.http.request({
|
|
80
|
+
method: "POST",
|
|
81
|
+
path: "/auth/mfa/verify",
|
|
82
|
+
body: { token: code },
|
|
83
|
+
token: this.token()
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
disable(code) {
|
|
87
|
+
return this.http.request({
|
|
88
|
+
method: "POST",
|
|
89
|
+
path: "/auth/mfa/disable",
|
|
90
|
+
body: { code },
|
|
91
|
+
token: this.token()
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var AuthClient = class {
|
|
96
|
+
constructor(http, accessToken) {
|
|
97
|
+
this.http = http;
|
|
98
|
+
this.accessToken = accessToken;
|
|
99
|
+
this.phone = new PhoneClient(http);
|
|
100
|
+
this.mfa = new MfaClient(http, () => this.accessToken);
|
|
101
|
+
}
|
|
102
|
+
http;
|
|
103
|
+
accessToken;
|
|
104
|
+
phone;
|
|
105
|
+
mfa;
|
|
106
|
+
setAccessToken(token) {
|
|
107
|
+
this.accessToken = token;
|
|
108
|
+
}
|
|
109
|
+
// ── Public ─────────────────────────────────────────────────────────────────
|
|
110
|
+
register(input) {
|
|
111
|
+
return this.http.request({
|
|
112
|
+
method: "POST",
|
|
113
|
+
path: "/auth/register",
|
|
114
|
+
body: input
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
login(input) {
|
|
118
|
+
return this.http.request({
|
|
119
|
+
method: "POST",
|
|
120
|
+
path: "/auth/login",
|
|
121
|
+
body: input
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
refreshTokens(refreshToken) {
|
|
125
|
+
return this.http.request({
|
|
126
|
+
method: "POST",
|
|
127
|
+
path: "/auth/refresh",
|
|
128
|
+
body: refreshToken ? { refreshToken } : void 0
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
forgotPassword(email) {
|
|
132
|
+
return this.http.request({
|
|
133
|
+
method: "POST",
|
|
134
|
+
path: "/auth/email/forgot",
|
|
135
|
+
body: { email }
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
resetPassword(input) {
|
|
139
|
+
return this.http.request({
|
|
140
|
+
method: "POST",
|
|
141
|
+
path: "/auth/email/reset",
|
|
142
|
+
body: input
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
verifyEmail(pin) {
|
|
146
|
+
return this.http.request({
|
|
147
|
+
method: "POST",
|
|
148
|
+
path: "/auth/email/verify",
|
|
149
|
+
body: { pin }
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
// ── Protected ──────────────────────────────────────────────────────────────
|
|
153
|
+
logout(refreshToken) {
|
|
154
|
+
return this.http.request({
|
|
155
|
+
method: "POST",
|
|
156
|
+
path: "/auth/logout",
|
|
157
|
+
body: refreshToken ? { refreshToken } : void 0,
|
|
158
|
+
token: this.accessToken
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
sendVerificationEmail() {
|
|
162
|
+
return this.http.request({
|
|
163
|
+
method: "POST",
|
|
164
|
+
path: "/auth/email/send-verification",
|
|
165
|
+
token: this.accessToken
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
// ── Protected + Verified ───────────────────────────────────────────────────
|
|
169
|
+
getUser() {
|
|
170
|
+
return this.http.request({
|
|
171
|
+
method: "GET",
|
|
172
|
+
path: "/users",
|
|
173
|
+
token: this.accessToken
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
updateUser(input) {
|
|
177
|
+
return this.http.request({
|
|
178
|
+
method: "PUT",
|
|
179
|
+
path: "/users/update",
|
|
180
|
+
body: input,
|
|
181
|
+
token: this.accessToken
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
deleteUser() {
|
|
185
|
+
return this.http.request({
|
|
186
|
+
method: "DELETE",
|
|
187
|
+
path: "/users",
|
|
188
|
+
token: this.accessToken
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// src/client.ts
|
|
194
|
+
var FonderieClient = class {
|
|
195
|
+
auth;
|
|
196
|
+
http;
|
|
197
|
+
constructor(opts) {
|
|
198
|
+
this.http = new HttpClient(opts.baseUrl);
|
|
199
|
+
this.auth = new AuthClient(this.http, opts.accessToken);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
export {
|
|
203
|
+
AuthClient,
|
|
204
|
+
FonderieApiError,
|
|
205
|
+
FonderieClient
|
|
206
|
+
};
|
|
207
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/http.ts","../src/modules/auth.ts","../src/client.ts"],"sourcesContent":["import type { IApiError } from './types';\n\nexport class FonderieApiError extends Error {\n\tconstructor(\n\t\tpublic readonly reason: string,\n\t\tpublic readonly explanation: string,\n\t\tpublic readonly status: number,\n\t\tpublic readonly details?: unknown,\n\t) {\n\t\tsuper(explanation);\n\t\tthis.name = 'FonderieApiError';\n\t}\n}\n\nexport interface IRequestOptions {\n\tmethod: string;\n\tpath: string;\n\tbody?: unknown;\n\ttoken?: string | undefined;\n\tcookie?: string | undefined;\n}\n\nexport class HttpClient {\n\tconstructor(private baseUrl: string) {}\n\n\tasync request<T>(opts: IRequestOptions): Promise<T> {\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Content-Type': 'application/json',\n\t\t};\n\n\t\tif (opts.token) headers['Authorization'] = `Bearer ${opts.token}`;\n\t\tif (opts.cookie) headers['Cookie'] = opts.cookie;\n\n\t\tconst fetchInit: RequestInit = {\n\t\t\tmethod: opts.method,\n\t\t\theaders,\n\t\t\tcredentials: 'include',\n\t\t};\n\t\tif (opts.body !== undefined) fetchInit.body = JSON.stringify(opts.body);\n\n\t\tconst res = await fetch(`${this.baseUrl}${opts.path}`, fetchInit);\n\n\t\tconst data = (await res.json()) as T | IApiError;\n\n\t\tif (!res.ok || res.status === 202) {\n\t\t\tconst err = data as IApiError;\n\t\t\tthrow new FonderieApiError(err.reason, err.explanation, res.status, err.details);\n\t\t}\n\n\t\treturn data as T;\n\t}\n}\n","import type { HttpClient } from '../http';\nimport type {\n\tIApiResponse,\n\tIRegisterResult,\n\tILoginResult,\n\tIRefreshResult,\n\tIVerifyEmailResult,\n\tIResendVerificationResult,\n\tIMeResult,\n\tIMfaSetupResult,\n\tIMfaEnabledResult,\n\tIPhoneVerifyResult,\n} from '../types';\n\n// ── Input shapes ─────────────────────────────────────────────────────────────\n\nexport interface IRegisterInput {\n\temail: string;\n\tpassword: string;\n\tfirstName?: string;\n\tlastName?: string;\n}\n\nexport interface ILoginInput {\n\temail: string;\n\tpassword: string;\n}\n\nexport interface IResetPasswordInput {\n\tresetToken: string;\n\tpassword: string;\n}\n\nexport interface IUpdateUserInput {\n\tfirstName?: string;\n\tlastName?: string;\n\tphoneNumber?: string;\n\tavatarUrl?: string;\n\tlocale?: string;\n\ttimezone?: string;\n\tpreferences?: Record<string, unknown>;\n}\n\n// ── Phone sub-client ─────────────────────────────────────────────────────────\n\nclass PhoneClient {\n\tconstructor(private http: HttpClient) {}\n\n\tsendVerification(phone: string) {\n\t\treturn this.http.request<IApiResponse<undefined>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/phone/send-verification',\n\t\t\tbody: { phone },\n\t\t});\n\t}\n\n\tverify(phone: string, otp: string) {\n\t\treturn this.http.request<IApiResponse<IPhoneVerifyResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/phone/verify',\n\t\t\tbody: { phone, otp },\n\t\t});\n\t}\n}\n\n// ── MFA sub-client ───────────────────────────────────────────────────────────\n\nclass MfaClient {\n\tconstructor(\n\t\tprivate http: HttpClient,\n\t\tprivate token: () => string | undefined,\n\t) {}\n\n\tsetup() {\n\t\treturn this.http.request<IApiResponse<IMfaSetupResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/mfa/setup',\n\t\t\ttoken: this.token(),\n\t\t});\n\t}\n\n\tverify(code: string) {\n\t\treturn this.http.request<IApiResponse<IMfaEnabledResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/mfa/verify',\n\t\t\tbody: { token: code },\n\t\t\ttoken: this.token(),\n\t\t});\n\t}\n\n\tdisable(code: string) {\n\t\treturn this.http.request<IApiResponse<undefined>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/mfa/disable',\n\t\t\tbody: { code },\n\t\t\ttoken: this.token(),\n\t\t});\n\t}\n}\n\n// ── Auth client ──────────────────────────────────────────────────────────────\n\nexport class AuthClient {\n\treadonly phone: PhoneClient;\n\treadonly mfa: MfaClient;\n\n\tconstructor(\n\t\tprivate http: HttpClient,\n\t\tprivate accessToken?: string,\n\t) {\n\t\tthis.phone = new PhoneClient(http);\n\t\tthis.mfa = new MfaClient(http, () => this.accessToken);\n\t}\n\n\tsetAccessToken(token: string | undefined) {\n\t\tthis.accessToken = token;\n\t}\n\n\t// ── Public ─────────────────────────────────────────────────────────────────\n\n\tregister(input: IRegisterInput) {\n\t\treturn this.http.request<IApiResponse<IRegisterResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/register',\n\t\t\tbody: input,\n\t\t});\n\t}\n\n\tlogin(input: ILoginInput) {\n\t\treturn this.http.request<IApiResponse<ILoginResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/login',\n\t\t\tbody: input,\n\t\t});\n\t}\n\n\trefreshTokens(refreshToken?: string) {\n\t\treturn this.http.request<IApiResponse<IRefreshResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/refresh',\n\t\t\tbody: refreshToken ? { refreshToken } : undefined,\n\t\t});\n\t}\n\n\tforgotPassword(email: string) {\n\t\treturn this.http.request<IApiResponse<undefined>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/email/forgot',\n\t\t\tbody: { email },\n\t\t});\n\t}\n\n\tresetPassword(input: IResetPasswordInput) {\n\t\treturn this.http.request<IApiResponse<undefined>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/email/reset',\n\t\t\tbody: input,\n\t\t});\n\t}\n\n\tverifyEmail(pin: string) {\n\t\treturn this.http.request<IApiResponse<IVerifyEmailResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/email/verify',\n\t\t\tbody: { pin },\n\t\t});\n\t}\n\n\t// ── Protected ──────────────────────────────────────────────────────────────\n\n\tlogout(refreshToken?: string) {\n\t\treturn this.http.request<IApiResponse<undefined>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/logout',\n\t\t\tbody: refreshToken ? { refreshToken } : undefined,\n\t\t\ttoken: this.accessToken,\n\t\t});\n\t}\n\n\tsendVerificationEmail() {\n\t\treturn this.http.request<IApiResponse<IResendVerificationResult>>({\n\t\t\tmethod: 'POST',\n\t\t\tpath: '/auth/email/send-verification',\n\t\t\ttoken: this.accessToken,\n\t\t});\n\t}\n\n\t// ── Protected + Verified ───────────────────────────────────────────────────\n\n\tgetUser() {\n\t\treturn this.http.request<IApiResponse<IMeResult>>({\n\t\t\tmethod: 'GET',\n\t\t\tpath: '/users',\n\t\t\ttoken: this.accessToken,\n\t\t});\n\t}\n\n\tupdateUser(input: IUpdateUserInput) {\n\t\treturn this.http.request<IApiResponse<IMeResult>>({\n\t\t\tmethod: 'PUT',\n\t\t\tpath: '/users/update',\n\t\t\tbody: input,\n\t\t\ttoken: this.accessToken,\n\t\t});\n\t}\n\n\tdeleteUser() {\n\t\treturn this.http.request<IApiResponse<undefined>>({\n\t\t\tmethod: 'DELETE',\n\t\t\tpath: '/users',\n\t\t\ttoken: this.accessToken,\n\t\t});\n\t}\n}\n","import { HttpClient } from './http';\nimport { AuthClient } from './modules/auth';\n\nexport interface IFonderieClientOptions {\n\tbaseUrl: string;\n\taccessToken?: string;\n}\n\nexport class FonderieClient {\n\treadonly auth: AuthClient;\n\n\tprivate http: HttpClient;\n\n\tconstructor(opts: IFonderieClientOptions) {\n\t\tthis.http = new HttpClient(opts.base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;AAAA,MACR,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,KAAK;AAAA,IACb,CAAC;AAAA,EACF;AAAA,EAEA,aAAa;AACZ,WAAO,KAAK,KAAK,QAAiC;AAAA,MACjD,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,OAAO,KAAK;AAAA,IACb,CAAC;AAAA,EACF;AACD;;;AC7MO,IAAM,iBAAN,MAAqB;AAAA,EAClB;AAAA,EAED;AAAA,EAER,YAAY,MAA8B;AACzC,SAAK,OAAO,IAAI,WAAW,KAAK,OAAO;AACvC,SAAK,OAAO,IAAI,WAAW,KAAK,MAAM,KAAK,WAAW;AAAA,EACvD;AACD;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fonderie/client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Isomorphic TypeScript client for Fonderie-powered APIs — fully typed request and response shapes, zero runtime dependencies.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"fonderie-js",
|
|
7
|
+
"client",
|
|
8
|
+
"http-client",
|
|
9
|
+
"sdk",
|
|
10
|
+
"saas",
|
|
11
|
+
"typescript"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"require": "./dist/index.cjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/index.cjs",
|
|
26
|
+
"module": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsup",
|
|
30
|
+
"dev": "tsup --watch",
|
|
31
|
+
"typecheck": "tsc --noEmit"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^25.6.0",
|
|
35
|
+
"tsup": "^8.5.1",
|
|
36
|
+
"typescript": "^6.0.3"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"LICENSE",
|
|
44
|
+
"README.md"
|
|
45
|
+
],
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+https://github.com/fonderie-js/sdk.git",
|
|
49
|
+
"directory": "packages/client"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://github.com/fonderie-js/sdk/tree/main/packages/client#readme",
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/fonderie-js/sdk/issues"
|
|
54
|
+
}
|
|
55
|
+
}
|