nexabase-console 2.0.3 → 2.0.4
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/app/NexaApp.js +1 -1
- package/dist/auth/Auth.js +29 -28
- package/dist/transport/HttpClient.d.ts +3 -1
- package/dist/transport/HttpClient.js +12 -2
- package/package.json +1 -1
package/dist/app/NexaApp.js
CHANGED
|
@@ -29,7 +29,7 @@ class NexaApp {
|
|
|
29
29
|
}
|
|
30
30
|
this.endpoint = config.endpoint || defaultEndpoint;
|
|
31
31
|
// Transport
|
|
32
|
-
this.httpClient = new HttpClient_1.HttpClient(this.endpoint, () => this.authService ? this.authService.getToken() : this.token);
|
|
32
|
+
this.httpClient = new HttpClient_1.HttpClient(this.endpoint, () => (this.authService ? this.authService.getToken() : this.token), this.projectId, this.token);
|
|
33
33
|
this.client = this.httpClient.getAxiosInstance();
|
|
34
34
|
this.sseClient = new SSEClient_1.SSEClient(this.projectId, this.endpoint);
|
|
35
35
|
// Auth & Persistence
|
package/dist/auth/Auth.js
CHANGED
|
@@ -165,9 +165,9 @@ class Auth {
|
|
|
165
165
|
return this.refreshPromise;
|
|
166
166
|
}
|
|
167
167
|
async refreshAccessToken(refreshToken) {
|
|
168
|
-
const endpoint = this.emulatorUrl || `/api/
|
|
168
|
+
const endpoint = this.emulatorUrl || `/api/auth/token/refresh`;
|
|
169
169
|
try {
|
|
170
|
-
const res = await this.client.post(endpoint, { refreshToken });
|
|
170
|
+
const res = await this.client.post(endpoint, { refreshToken, projectId: this.projectId });
|
|
171
171
|
const session = res.data;
|
|
172
172
|
this.currentSession = session;
|
|
173
173
|
await this.persistence.saveSession(session);
|
|
@@ -203,8 +203,8 @@ class Auth {
|
|
|
203
203
|
// --- Email & Password Auth ---
|
|
204
204
|
async createUserWithEmailAndPassword(email, password, name) {
|
|
205
205
|
try {
|
|
206
|
-
const endpoint = this.emulatorUrl || `/api/
|
|
207
|
-
const res = await this.client.post(endpoint, { email, password, name });
|
|
206
|
+
const endpoint = this.emulatorUrl || `/api/auth/register`;
|
|
207
|
+
const res = await this.client.post(endpoint, { email, password, name, projectId: this.projectId });
|
|
208
208
|
const session = res.data;
|
|
209
209
|
this.currentSession = session;
|
|
210
210
|
await this.persistence.saveSession(session);
|
|
@@ -218,8 +218,8 @@ class Auth {
|
|
|
218
218
|
}
|
|
219
219
|
async signInWithEmailAndPassword(email, password) {
|
|
220
220
|
try {
|
|
221
|
-
const endpoint = this.emulatorUrl || `/api/
|
|
222
|
-
const res = await this.client.post(endpoint, { email, password });
|
|
221
|
+
const endpoint = this.emulatorUrl || `/api/auth/login`;
|
|
222
|
+
const res = await this.client.post(endpoint, { email, password, projectId: this.projectId });
|
|
223
223
|
const session = res.data;
|
|
224
224
|
this.currentSession = session;
|
|
225
225
|
await this.persistence.saveSession(session);
|
|
@@ -234,8 +234,8 @@ class Auth {
|
|
|
234
234
|
// --- OTP Auth ---
|
|
235
235
|
async sendOtp(email) {
|
|
236
236
|
try {
|
|
237
|
-
const endpoint = this.emulatorUrl || `/api/
|
|
238
|
-
const res = await this.client.post(endpoint, { email });
|
|
237
|
+
const endpoint = this.emulatorUrl || `/api/auth/otp/send`;
|
|
238
|
+
const res = await this.client.post(endpoint, { email, projectId: this.projectId });
|
|
239
239
|
return res.data;
|
|
240
240
|
}
|
|
241
241
|
catch (err) {
|
|
@@ -244,8 +244,8 @@ class Auth {
|
|
|
244
244
|
}
|
|
245
245
|
async signInWithOtp(email, otp) {
|
|
246
246
|
try {
|
|
247
|
-
const endpoint = this.emulatorUrl || `/api/
|
|
248
|
-
const res = await this.client.post(endpoint, { email, otp });
|
|
247
|
+
const endpoint = this.emulatorUrl || `/api/auth/otp/login`;
|
|
248
|
+
const res = await this.client.post(endpoint, { email, otp, projectId: this.projectId });
|
|
249
249
|
const session = res.data;
|
|
250
250
|
this.currentSession = session;
|
|
251
251
|
await this.persistence.saveSession(session);
|
|
@@ -260,8 +260,8 @@ class Auth {
|
|
|
260
260
|
// --- Password Reset & Verification ---
|
|
261
261
|
async sendPasswordResetEmail(email) {
|
|
262
262
|
try {
|
|
263
|
-
const endpoint = this.emulatorUrl || `/api/
|
|
264
|
-
const res = await this.client.post(endpoint, { email });
|
|
263
|
+
const endpoint = this.emulatorUrl || `/api/auth/password-reset/send`;
|
|
264
|
+
const res = await this.client.post(endpoint, { email, projectId: this.projectId });
|
|
265
265
|
return res.data;
|
|
266
266
|
}
|
|
267
267
|
catch (err) {
|
|
@@ -270,8 +270,8 @@ class Auth {
|
|
|
270
270
|
}
|
|
271
271
|
async confirmPasswordReset(code, newPassword) {
|
|
272
272
|
try {
|
|
273
|
-
const endpoint = this.emulatorUrl || `/api/
|
|
274
|
-
const res = await this.client.post(endpoint, { code, newPassword });
|
|
273
|
+
const endpoint = this.emulatorUrl || `/api/auth/password-reset/confirm`;
|
|
274
|
+
const res = await this.client.post(endpoint, { code, newPassword, projectId: this.projectId });
|
|
275
275
|
return res.data;
|
|
276
276
|
}
|
|
277
277
|
catch (err) {
|
|
@@ -281,8 +281,8 @@ class Auth {
|
|
|
281
281
|
async sendEmailVerification() {
|
|
282
282
|
const token = await this.getIdToken();
|
|
283
283
|
try {
|
|
284
|
-
const endpoint = this.emulatorUrl || `/api/
|
|
285
|
-
const res = await this.client.post(endpoint, {}, {
|
|
284
|
+
const endpoint = this.emulatorUrl || `/api/auth/email/send-verification`;
|
|
285
|
+
const res = await this.client.post(endpoint, { projectId: this.projectId }, {
|
|
286
286
|
headers: { Authorization: `Bearer ${token}` }
|
|
287
287
|
});
|
|
288
288
|
return res.data;
|
|
@@ -295,8 +295,8 @@ class Auth {
|
|
|
295
295
|
async updateProfile(update) {
|
|
296
296
|
const token = await this.getIdToken();
|
|
297
297
|
try {
|
|
298
|
-
const endpoint = this.emulatorUrl || `/api/
|
|
299
|
-
const res = await this.client.patch(endpoint, update, {
|
|
298
|
+
const endpoint = this.emulatorUrl || `/api/auth/profile`;
|
|
299
|
+
const res = await this.client.patch(endpoint, { ...update, projectId: this.projectId }, {
|
|
300
300
|
headers: { Authorization: `Bearer ${token}` }
|
|
301
301
|
});
|
|
302
302
|
const updatedUser = res.data;
|
|
@@ -314,8 +314,8 @@ class Auth {
|
|
|
314
314
|
async updatePassword(newPassword) {
|
|
315
315
|
const token = await this.getIdToken();
|
|
316
316
|
try {
|
|
317
|
-
const endpoint = this.emulatorUrl || `/api/
|
|
318
|
-
await this.client.post(endpoint, { newPassword }, {
|
|
317
|
+
const endpoint = this.emulatorUrl || `/api/auth/password/update`;
|
|
318
|
+
await this.client.post(endpoint, { newPassword, projectId: this.projectId }, {
|
|
319
319
|
headers: { Authorization: `Bearer ${token}` }
|
|
320
320
|
});
|
|
321
321
|
}
|
|
@@ -326,9 +326,10 @@ class Auth {
|
|
|
326
326
|
async deleteUser() {
|
|
327
327
|
const token = await this.getIdToken();
|
|
328
328
|
try {
|
|
329
|
-
const endpoint = this.emulatorUrl || `/api/
|
|
329
|
+
const endpoint = this.emulatorUrl || `/api/auth/user/delete`;
|
|
330
330
|
await this.client.delete(endpoint, {
|
|
331
|
-
headers: { Authorization: `Bearer ${token}` }
|
|
331
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
332
|
+
data: { projectId: this.projectId }
|
|
332
333
|
});
|
|
333
334
|
await this.signOut();
|
|
334
335
|
}
|
|
@@ -340,8 +341,8 @@ class Auth {
|
|
|
340
341
|
async revokeSession(sessionId) {
|
|
341
342
|
const token = await this.getIdToken();
|
|
342
343
|
try {
|
|
343
|
-
const endpoint = this.emulatorUrl || `/api/
|
|
344
|
-
await this.client.post(endpoint, { sessionId }, {
|
|
344
|
+
const endpoint = this.emulatorUrl || `/api/auth/session/revoke`;
|
|
345
|
+
await this.client.post(endpoint, { sessionId, projectId: this.projectId }, {
|
|
345
346
|
headers: { Authorization: `Bearer ${token}` }
|
|
346
347
|
});
|
|
347
348
|
}
|
|
@@ -352,8 +353,8 @@ class Auth {
|
|
|
352
353
|
async revokeAllSessions() {
|
|
353
354
|
const token = await this.getIdToken();
|
|
354
355
|
try {
|
|
355
|
-
const endpoint = this.emulatorUrl || `/api/
|
|
356
|
-
await this.client.post(endpoint, {}, {
|
|
356
|
+
const endpoint = this.emulatorUrl || `/api/auth/session/revoke-all`;
|
|
357
|
+
await this.client.post(endpoint, { projectId: this.projectId }, {
|
|
357
358
|
headers: { Authorization: `Bearer ${token}` }
|
|
358
359
|
});
|
|
359
360
|
await this.signOut();
|
|
@@ -368,8 +369,8 @@ class Auth {
|
|
|
368
369
|
this.currentSession = null;
|
|
369
370
|
if (oldSession) {
|
|
370
371
|
try {
|
|
371
|
-
const endpoint = this.emulatorUrl || `/api/
|
|
372
|
-
await this.client.post(endpoint, { refreshToken: oldSession.refreshToken });
|
|
372
|
+
const endpoint = this.emulatorUrl || `/api/auth/logout`;
|
|
373
|
+
await this.client.post(endpoint, { refreshToken: oldSession.refreshToken, projectId: this.projectId });
|
|
373
374
|
}
|
|
374
375
|
catch {
|
|
375
376
|
// Non-blocking logout network failure
|
|
@@ -2,7 +2,9 @@ import { AxiosInstance } from 'axios';
|
|
|
2
2
|
export declare class HttpClient {
|
|
3
3
|
private client;
|
|
4
4
|
private getToken;
|
|
5
|
-
|
|
5
|
+
private projectId?;
|
|
6
|
+
private apiKey?;
|
|
7
|
+
constructor(endpoint: string, getTokenFn: () => string | null, projectId?: string, apiKey?: string | null);
|
|
6
8
|
getAxiosInstance(): AxiosInstance;
|
|
7
9
|
setBaseURL(url: string): void;
|
|
8
10
|
}
|
|
@@ -6,18 +6,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.HttpClient = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
class HttpClient {
|
|
9
|
-
constructor(endpoint, getTokenFn) {
|
|
9
|
+
constructor(endpoint, getTokenFn, projectId, apiKey) {
|
|
10
10
|
this.getToken = getTokenFn;
|
|
11
|
+
this.projectId = projectId;
|
|
12
|
+
this.apiKey = apiKey;
|
|
11
13
|
this.client = axios_1.default.create({
|
|
12
14
|
baseURL: endpoint,
|
|
13
|
-
timeout:
|
|
15
|
+
timeout: 10000
|
|
14
16
|
});
|
|
15
17
|
this.client.interceptors.request.use((req) => {
|
|
16
18
|
const activeToken = this.getToken();
|
|
17
19
|
if (activeToken) {
|
|
18
20
|
req.headers.Authorization = `Bearer ${activeToken}`;
|
|
21
|
+
}
|
|
22
|
+
if (this.apiKey) {
|
|
23
|
+
req.headers['x-api-key'] = this.apiKey;
|
|
24
|
+
}
|
|
25
|
+
else if (activeToken) {
|
|
19
26
|
req.headers['x-api-key'] = activeToken;
|
|
20
27
|
}
|
|
28
|
+
if (this.projectId) {
|
|
29
|
+
req.headers['x-project-id'] = this.projectId;
|
|
30
|
+
}
|
|
21
31
|
if (typeof FormData !== 'undefined' && req.data instanceof FormData) {
|
|
22
32
|
if (req.headers) {
|
|
23
33
|
delete req.headers['Content-Type'];
|
package/package.json
CHANGED