@nexusrt/nexus-auth 1.0.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/README.md +277 -0
- package/dist/client.d.ts +106 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/http.d.ts +11 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/index.d.mts +466 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +613 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +506 -0
- package/dist/methods/emailMfa.d.ts +18 -0
- package/dist/methods/emailMfa.d.ts.map +1 -0
- package/dist/methods/emailPassword.d.ts +52 -0
- package/dist/methods/emailPassword.d.ts.map +1 -0
- package/dist/methods/magicLink.d.ts +27 -0
- package/dist/methods/magicLink.d.ts.map +1 -0
- package/dist/methods/password.d.ts +37 -0
- package/dist/methods/password.d.ts.map +1 -0
- package/dist/methods/session.d.ts +27 -0
- package/dist/methods/session.d.ts.map +1 -0
- package/dist/methods/sso.d.ts +34 -0
- package/dist/methods/sso.d.ts.map +1 -0
- package/dist/methods/token.d.ts +32 -0
- package/dist/methods/token.d.ts.map +1 -0
- package/dist/methods/totp.d.ts +34 -0
- package/dist/methods/totp.d.ts.map +1 -0
- package/dist/providers/social.d.ts +23 -0
- package/dist/providers/social.d.ts.map +1 -0
- package/dist/types/index.d.ts +92 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +43 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.AuthSDK = {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Lightweight fetch wrapper used internally by the SDK.
|
|
9
|
+
* All requests automatically include credentials (cookies) for session support.
|
|
10
|
+
*/
|
|
11
|
+
async function request(url, options = {}) {
|
|
12
|
+
const response = await fetch(url, {
|
|
13
|
+
...options,
|
|
14
|
+
credentials: "include", // required for cookie-based sessions
|
|
15
|
+
headers: {
|
|
16
|
+
"Content-Type": "application/json",
|
|
17
|
+
...options.headers,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const data = await response.json().catch(() => null);
|
|
21
|
+
if (!response.ok) {
|
|
22
|
+
const message = data?.message ??
|
|
23
|
+
`Request failed with status ${response.status}`;
|
|
24
|
+
throw new AuthError(message, response.status, data);
|
|
25
|
+
}
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
// ─────────────────────────────────────────────
|
|
29
|
+
// Typed error class so callers can catch and inspect failures
|
|
30
|
+
// ─────────────────────────────────────────────
|
|
31
|
+
class AuthError extends Error {
|
|
32
|
+
constructor(message, status, body = null) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.status = status;
|
|
35
|
+
this.body = body;
|
|
36
|
+
this.name = "AuthError";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Manages the in-memory access token and exposes token-based auth helpers.
|
|
42
|
+
*
|
|
43
|
+
* Storage strategy:
|
|
44
|
+
* - Access tokens are kept in memory only (never localStorage) for security.
|
|
45
|
+
* - Refresh tokens are stored in an HttpOnly cookie by the server.
|
|
46
|
+
*/
|
|
47
|
+
class TokenManager {
|
|
48
|
+
constructor() {
|
|
49
|
+
this.accessToken = null;
|
|
50
|
+
}
|
|
51
|
+
// ── Getters / Setters ───────────────────────────────────────────────────
|
|
52
|
+
getAccessToken() {
|
|
53
|
+
return this.accessToken;
|
|
54
|
+
}
|
|
55
|
+
setAccessToken(token) {
|
|
56
|
+
this.accessToken = token;
|
|
57
|
+
}
|
|
58
|
+
clearAccessToken() {
|
|
59
|
+
this.accessToken = null;
|
|
60
|
+
}
|
|
61
|
+
// ── JWT helpers ─────────────────────────────────────────────────────────
|
|
62
|
+
/**
|
|
63
|
+
* Decodes the JWT payload without verifying the signature.
|
|
64
|
+
* Useful for reading user info (email, avatar) on the client side.
|
|
65
|
+
*/
|
|
66
|
+
decodeToken(token) {
|
|
67
|
+
try {
|
|
68
|
+
const payload = token.split(".")[1];
|
|
69
|
+
return JSON.parse(atob(payload));
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Reads user info directly from the stored access token.
|
|
77
|
+
* Returns null if no token is set or it cannot be decoded.
|
|
78
|
+
*/
|
|
79
|
+
getUserFromToken() {
|
|
80
|
+
if (!this.accessToken)
|
|
81
|
+
return null;
|
|
82
|
+
const payload = this.decodeToken(this.accessToken);
|
|
83
|
+
if (!payload)
|
|
84
|
+
return null;
|
|
85
|
+
return {
|
|
86
|
+
email: payload.email,
|
|
87
|
+
avatar_url: payload.avatar_url,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
// ── Refresh ─────────────────────────────────────────────────────────────
|
|
91
|
+
/**
|
|
92
|
+
* Attempts to get a new access token using the HttpOnly refresh-token cookie.
|
|
93
|
+
* Call this once on app startup to restore an existing session.
|
|
94
|
+
*
|
|
95
|
+
* @returns The decoded user info on success, or null if no refresh token exists.
|
|
96
|
+
*/
|
|
97
|
+
async refresh(baseUrl) {
|
|
98
|
+
try {
|
|
99
|
+
const data = await request(`${baseUrl}/auth/refresh`, { method: "POST" });
|
|
100
|
+
this.setAccessToken(data.access_token);
|
|
101
|
+
return this.getUserFromToken();
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// No refresh token cookie present — user is not logged in
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Session-based auth helpers.
|
|
112
|
+
*
|
|
113
|
+
* When the developer chooses sessions over JWTs, the server sets an
|
|
114
|
+
* HttpOnly session cookie. These methods let you read and verify
|
|
115
|
+
* that session without managing tokens yourself.
|
|
116
|
+
*
|
|
117
|
+
* Note: An access token is still returned by the server even in session
|
|
118
|
+
* mode, so you can use it to authenticate with downstream services if needed.
|
|
119
|
+
*/
|
|
120
|
+
class SessionManager {
|
|
121
|
+
// ── Get Current User ────────────────────────────────────────────────────
|
|
122
|
+
/**
|
|
123
|
+
* Fetches the currently authenticated user from the server.
|
|
124
|
+
* Relies on the session cookie being present in the browser.
|
|
125
|
+
*
|
|
126
|
+
* Use this instead of decoding the JWT when you want the
|
|
127
|
+
* authoritative user object from your database.
|
|
128
|
+
*/
|
|
129
|
+
async getUser(baseUrl) {
|
|
130
|
+
return request(`${baseUrl}/me`, { method: "GET" });
|
|
131
|
+
}
|
|
132
|
+
// ── Verify Session ──────────────────────────────────────────────────────
|
|
133
|
+
/**
|
|
134
|
+
* Verifies that a session is still valid for a given email address.
|
|
135
|
+
* Useful for server-side checks or sensitive operations.
|
|
136
|
+
*/
|
|
137
|
+
async verifySession(baseUrl, email) {
|
|
138
|
+
await request(`${baseUrl}/auth/verify_session`, {
|
|
139
|
+
method: "POST",
|
|
140
|
+
body: JSON.stringify({ email }),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ─────────────────────────────────────────────
|
|
146
|
+
// Core User & Session Types
|
|
147
|
+
// ─────────────────────────────────────────────
|
|
148
|
+
// ─────────────────────────────────────────────
|
|
149
|
+
// MFA / Sign-In Status Codes
|
|
150
|
+
// Export these so developers can do comparisons
|
|
151
|
+
// ─────────────────────────────────────────────
|
|
152
|
+
const SignInStatus = {
|
|
153
|
+
/** Standard email+password sign-in succeeded — no MFA required */
|
|
154
|
+
SUCCESS: "SUCCESS",
|
|
155
|
+
/** Server requires the user to complete an Email MFA challenge */
|
|
156
|
+
MFA_REQUIRED: "MFA_REQUIRED",
|
|
157
|
+
/** Server requires the user to complete a TOTP challenge */
|
|
158
|
+
TOTP_REQUIRED: "TOTP_REQUIRED",
|
|
159
|
+
/** Server sent a magic link/code to the user's email */
|
|
160
|
+
MAGIC_LINK: "MAGIC_LINK",
|
|
161
|
+
/** Server sent a password-reset code to the user's email */
|
|
162
|
+
RESET_PASSWORD: "RESET_PASSWORD",
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Email + Password authentication methods.
|
|
167
|
+
*
|
|
168
|
+
* Sign-in has three possible outcomes depending on what the user has enabled:
|
|
169
|
+
*
|
|
170
|
+
* 1. Plain sign-in → status is undefined / SUCCESS (no MFA)
|
|
171
|
+
* 2. Email MFA → status === SignInStatus.MFA_REQUIRED
|
|
172
|
+
* 3. TOTP → status === SignInStatus.TOTP_REQUIRED
|
|
173
|
+
*
|
|
174
|
+
* In cases 2 & 3 the response includes a `mfa` session ID that you must
|
|
175
|
+
* pass to the corresponding verify method.
|
|
176
|
+
*
|
|
177
|
+
* Import `SignInStatus` to compare against the status value:
|
|
178
|
+
* import { SignInStatus } from "jobtrk-auth-sdk";
|
|
179
|
+
*/
|
|
180
|
+
class EmailPasswordAuth {
|
|
181
|
+
// ── Sign Up ─────────────────────────────────────────────────────────────
|
|
182
|
+
/**
|
|
183
|
+
* Creates a new account with an email address and password.
|
|
184
|
+
*/
|
|
185
|
+
async signUp(baseUrl, credentials) {
|
|
186
|
+
return request(`${baseUrl}/auth/email_password/signup`, {
|
|
187
|
+
method: "POST",
|
|
188
|
+
body: JSON.stringify({
|
|
189
|
+
email: credentials.email,
|
|
190
|
+
password: credentials.password,
|
|
191
|
+
userName: credentials.userName,
|
|
192
|
+
firstName: credentials.firstName,
|
|
193
|
+
lastName: credentials.lastName,
|
|
194
|
+
}),
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
// ── Sign In ─────────────────────────────────────────────────────────────
|
|
198
|
+
/**
|
|
199
|
+
* Signs in with email + password.
|
|
200
|
+
*
|
|
201
|
+
* Check `response.status` to determine the next step:
|
|
202
|
+
*
|
|
203
|
+
* ```ts
|
|
204
|
+
* const result = await auth.email.signIn({ email, password });
|
|
205
|
+
*
|
|
206
|
+
* if (result.status === SignInStatus.MFA_REQUIRED) {
|
|
207
|
+
* // prompt for email OTP, then call auth.email.verifyMfa()
|
|
208
|
+
* } else if (result.status === SignInStatus.TOTP_REQUIRED) {
|
|
209
|
+
* // prompt for TOTP code, then call auth.totp.verifySignIn()
|
|
210
|
+
* } else {
|
|
211
|
+
* // user is signed in — store result.access_token if using JWT mode
|
|
212
|
+
* }
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
async signIn(baseUrl, credentials) {
|
|
216
|
+
return request(`${baseUrl}/auth/email_password/signin`, {
|
|
217
|
+
method: "POST",
|
|
218
|
+
body: JSON.stringify({
|
|
219
|
+
email: credentials.email,
|
|
220
|
+
password: credentials.password,
|
|
221
|
+
}),
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
// ── Email MFA verify ────────────────────────────────────────────────────
|
|
225
|
+
/**
|
|
226
|
+
* Confirms the one-time code sent to the user's email after a sign-in
|
|
227
|
+
* that returned `status === SignInStatus.MFA_REQUIRED`.
|
|
228
|
+
*/
|
|
229
|
+
async verifyMfa(baseUrl, input) {
|
|
230
|
+
return request(`${baseUrl}/auth/email_mfa_signin`, {
|
|
231
|
+
method: "POST",
|
|
232
|
+
body: JSON.stringify({
|
|
233
|
+
sessionid: input.sessionId,
|
|
234
|
+
code: input.code,
|
|
235
|
+
}),
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
// ── Get username ────────────────────────────────────────────────────────
|
|
239
|
+
/**
|
|
240
|
+
* Looks up the username associated with an email address.
|
|
241
|
+
*/
|
|
242
|
+
async getUsername(baseUrl, email) {
|
|
243
|
+
return request(`${baseUrl}/auth/getusername`, {
|
|
244
|
+
method: "POST",
|
|
245
|
+
body: JSON.stringify({ email }),
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Email Magic Link authentication.
|
|
252
|
+
*
|
|
253
|
+
* Flow:
|
|
254
|
+
* 1. Call `send(email)` → server emails a one-time code to the user.
|
|
255
|
+
* 2. Response contains a `mfa` session ID.
|
|
256
|
+
* 3. User enters the code; call `verify({ sessionId, code })` to complete sign-in.
|
|
257
|
+
*/
|
|
258
|
+
class MagicLinkAuth {
|
|
259
|
+
/**
|
|
260
|
+
* Sends a magic-link code to the provided email address.
|
|
261
|
+
*
|
|
262
|
+
* @returns A session ID (`mfa` field) that you must pass to `verify()`.
|
|
263
|
+
*
|
|
264
|
+
* ```ts
|
|
265
|
+
* const { mfa: sessionId } = await auth.magicLink.send(email);
|
|
266
|
+
* // store sessionId, prompt user for code
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
async send(baseUrl, email) {
|
|
270
|
+
return request(`${baseUrl}/auth/email_magic_link`, {
|
|
271
|
+
method: "POST",
|
|
272
|
+
body: JSON.stringify({ email }),
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Verifies the code the user received and completes sign-in.
|
|
277
|
+
*/
|
|
278
|
+
async verify(baseUrl, input) {
|
|
279
|
+
return request(`${baseUrl}/auth/verify_magic_link`, {
|
|
280
|
+
method: "POST",
|
|
281
|
+
body: JSON.stringify({
|
|
282
|
+
sessionid: input.sessionId,
|
|
283
|
+
code: input.code,
|
|
284
|
+
}),
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* TOTP (Time-based One-Time Password) MFA management.
|
|
291
|
+
*
|
|
292
|
+
* Setup flow:
|
|
293
|
+
* 1. Call `setup()` → server returns a QR code / TOTP secret.
|
|
294
|
+
* 2. User scans with their authenticator app.
|
|
295
|
+
* 3. Call `confirmSetup(code)` with the first code to activate TOTP.
|
|
296
|
+
*
|
|
297
|
+
* Sign-in flow (when signIn returns `status === SignInStatus.TOTP_REQUIRED`):
|
|
298
|
+
* 1. Prompt user for their TOTP code.
|
|
299
|
+
* 2. Call `verifySignIn({ sessionId: data.mfa, code })` to complete sign-in.
|
|
300
|
+
*/
|
|
301
|
+
class TotpAuth {
|
|
302
|
+
/**
|
|
303
|
+
* Starts TOTP registration — returns the secret / QR code to display.
|
|
304
|
+
*/
|
|
305
|
+
async setup(baseUrl) {
|
|
306
|
+
return request(`${baseUrl}/auth/mfa/totp/start`, { method: "POST" });
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Confirms the TOTP setup by verifying the first code from the
|
|
310
|
+
* authenticator app.
|
|
311
|
+
*/
|
|
312
|
+
async confirmSetup(baseUrl, code) {
|
|
313
|
+
return request(`${baseUrl}/auth/mfa/totp/confirm`, {
|
|
314
|
+
method: "POST",
|
|
315
|
+
body: JSON.stringify({ code }),
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Completes a TOTP sign-in challenge.
|
|
320
|
+
* Use the `mfa` session ID returned by `emailPassword.signIn()` as `sessionId`.
|
|
321
|
+
*/
|
|
322
|
+
async verifySignIn(baseUrl, input) {
|
|
323
|
+
return request(`${baseUrl}/auth/mfa/totp/signin`, {
|
|
324
|
+
method: "POST",
|
|
325
|
+
body: JSON.stringify({
|
|
326
|
+
challenge_id: input.sessionId,
|
|
327
|
+
code: input.code,
|
|
328
|
+
}),
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Removes TOTP from the currently authenticated user's account.
|
|
333
|
+
*/
|
|
334
|
+
async delete(baseUrl) {
|
|
335
|
+
await request(`${baseUrl}/auth/mfa/totp/delete`, { method: "POST" });
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Password management methods.
|
|
341
|
+
*
|
|
342
|
+
* ── Reset password (authenticated user) ──────────────────────────────
|
|
343
|
+
* The user knows their current password and wants to change it.
|
|
344
|
+
* Call `reset({ oldPassword, newPassword })`.
|
|
345
|
+
*
|
|
346
|
+
* ── Forgot password (unauthenticated) ────────────────────────────────
|
|
347
|
+
* 1. Call `forgot(email)` → server emails a code and returns a session ID.
|
|
348
|
+
* 2. User enters the code from their email.
|
|
349
|
+
* 3. Call `confirmForgot({ sessionId, code, password })` to set the new password.
|
|
350
|
+
*/
|
|
351
|
+
class PasswordAuth {
|
|
352
|
+
/**
|
|
353
|
+
* Changes the password for an already authenticated user.
|
|
354
|
+
*/
|
|
355
|
+
async reset(baseUrl, input) {
|
|
356
|
+
return request(`${baseUrl}/auth/password/reset`, {
|
|
357
|
+
method: "POST",
|
|
358
|
+
body: JSON.stringify({
|
|
359
|
+
oldPassword: input.oldPassword,
|
|
360
|
+
newPassword: input.newPassword,
|
|
361
|
+
}),
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Initiates the forgot-password flow by sending a reset code to the
|
|
366
|
+
* user's email address.
|
|
367
|
+
*
|
|
368
|
+
* @returns A session ID (`mfa` field) required by `confirmForgot()`.
|
|
369
|
+
*
|
|
370
|
+
* ```ts
|
|
371
|
+
* const { mfa: sessionId } = await auth.password.forgot(email);
|
|
372
|
+
* // prompt user for code
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
async forgot(baseUrl, email) {
|
|
376
|
+
return request(`${baseUrl}/auth/password/forgot`, {
|
|
377
|
+
method: "POST",
|
|
378
|
+
body: JSON.stringify({ email }),
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Completes the forgot-password flow by verifying the emailed code
|
|
383
|
+
* and setting the new password.
|
|
384
|
+
*/
|
|
385
|
+
async confirmForgot(baseUrl, input) {
|
|
386
|
+
return request(`${baseUrl}/auth/password/forgot/confirm`, {
|
|
387
|
+
method: "POST",
|
|
388
|
+
body: JSON.stringify({
|
|
389
|
+
sessionID: input.sessionId,
|
|
390
|
+
code: input.code,
|
|
391
|
+
password: input.password,
|
|
392
|
+
}),
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Multi-tenant SSO (Single Sign-On) methods.
|
|
399
|
+
*
|
|
400
|
+
* Two roles exist:
|
|
401
|
+
*
|
|
402
|
+
* Organization Admin → registers their company IDP via `registerProvider()`.
|
|
403
|
+
* End User → signs in through their company's IDP via `signIn()`.
|
|
404
|
+
*
|
|
405
|
+
* Sign-in flow:
|
|
406
|
+
* 1. Call `signIn(email)` → server resolves the org and returns a redirect URL.
|
|
407
|
+
* 2. Redirect the user to `auth_url` to complete sign-in with their IDP.
|
|
408
|
+
*
|
|
409
|
+
* ```ts
|
|
410
|
+
* const { auth_url } = await auth.sso.signIn(email);
|
|
411
|
+
* window.location.href = auth_url;
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
class SsoAuth {
|
|
415
|
+
/**
|
|
416
|
+
* Registers an organisation's Identity Provider (IDP) with the auth system.
|
|
417
|
+
* This is typically called once by an organisation admin during onboarding.
|
|
418
|
+
*/
|
|
419
|
+
async registerProvider(baseUrl, input) {
|
|
420
|
+
return request(`${baseUrl}/sso/providers/register`, {
|
|
421
|
+
method: "POST",
|
|
422
|
+
body: JSON.stringify({
|
|
423
|
+
provider_name: input.providerName,
|
|
424
|
+
provider_end_email: input.providerEndEmail,
|
|
425
|
+
client_id: input.clientId,
|
|
426
|
+
client_secret: input.clientSecret,
|
|
427
|
+
issuer: input.issuer,
|
|
428
|
+
callback_url: input.callbackUrl,
|
|
429
|
+
}),
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Starts the SSO sign-in flow for an end user.
|
|
434
|
+
*
|
|
435
|
+
* The server resolves the correct IDP from the user's email domain
|
|
436
|
+
* and returns a redirect URL. Redirect the user to that URL to
|
|
437
|
+
* complete sign-in with their organisation's IDP.
|
|
438
|
+
*/
|
|
439
|
+
async signIn(baseUrl, email) {
|
|
440
|
+
return request(`${baseUrl}/sso/start`, {
|
|
441
|
+
method: "POST",
|
|
442
|
+
body: JSON.stringify({ email }),
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Email MFA management.
|
|
449
|
+
*
|
|
450
|
+
* These methods manage whether a user has Email MFA enabled on their account.
|
|
451
|
+
* They are separate from the sign-in verify step (see EmailPasswordAuth.verifyMfa).
|
|
452
|
+
*/
|
|
453
|
+
class EmailMfaManager {
|
|
454
|
+
/**
|
|
455
|
+
* Enables Email MFA for the currently authenticated user.
|
|
456
|
+
* Once enabled, future sign-ins will require a one-time code sent to email.
|
|
457
|
+
*/
|
|
458
|
+
async create(baseUrl) {
|
|
459
|
+
await request(`${baseUrl}/auth/mfa/email/create`, { method: "POST" });
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Disables Email MFA for the currently authenticated user.
|
|
463
|
+
*/
|
|
464
|
+
async delete(baseUrl) {
|
|
465
|
+
await request(`${baseUrl}/auth/mfa/email/delete`, { method: "POST" });
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Social / OAuth provider sign-in methods.
|
|
471
|
+
*
|
|
472
|
+
* Each method redirects the browser to the provider's OAuth flow.
|
|
473
|
+
* After successful authentication the server will redirect back to
|
|
474
|
+
* your application with a session cookie (or access token, depending
|
|
475
|
+
* on your server configuration).
|
|
476
|
+
*
|
|
477
|
+
* These are simple redirects — no async call is needed.
|
|
478
|
+
*/
|
|
479
|
+
class SocialAuth {
|
|
480
|
+
constructor(baseUrl) {
|
|
481
|
+
this.baseUrl = baseUrl;
|
|
482
|
+
}
|
|
483
|
+
/** Redirects to Google OAuth sign-in. */
|
|
484
|
+
signInWithGoogle() {
|
|
485
|
+
window.location.href = `${this.baseUrl}/auth/google`;
|
|
486
|
+
}
|
|
487
|
+
/** Redirects to GitHub OAuth sign-in. */
|
|
488
|
+
signInWithGithub() {
|
|
489
|
+
window.location.href = `${this.baseUrl}/auth/github`;
|
|
490
|
+
}
|
|
491
|
+
/** Redirects to LinkedIn OAuth sign-in. */
|
|
492
|
+
signInWithLinkedIn() {
|
|
493
|
+
window.location.href = `${this.baseUrl}/auth/linkedin`;
|
|
494
|
+
}
|
|
495
|
+
/** Redirects to Okta OAuth sign-in. */
|
|
496
|
+
signInWithOkta() {
|
|
497
|
+
window.location.href = `${this.baseUrl}/auth/okta`;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* AuthClient
|
|
503
|
+
*
|
|
504
|
+
* The single entry point for the JobTrk auth SDK.
|
|
505
|
+
* Framework-agnostic — works in React, Vue, Svelte, vanilla JS, etc.
|
|
506
|
+
*
|
|
507
|
+
* ── Quick start ──────────────────────────────────────────────────────
|
|
508
|
+
*
|
|
509
|
+
* ```ts
|
|
510
|
+
* import { AuthClient, SignInStatus } from "jobtrk-auth-sdk";
|
|
511
|
+
*
|
|
512
|
+
* const auth = new AuthClient({ baseUrl: "https://auth.yourapp.com" });
|
|
513
|
+
*
|
|
514
|
+
* // Restore session on app startup
|
|
515
|
+
* const user = await auth.token.refresh();
|
|
516
|
+
*
|
|
517
|
+
* // Social sign-in
|
|
518
|
+
* auth.social.signInWithGoogle();
|
|
519
|
+
*
|
|
520
|
+
* // Email + password sign-in (with MFA branching)
|
|
521
|
+
* const result = await auth.email.signIn({ email, password });
|
|
522
|
+
* if (result.status === SignInStatus.MFA_REQUIRED) { ... }
|
|
523
|
+
* if (result.status === SignInStatus.TOTP_REQUIRED) { ... }
|
|
524
|
+
*
|
|
525
|
+
* // Magic link
|
|
526
|
+
* const { mfa: sessionId } = await auth.magicLink.send(email);
|
|
527
|
+
* await auth.magicLink.verify({ sessionId, code });
|
|
528
|
+
*
|
|
529
|
+
* // SSO
|
|
530
|
+
* const { auth_url } = await auth.sso.signIn(email);
|
|
531
|
+
* window.location.href = auth_url;
|
|
532
|
+
* ```
|
|
533
|
+
*/
|
|
534
|
+
class AuthClient {
|
|
535
|
+
constructor(config = {}) {
|
|
536
|
+
this.baseUrl = config.baseUrl ?? "https://auth.jobtrk.com";
|
|
537
|
+
this.token = new TokenManager();
|
|
538
|
+
this.session = new SessionManager();
|
|
539
|
+
this.social = new SocialAuth(this.baseUrl);
|
|
540
|
+
this.email = new EmailPasswordAuth();
|
|
541
|
+
this.magicLink = new MagicLinkAuth();
|
|
542
|
+
this.totp = new TotpAuth();
|
|
543
|
+
this.emailMfa = new EmailMfaManager();
|
|
544
|
+
this.password = new PasswordAuth();
|
|
545
|
+
this.sso = new SsoAuth();
|
|
546
|
+
}
|
|
547
|
+
// ── Logout helpers ───────────────────────────────────────────────────────
|
|
548
|
+
/**
|
|
549
|
+
* Signs the user out of the current session/device.
|
|
550
|
+
* Clears the in-memory access token after a successful server response.
|
|
551
|
+
*/
|
|
552
|
+
async logout() {
|
|
553
|
+
await request(`${this.baseUrl}/auth/logout`, { method: "POST" });
|
|
554
|
+
this.token.clearAccessToken();
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Signs the user out of ALL active sessions / devices.
|
|
558
|
+
* Clears the in-memory access token after a successful server response.
|
|
559
|
+
*/
|
|
560
|
+
async logoutAllSessions() {
|
|
561
|
+
await request(`${this.baseUrl}/auth/logoutsessions`, { method: "POST" });
|
|
562
|
+
this.token.clearAccessToken();
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
function bindBaseUrl(module, baseUrl) {
|
|
566
|
+
return new Proxy(module, {
|
|
567
|
+
get(target, prop) {
|
|
568
|
+
const value = target[prop];
|
|
569
|
+
if (typeof value === "function") {
|
|
570
|
+
return (...args) => value.call(target, baseUrl, ...args);
|
|
571
|
+
}
|
|
572
|
+
return value;
|
|
573
|
+
},
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Creates an `AuthClient` where all sub-module methods have the `baseUrl`
|
|
578
|
+
* argument pre-bound. This is the recommended way to instantiate the SDK.
|
|
579
|
+
*
|
|
580
|
+
* ```ts
|
|
581
|
+
* const auth = createAuthClient({ baseUrl: "https://auth.yourapp.com" });
|
|
582
|
+
*
|
|
583
|
+
* // No need to pass baseUrl to individual methods:
|
|
584
|
+
* await auth.email.signIn({ email, password });
|
|
585
|
+
* await auth.token.refresh();
|
|
586
|
+
* ```
|
|
587
|
+
*/
|
|
588
|
+
function createAuthClient(config = {}) {
|
|
589
|
+
const baseUrl = config.baseUrl ?? "";
|
|
590
|
+
const client = new AuthClient(config);
|
|
591
|
+
return {
|
|
592
|
+
...client,
|
|
593
|
+
token: bindBaseUrl(client.token, baseUrl),
|
|
594
|
+
session: bindBaseUrl(client.session, baseUrl),
|
|
595
|
+
email: bindBaseUrl(client.email, baseUrl),
|
|
596
|
+
magicLink: bindBaseUrl(client.magicLink, baseUrl),
|
|
597
|
+
totp: bindBaseUrl(client.totp, baseUrl),
|
|
598
|
+
emailMfa: bindBaseUrl(client.emailMfa, baseUrl),
|
|
599
|
+
password: bindBaseUrl(client.password, baseUrl),
|
|
600
|
+
sso: bindBaseUrl(client.sso, baseUrl),
|
|
601
|
+
social: client.social, // already has baseUrl from constructor
|
|
602
|
+
logout: () => client.logout(),
|
|
603
|
+
logoutAllSessions: () => client.logoutAllSessions(),
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
exports.AuthClient = AuthClient;
|
|
608
|
+
exports.AuthError = AuthError;
|
|
609
|
+
exports.SignInStatus = SignInStatus;
|
|
610
|
+
exports.createAuthClient = createAuthClient;
|
|
611
|
+
|
|
612
|
+
}));
|
|
613
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/http.ts","../src/methods/token.ts","../src/methods/session.ts","../src/types/index.ts","../src/methods/emailPassword.ts","../src/methods/magicLink.ts","../src/methods/totp.ts","../src/methods/password.ts","../src/methods/sso.ts","../src/methods/emailMfa.ts","../src/providers/social.ts","../src/client.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null],"names":[],"mappings":";;;;;;IAAA;;;IAGG;IACI,eAAe,OAAO,CAC3B,GAAW,EACX,UAAuB,EAAE,EAAA;IAEzB,IAAA,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;IAChC,QAAA,GAAG,OAAO;YACV,WAAW,EAAE,SAAS;IACtB,QAAA,OAAO,EAAE;IACP,YAAA,cAAc,EAAE,kBAAkB;gBAClC,GAAG,OAAO,CAAC,OAAO;IACnB,SAAA;IACF,KAAA,CAAC;IAEF,IAAA,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC;IAEpD,IAAA,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;IAChB,QAAA,MAAM,OAAO,GACV,IAA6B,EAAE,OAAO;IACvC,YAAA,CAAA,2BAAA,EAA8B,QAAQ,CAAC,MAAM,CAAA,CAAE;YACjD,MAAM,IAAI,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;QACrD;IAEA,IAAA,OAAO,IAAS;IAClB;IAEA;IACA;IACA;IAEM,MAAO,SAAU,SAAQ,KAAK,CAAA;IAClC,IAAA,WAAA,CACE,OAAe,EACC,MAAc,EACd,OAAgB,IAAI,EAAA;YAEpC,KAAK,CAAC,OAAO,CAAC;YAHE,IAAA,CAAA,MAAM,GAAN,MAAM;YACN,IAAA,CAAA,IAAI,GAAJ,IAAI;IAGpB,QAAA,IAAI,CAAC,IAAI,GAAG,WAAW;QACzB;IACD;;ICnCD;;;;;;IAMG;UACU,YAAY,CAAA;IAAzB,IAAA,WAAA,GAAA;YACU,IAAA,CAAA,WAAW,GAAkB,IAAI;QAqE3C;;QAjEE,cAAc,GAAA;YACZ,OAAO,IAAI,CAAC,WAAW;QACzB;IAEA,IAAA,cAAc,CAA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