@insforge/sdk 0.0.9 → 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/index.d.mts +33 -6
- package/dist/index.d.ts +33 -6
- package/dist/index.js +217 -179
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +217 -179
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UserSchema, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse,
|
|
1
|
+
import { UserSchema, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, StorageFileSchema, ListObjectsResponseSchema } from '@insforge/shared-schemas';
|
|
2
2
|
export { AuthErrorResponse, CreateSessionRequest, CreateUserRequest, UserSchema } from '@insforge/shared-schemas';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -100,6 +100,7 @@ declare class TokenManager {
|
|
|
100
100
|
declare class Auth {
|
|
101
101
|
private http;
|
|
102
102
|
private tokenManager;
|
|
103
|
+
private database;
|
|
103
104
|
constructor(http: HttpClient, tokenManager: TokenManager);
|
|
104
105
|
/**
|
|
105
106
|
* Sign up a new user
|
|
@@ -136,22 +137,48 @@ declare class Auth {
|
|
|
136
137
|
error: InsForgeError | null;
|
|
137
138
|
}>;
|
|
138
139
|
/**
|
|
139
|
-
* Get the current user
|
|
140
|
-
* Returns
|
|
140
|
+
* Get the current user with full profile information
|
|
141
|
+
* Returns both auth info (id, email, role) and profile data (nickname, avatar_url, bio, etc.)
|
|
141
142
|
*/
|
|
142
143
|
getCurrentUser(): Promise<{
|
|
143
|
-
data:
|
|
144
|
+
data: {
|
|
145
|
+
user: any;
|
|
146
|
+
profile: any;
|
|
147
|
+
} | null;
|
|
148
|
+
error: InsForgeError | null;
|
|
149
|
+
}>;
|
|
150
|
+
/**
|
|
151
|
+
* Get any user's profile by ID
|
|
152
|
+
* Returns profile information from the users table (nickname, avatar_url, bio, etc.)
|
|
153
|
+
*/
|
|
154
|
+
getProfile(userId: string): Promise<{
|
|
155
|
+
data: any | null;
|
|
144
156
|
error: InsForgeError | null;
|
|
145
157
|
}>;
|
|
146
158
|
/**
|
|
147
|
-
* Get the
|
|
159
|
+
* Get the current session (only session data, no API call)
|
|
160
|
+
* Returns the stored JWT token and basic user info from local storage
|
|
148
161
|
*/
|
|
149
|
-
|
|
162
|
+
getCurrentSession(): Promise<{
|
|
150
163
|
data: {
|
|
151
164
|
session: AuthSession | null;
|
|
152
165
|
};
|
|
153
166
|
error: InsForgeError | null;
|
|
154
167
|
}>;
|
|
168
|
+
/**
|
|
169
|
+
* Set/Update the current user's profile
|
|
170
|
+
* Updates profile information in the users table (nickname, avatar_url, bio, etc.)
|
|
171
|
+
*/
|
|
172
|
+
setProfile(profile: {
|
|
173
|
+
nickname?: string;
|
|
174
|
+
avatar_url?: string;
|
|
175
|
+
bio?: string;
|
|
176
|
+
birthday?: string;
|
|
177
|
+
[key: string]: any;
|
|
178
|
+
}): Promise<{
|
|
179
|
+
data: any | null;
|
|
180
|
+
error: InsForgeError | null;
|
|
181
|
+
}>;
|
|
155
182
|
}
|
|
156
183
|
|
|
157
184
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UserSchema, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse,
|
|
1
|
+
import { UserSchema, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, StorageFileSchema, ListObjectsResponseSchema } from '@insforge/shared-schemas';
|
|
2
2
|
export { AuthErrorResponse, CreateSessionRequest, CreateUserRequest, UserSchema } from '@insforge/shared-schemas';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -100,6 +100,7 @@ declare class TokenManager {
|
|
|
100
100
|
declare class Auth {
|
|
101
101
|
private http;
|
|
102
102
|
private tokenManager;
|
|
103
|
+
private database;
|
|
103
104
|
constructor(http: HttpClient, tokenManager: TokenManager);
|
|
104
105
|
/**
|
|
105
106
|
* Sign up a new user
|
|
@@ -136,22 +137,48 @@ declare class Auth {
|
|
|
136
137
|
error: InsForgeError | null;
|
|
137
138
|
}>;
|
|
138
139
|
/**
|
|
139
|
-
* Get the current user
|
|
140
|
-
* Returns
|
|
140
|
+
* Get the current user with full profile information
|
|
141
|
+
* Returns both auth info (id, email, role) and profile data (nickname, avatar_url, bio, etc.)
|
|
141
142
|
*/
|
|
142
143
|
getCurrentUser(): Promise<{
|
|
143
|
-
data:
|
|
144
|
+
data: {
|
|
145
|
+
user: any;
|
|
146
|
+
profile: any;
|
|
147
|
+
} | null;
|
|
148
|
+
error: InsForgeError | null;
|
|
149
|
+
}>;
|
|
150
|
+
/**
|
|
151
|
+
* Get any user's profile by ID
|
|
152
|
+
* Returns profile information from the users table (nickname, avatar_url, bio, etc.)
|
|
153
|
+
*/
|
|
154
|
+
getProfile(userId: string): Promise<{
|
|
155
|
+
data: any | null;
|
|
144
156
|
error: InsForgeError | null;
|
|
145
157
|
}>;
|
|
146
158
|
/**
|
|
147
|
-
* Get the
|
|
159
|
+
* Get the current session (only session data, no API call)
|
|
160
|
+
* Returns the stored JWT token and basic user info from local storage
|
|
148
161
|
*/
|
|
149
|
-
|
|
162
|
+
getCurrentSession(): Promise<{
|
|
150
163
|
data: {
|
|
151
164
|
session: AuthSession | null;
|
|
152
165
|
};
|
|
153
166
|
error: InsForgeError | null;
|
|
154
167
|
}>;
|
|
168
|
+
/**
|
|
169
|
+
* Set/Update the current user's profile
|
|
170
|
+
* Updates profile information in the users table (nickname, avatar_url, bio, etc.)
|
|
171
|
+
*/
|
|
172
|
+
setProfile(profile: {
|
|
173
|
+
nickname?: string;
|
|
174
|
+
avatar_url?: string;
|
|
175
|
+
bio?: string;
|
|
176
|
+
birthday?: string;
|
|
177
|
+
[key: string]: any;
|
|
178
|
+
}): Promise<{
|
|
179
|
+
data: any | null;
|
|
180
|
+
error: InsForgeError | null;
|
|
181
|
+
}>;
|
|
155
182
|
}
|
|
156
183
|
|
|
157
184
|
/**
|
package/dist/index.js
CHANGED
|
@@ -202,185 +202,6 @@ var TokenManager = class {
|
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
204
|
|
|
205
|
-
// src/modules/auth.ts
|
|
206
|
-
var Auth = class {
|
|
207
|
-
constructor(http, tokenManager) {
|
|
208
|
-
this.http = http;
|
|
209
|
-
this.tokenManager = tokenManager;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Sign up a new user
|
|
213
|
-
*/
|
|
214
|
-
async signUp(request) {
|
|
215
|
-
try {
|
|
216
|
-
const response = await this.http.post("/api/auth/users", request);
|
|
217
|
-
const session = {
|
|
218
|
-
accessToken: response.accessToken,
|
|
219
|
-
user: response.user
|
|
220
|
-
};
|
|
221
|
-
this.tokenManager.saveSession(session);
|
|
222
|
-
this.http.setAuthToken(response.accessToken);
|
|
223
|
-
return {
|
|
224
|
-
data: response,
|
|
225
|
-
error: null
|
|
226
|
-
};
|
|
227
|
-
} catch (error) {
|
|
228
|
-
if (error instanceof InsForgeError) {
|
|
229
|
-
return { data: null, error };
|
|
230
|
-
}
|
|
231
|
-
return {
|
|
232
|
-
data: null,
|
|
233
|
-
error: new InsForgeError(
|
|
234
|
-
error instanceof Error ? error.message : "An unexpected error occurred during sign up",
|
|
235
|
-
500,
|
|
236
|
-
"UNEXPECTED_ERROR"
|
|
237
|
-
)
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Sign in with email and password
|
|
243
|
-
*/
|
|
244
|
-
async signInWithPassword(request) {
|
|
245
|
-
try {
|
|
246
|
-
const response = await this.http.post("/api/auth/sessions", request);
|
|
247
|
-
const session = {
|
|
248
|
-
accessToken: response.accessToken,
|
|
249
|
-
user: response.user
|
|
250
|
-
};
|
|
251
|
-
this.tokenManager.saveSession(session);
|
|
252
|
-
this.http.setAuthToken(response.accessToken);
|
|
253
|
-
return {
|
|
254
|
-
data: response,
|
|
255
|
-
error: null
|
|
256
|
-
};
|
|
257
|
-
} catch (error) {
|
|
258
|
-
if (error instanceof InsForgeError) {
|
|
259
|
-
return { data: null, error };
|
|
260
|
-
}
|
|
261
|
-
return {
|
|
262
|
-
data: null,
|
|
263
|
-
error: new InsForgeError(
|
|
264
|
-
"An unexpected error occurred during sign in",
|
|
265
|
-
500,
|
|
266
|
-
"UNEXPECTED_ERROR"
|
|
267
|
-
)
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Sign in with OAuth provider
|
|
273
|
-
*/
|
|
274
|
-
async signInWithOAuth(options) {
|
|
275
|
-
try {
|
|
276
|
-
const { provider, redirectTo, skipBrowserRedirect } = options;
|
|
277
|
-
const params = redirectTo ? { redirect_uri: redirectTo } : void 0;
|
|
278
|
-
const endpoint = `/api/auth/oauth/${provider}`;
|
|
279
|
-
const response = await this.http.get(endpoint, { params });
|
|
280
|
-
if (typeof window !== "undefined" && !skipBrowserRedirect) {
|
|
281
|
-
window.location.href = response.authUrl;
|
|
282
|
-
return { data: {}, error: null };
|
|
283
|
-
}
|
|
284
|
-
return {
|
|
285
|
-
data: {
|
|
286
|
-
url: response.authUrl,
|
|
287
|
-
provider
|
|
288
|
-
},
|
|
289
|
-
error: null
|
|
290
|
-
};
|
|
291
|
-
} catch (error) {
|
|
292
|
-
if (error instanceof InsForgeError) {
|
|
293
|
-
return { data: {}, error };
|
|
294
|
-
}
|
|
295
|
-
return {
|
|
296
|
-
data: {},
|
|
297
|
-
error: new InsForgeError(
|
|
298
|
-
"An unexpected error occurred during OAuth initialization",
|
|
299
|
-
500,
|
|
300
|
-
"UNEXPECTED_ERROR"
|
|
301
|
-
)
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Sign out the current user
|
|
307
|
-
*/
|
|
308
|
-
async signOut() {
|
|
309
|
-
try {
|
|
310
|
-
this.tokenManager.clearSession();
|
|
311
|
-
this.http.setAuthToken(null);
|
|
312
|
-
return { error: null };
|
|
313
|
-
} catch (error) {
|
|
314
|
-
return {
|
|
315
|
-
error: new InsForgeError(
|
|
316
|
-
"Failed to sign out",
|
|
317
|
-
500,
|
|
318
|
-
"SIGNOUT_ERROR"
|
|
319
|
-
)
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Get the current user from the API
|
|
325
|
-
* Returns exactly what the backend returns: {id, email, role}
|
|
326
|
-
*/
|
|
327
|
-
async getCurrentUser() {
|
|
328
|
-
try {
|
|
329
|
-
const session = this.tokenManager.getSession();
|
|
330
|
-
if (!session?.accessToken) {
|
|
331
|
-
return { data: null, error: null };
|
|
332
|
-
}
|
|
333
|
-
this.http.setAuthToken(session.accessToken);
|
|
334
|
-
const response = await this.http.get("/api/auth/sessions/current");
|
|
335
|
-
return {
|
|
336
|
-
data: response,
|
|
337
|
-
error: null
|
|
338
|
-
};
|
|
339
|
-
} catch (error) {
|
|
340
|
-
if (error instanceof InsForgeError && error.statusCode === 401) {
|
|
341
|
-
await this.signOut();
|
|
342
|
-
return { data: null, error: null };
|
|
343
|
-
}
|
|
344
|
-
if (error instanceof InsForgeError) {
|
|
345
|
-
return { data: null, error };
|
|
346
|
-
}
|
|
347
|
-
return {
|
|
348
|
-
data: null,
|
|
349
|
-
error: new InsForgeError(
|
|
350
|
-
"An unexpected error occurred while fetching user",
|
|
351
|
-
500,
|
|
352
|
-
"UNEXPECTED_ERROR"
|
|
353
|
-
)
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Get the stored session (no API call)
|
|
359
|
-
*/
|
|
360
|
-
async getSession() {
|
|
361
|
-
try {
|
|
362
|
-
const session = this.tokenManager.getSession();
|
|
363
|
-
if (session?.accessToken) {
|
|
364
|
-
this.http.setAuthToken(session.accessToken);
|
|
365
|
-
return { data: { session }, error: null };
|
|
366
|
-
}
|
|
367
|
-
return { data: { session: null }, error: null };
|
|
368
|
-
} catch (error) {
|
|
369
|
-
if (error instanceof InsForgeError) {
|
|
370
|
-
return { data: { session: null }, error };
|
|
371
|
-
}
|
|
372
|
-
return {
|
|
373
|
-
data: { session: null },
|
|
374
|
-
error: new InsForgeError(
|
|
375
|
-
"An unexpected error occurred while getting session",
|
|
376
|
-
500,
|
|
377
|
-
"UNEXPECTED_ERROR"
|
|
378
|
-
)
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
|
|
384
205
|
// src/modules/database.ts
|
|
385
206
|
var QueryBuilder = class {
|
|
386
207
|
constructor(table, http) {
|
|
@@ -668,6 +489,223 @@ var Database = class {
|
|
|
668
489
|
}
|
|
669
490
|
};
|
|
670
491
|
|
|
492
|
+
// src/modules/auth.ts
|
|
493
|
+
var Auth = class {
|
|
494
|
+
constructor(http, tokenManager) {
|
|
495
|
+
this.http = http;
|
|
496
|
+
this.tokenManager = tokenManager;
|
|
497
|
+
this.database = new Database(http);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Sign up a new user
|
|
501
|
+
*/
|
|
502
|
+
async signUp(request) {
|
|
503
|
+
try {
|
|
504
|
+
const response = await this.http.post("/api/auth/users", request);
|
|
505
|
+
const session = {
|
|
506
|
+
accessToken: response.accessToken,
|
|
507
|
+
user: response.user
|
|
508
|
+
};
|
|
509
|
+
this.tokenManager.saveSession(session);
|
|
510
|
+
this.http.setAuthToken(response.accessToken);
|
|
511
|
+
return {
|
|
512
|
+
data: response,
|
|
513
|
+
error: null
|
|
514
|
+
};
|
|
515
|
+
} catch (error) {
|
|
516
|
+
if (error instanceof InsForgeError) {
|
|
517
|
+
return { data: null, error };
|
|
518
|
+
}
|
|
519
|
+
return {
|
|
520
|
+
data: null,
|
|
521
|
+
error: new InsForgeError(
|
|
522
|
+
error instanceof Error ? error.message : "An unexpected error occurred during sign up",
|
|
523
|
+
500,
|
|
524
|
+
"UNEXPECTED_ERROR"
|
|
525
|
+
)
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Sign in with email and password
|
|
531
|
+
*/
|
|
532
|
+
async signInWithPassword(request) {
|
|
533
|
+
try {
|
|
534
|
+
const response = await this.http.post("/api/auth/sessions", request);
|
|
535
|
+
const session = {
|
|
536
|
+
accessToken: response.accessToken,
|
|
537
|
+
user: response.user
|
|
538
|
+
};
|
|
539
|
+
this.tokenManager.saveSession(session);
|
|
540
|
+
this.http.setAuthToken(response.accessToken);
|
|
541
|
+
return {
|
|
542
|
+
data: response,
|
|
543
|
+
error: null
|
|
544
|
+
};
|
|
545
|
+
} catch (error) {
|
|
546
|
+
if (error instanceof InsForgeError) {
|
|
547
|
+
return { data: null, error };
|
|
548
|
+
}
|
|
549
|
+
return {
|
|
550
|
+
data: null,
|
|
551
|
+
error: new InsForgeError(
|
|
552
|
+
"An unexpected error occurred during sign in",
|
|
553
|
+
500,
|
|
554
|
+
"UNEXPECTED_ERROR"
|
|
555
|
+
)
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Sign in with OAuth provider
|
|
561
|
+
*/
|
|
562
|
+
async signInWithOAuth(options) {
|
|
563
|
+
try {
|
|
564
|
+
const { provider, redirectTo, skipBrowserRedirect } = options;
|
|
565
|
+
const params = redirectTo ? { redirect_uri: redirectTo } : void 0;
|
|
566
|
+
const endpoint = `/api/auth/oauth/${provider}`;
|
|
567
|
+
const response = await this.http.get(endpoint, { params });
|
|
568
|
+
if (typeof window !== "undefined" && !skipBrowserRedirect) {
|
|
569
|
+
window.location.href = response.authUrl;
|
|
570
|
+
return { data: {}, error: null };
|
|
571
|
+
}
|
|
572
|
+
return {
|
|
573
|
+
data: {
|
|
574
|
+
url: response.authUrl,
|
|
575
|
+
provider
|
|
576
|
+
},
|
|
577
|
+
error: null
|
|
578
|
+
};
|
|
579
|
+
} catch (error) {
|
|
580
|
+
if (error instanceof InsForgeError) {
|
|
581
|
+
return { data: {}, error };
|
|
582
|
+
}
|
|
583
|
+
return {
|
|
584
|
+
data: {},
|
|
585
|
+
error: new InsForgeError(
|
|
586
|
+
"An unexpected error occurred during OAuth initialization",
|
|
587
|
+
500,
|
|
588
|
+
"UNEXPECTED_ERROR"
|
|
589
|
+
)
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Sign out the current user
|
|
595
|
+
*/
|
|
596
|
+
async signOut() {
|
|
597
|
+
try {
|
|
598
|
+
this.tokenManager.clearSession();
|
|
599
|
+
this.http.setAuthToken(null);
|
|
600
|
+
return { error: null };
|
|
601
|
+
} catch (error) {
|
|
602
|
+
return {
|
|
603
|
+
error: new InsForgeError(
|
|
604
|
+
"Failed to sign out",
|
|
605
|
+
500,
|
|
606
|
+
"SIGNOUT_ERROR"
|
|
607
|
+
)
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Get the current user with full profile information
|
|
613
|
+
* Returns both auth info (id, email, role) and profile data (nickname, avatar_url, bio, etc.)
|
|
614
|
+
*/
|
|
615
|
+
async getCurrentUser() {
|
|
616
|
+
try {
|
|
617
|
+
const session = this.tokenManager.getSession();
|
|
618
|
+
if (!session?.accessToken) {
|
|
619
|
+
return { data: null, error: null };
|
|
620
|
+
}
|
|
621
|
+
this.http.setAuthToken(session.accessToken);
|
|
622
|
+
const authResponse = await this.http.get("/api/auth/sessions/current");
|
|
623
|
+
const { data: profile, error: profileError } = await this.database.from("users").select("*").eq("id", authResponse.user.id).single();
|
|
624
|
+
if (profileError && profileError.statusCode !== 406) {
|
|
625
|
+
return { data: null, error: profileError };
|
|
626
|
+
}
|
|
627
|
+
return {
|
|
628
|
+
data: {
|
|
629
|
+
user: authResponse.user,
|
|
630
|
+
profile
|
|
631
|
+
},
|
|
632
|
+
error: null
|
|
633
|
+
};
|
|
634
|
+
} catch (error) {
|
|
635
|
+
if (error instanceof InsForgeError && error.statusCode === 401) {
|
|
636
|
+
await this.signOut();
|
|
637
|
+
return { data: null, error: null };
|
|
638
|
+
}
|
|
639
|
+
if (error instanceof InsForgeError) {
|
|
640
|
+
return { data: null, error };
|
|
641
|
+
}
|
|
642
|
+
return {
|
|
643
|
+
data: null,
|
|
644
|
+
error: new InsForgeError(
|
|
645
|
+
"An unexpected error occurred while fetching user",
|
|
646
|
+
500,
|
|
647
|
+
"UNEXPECTED_ERROR"
|
|
648
|
+
)
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Get any user's profile by ID
|
|
654
|
+
* Returns profile information from the users table (nickname, avatar_url, bio, etc.)
|
|
655
|
+
*/
|
|
656
|
+
async getProfile(userId) {
|
|
657
|
+
const { data, error } = await this.database.from("users").select("*").eq("id", userId).single();
|
|
658
|
+
if (error && error.statusCode === 406) {
|
|
659
|
+
return { data: null, error: null };
|
|
660
|
+
}
|
|
661
|
+
return { data, error };
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Get the current session (only session data, no API call)
|
|
665
|
+
* Returns the stored JWT token and basic user info from local storage
|
|
666
|
+
*/
|
|
667
|
+
async getCurrentSession() {
|
|
668
|
+
try {
|
|
669
|
+
const session = this.tokenManager.getSession();
|
|
670
|
+
if (session?.accessToken) {
|
|
671
|
+
this.http.setAuthToken(session.accessToken);
|
|
672
|
+
return { data: { session }, error: null };
|
|
673
|
+
}
|
|
674
|
+
return { data: { session: null }, error: null };
|
|
675
|
+
} catch (error) {
|
|
676
|
+
if (error instanceof InsForgeError) {
|
|
677
|
+
return { data: { session: null }, error };
|
|
678
|
+
}
|
|
679
|
+
return {
|
|
680
|
+
data: { session: null },
|
|
681
|
+
error: new InsForgeError(
|
|
682
|
+
"An unexpected error occurred while getting session",
|
|
683
|
+
500,
|
|
684
|
+
"UNEXPECTED_ERROR"
|
|
685
|
+
)
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Set/Update the current user's profile
|
|
691
|
+
* Updates profile information in the users table (nickname, avatar_url, bio, etc.)
|
|
692
|
+
*/
|
|
693
|
+
async setProfile(profile) {
|
|
694
|
+
const session = this.tokenManager.getSession();
|
|
695
|
+
if (!session?.user?.id) {
|
|
696
|
+
return {
|
|
697
|
+
data: null,
|
|
698
|
+
error: new InsForgeError(
|
|
699
|
+
"No authenticated user found",
|
|
700
|
+
401,
|
|
701
|
+
"UNAUTHENTICATED"
|
|
702
|
+
)
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
return await this.database.from("users").update(profile).eq("id", session.user.id).select().single();
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
|
|
671
709
|
// src/modules/storage.ts
|
|
672
710
|
var StorageBucket = class {
|
|
673
711
|
constructor(bucketName, http) {
|