@insforge/sdk 0.0.58-dev.13 → 0.0.58-dev.15
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 +48 -41
- package/dist/index.d.ts +48 -41
- package/dist/index.js +50 -49
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -49
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UserSchema, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema, GetPublicAuthConfigResponse, UserIdSchema, EmailSchema, RoleSchema, StorageFileSchema, ListObjectsResponseSchema, ChatCompletionRequest, ImageGenerationRequest } from '@insforge/shared-schemas';
|
|
1
|
+
import { UserSchema, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema, GetPublicAuthConfigResponse, UserIdSchema, EmailSchema, RoleSchema, SendVerificationEmailRequest, SendResetPasswordEmailRequest, ExchangeResetPasswordTokenRequest, VerifyEmailRequest, StorageFileSchema, ListObjectsResponseSchema, ChatCompletionRequest, ImageGenerationRequest } from '@insforge/shared-schemas';
|
|
2
2
|
export { AuthErrorResponse, CreateSessionRequest, CreateUserRequest, UserSchema } from '@insforge/shared-schemas';
|
|
3
3
|
import * as _supabase_postgrest_js from '@supabase/postgrest-js';
|
|
4
4
|
|
|
@@ -131,7 +131,7 @@ declare class Auth {
|
|
|
131
131
|
* This runs on initialization to seamlessly complete the OAuth flow
|
|
132
132
|
* Matches the backend's OAuth callback response (backend/src/api/routes/auth.ts:540-544)
|
|
133
133
|
*/
|
|
134
|
-
private
|
|
134
|
+
private detectAuthCallback;
|
|
135
135
|
/**
|
|
136
136
|
* Sign up a new user
|
|
137
137
|
*/
|
|
@@ -228,25 +228,13 @@ declare class Auth {
|
|
|
228
228
|
error: any | null;
|
|
229
229
|
}>;
|
|
230
230
|
/**
|
|
231
|
-
* Send email verification code
|
|
232
|
-
*
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}): Promise<{
|
|
237
|
-
data: {
|
|
238
|
-
success: boolean;
|
|
239
|
-
message: string;
|
|
240
|
-
} | null;
|
|
241
|
-
error: InsForgeError | null;
|
|
242
|
-
}>;
|
|
243
|
-
/**
|
|
244
|
-
* Send email verification link
|
|
245
|
-
* Creates a magic link token and sends it via email
|
|
231
|
+
* Send email verification (code or link based on config)
|
|
232
|
+
*
|
|
233
|
+
* Send email verification using the method configured in auth settings (verifyEmailMethod).
|
|
234
|
+
* When method is 'code', sends a 6-digit numeric code. When method is 'link', sends a magic link.
|
|
235
|
+
* Prevents user enumeration by returning success even if email doesn't exist.
|
|
246
236
|
*/
|
|
247
|
-
|
|
248
|
-
email: string;
|
|
249
|
-
}): Promise<{
|
|
237
|
+
sendVerificationEmail(request: SendVerificationEmailRequest): Promise<{
|
|
250
238
|
data: {
|
|
251
239
|
success: boolean;
|
|
252
240
|
message: string;
|
|
@@ -254,12 +242,14 @@ declare class Auth {
|
|
|
254
242
|
error: InsForgeError | null;
|
|
255
243
|
}>;
|
|
256
244
|
/**
|
|
257
|
-
* Send password reset code
|
|
258
|
-
*
|
|
245
|
+
* Send password reset (code or link based on config)
|
|
246
|
+
*
|
|
247
|
+
* Send password reset email using the method configured in auth settings (resetPasswordMethod).
|
|
248
|
+
* When method is 'code', sends a 6-digit numeric code for two-step flow.
|
|
249
|
+
* When method is 'link', sends a magic link.
|
|
250
|
+
* Prevents user enumeration by returning success even if email doesn't exist.
|
|
259
251
|
*/
|
|
260
|
-
|
|
261
|
-
email: string;
|
|
262
|
-
}): Promise<{
|
|
252
|
+
sendResetPasswordEmail(request: SendResetPasswordEmailRequest): Promise<{
|
|
263
253
|
data: {
|
|
264
254
|
success: boolean;
|
|
265
255
|
message: string;
|
|
@@ -267,22 +257,33 @@ declare class Auth {
|
|
|
267
257
|
error: InsForgeError | null;
|
|
268
258
|
}>;
|
|
269
259
|
/**
|
|
270
|
-
*
|
|
271
|
-
*
|
|
260
|
+
* Exchange reset password code for reset token
|
|
261
|
+
*
|
|
262
|
+
* Step 1 of two-step password reset flow (only used when resetPasswordMethod is 'code'):
|
|
263
|
+
* 1. Verify the 6-digit code sent to user's email
|
|
264
|
+
* 2. Return a reset token that can be used to actually reset the password
|
|
265
|
+
*
|
|
266
|
+
* This endpoint is not used when resetPasswordMethod is 'link' (magic link flow is direct).
|
|
272
267
|
*/
|
|
273
|
-
|
|
274
|
-
email: string;
|
|
275
|
-
code: string;
|
|
276
|
-
}): Promise<{
|
|
268
|
+
exchangeResetPasswordToken(request: ExchangeResetPasswordTokenRequest): Promise<{
|
|
277
269
|
data: {
|
|
278
|
-
|
|
270
|
+
token: string;
|
|
279
271
|
expiresAt: string;
|
|
280
272
|
} | null;
|
|
281
273
|
error: InsForgeError | null;
|
|
282
274
|
}>;
|
|
283
275
|
/**
|
|
284
|
-
* Reset password with
|
|
285
|
-
*
|
|
276
|
+
* Reset password with token
|
|
277
|
+
*
|
|
278
|
+
* Reset user password with a token. The token can be:
|
|
279
|
+
* - Magic link token (64-character hex token from send-reset-password when method is 'link')
|
|
280
|
+
* - Reset token (from exchange-reset-password-token after code verification when method is 'code')
|
|
281
|
+
*
|
|
282
|
+
* Both token types use RESET_PASSWORD purpose and are verified the same way.
|
|
283
|
+
*
|
|
284
|
+
* Flow summary:
|
|
285
|
+
* - Code method: send-reset-password → exchange-reset-password-token → reset-password (with resetToken)
|
|
286
|
+
* - Link method: send-reset-password → reset-password (with link token directly)
|
|
286
287
|
*/
|
|
287
288
|
resetPassword(request: {
|
|
288
289
|
newPassword: string;
|
|
@@ -295,17 +296,23 @@ declare class Auth {
|
|
|
295
296
|
error: InsForgeError | null;
|
|
296
297
|
}>;
|
|
297
298
|
/**
|
|
298
|
-
* Verify email with
|
|
299
|
-
*
|
|
300
|
-
*
|
|
299
|
+
* Verify email with code or link
|
|
300
|
+
*
|
|
301
|
+
* Verify email address using the method configured in auth settings (verifyEmailMethod):
|
|
302
|
+
* - Code verification: Provide both `email` and `otp` (6-digit numeric code)
|
|
303
|
+
* - Link verification: Provide only `otp` (64-character hex token from magic link)
|
|
304
|
+
*
|
|
305
|
+
* Successfully verified users will receive a session token.
|
|
306
|
+
*
|
|
307
|
+
* The email verification link sent to users always points to the backend API endpoint.
|
|
308
|
+
* If `verifyEmailRedirectTo` is configured, the backend will redirect to that URL after successful verification.
|
|
309
|
+
* Otherwise, a default success page is displayed.
|
|
301
310
|
*/
|
|
302
|
-
verifyEmail(request: {
|
|
303
|
-
email?: string;
|
|
304
|
-
otp: string;
|
|
305
|
-
}): Promise<{
|
|
311
|
+
verifyEmail(request: VerifyEmailRequest): Promise<{
|
|
306
312
|
data: {
|
|
307
313
|
accessToken: string;
|
|
308
314
|
user?: any;
|
|
315
|
+
redirectTo?: string;
|
|
309
316
|
} | null;
|
|
310
317
|
error: InsForgeError | null;
|
|
311
318
|
}>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UserSchema, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema, GetPublicAuthConfigResponse, UserIdSchema, EmailSchema, RoleSchema, StorageFileSchema, ListObjectsResponseSchema, ChatCompletionRequest, ImageGenerationRequest } from '@insforge/shared-schemas';
|
|
1
|
+
import { UserSchema, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema, GetPublicAuthConfigResponse, UserIdSchema, EmailSchema, RoleSchema, SendVerificationEmailRequest, SendResetPasswordEmailRequest, ExchangeResetPasswordTokenRequest, VerifyEmailRequest, StorageFileSchema, ListObjectsResponseSchema, ChatCompletionRequest, ImageGenerationRequest } from '@insforge/shared-schemas';
|
|
2
2
|
export { AuthErrorResponse, CreateSessionRequest, CreateUserRequest, UserSchema } from '@insforge/shared-schemas';
|
|
3
3
|
import * as _supabase_postgrest_js from '@supabase/postgrest-js';
|
|
4
4
|
|
|
@@ -131,7 +131,7 @@ declare class Auth {
|
|
|
131
131
|
* This runs on initialization to seamlessly complete the OAuth flow
|
|
132
132
|
* Matches the backend's OAuth callback response (backend/src/api/routes/auth.ts:540-544)
|
|
133
133
|
*/
|
|
134
|
-
private
|
|
134
|
+
private detectAuthCallback;
|
|
135
135
|
/**
|
|
136
136
|
* Sign up a new user
|
|
137
137
|
*/
|
|
@@ -228,25 +228,13 @@ declare class Auth {
|
|
|
228
228
|
error: any | null;
|
|
229
229
|
}>;
|
|
230
230
|
/**
|
|
231
|
-
* Send email verification code
|
|
232
|
-
*
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}): Promise<{
|
|
237
|
-
data: {
|
|
238
|
-
success: boolean;
|
|
239
|
-
message: string;
|
|
240
|
-
} | null;
|
|
241
|
-
error: InsForgeError | null;
|
|
242
|
-
}>;
|
|
243
|
-
/**
|
|
244
|
-
* Send email verification link
|
|
245
|
-
* Creates a magic link token and sends it via email
|
|
231
|
+
* Send email verification (code or link based on config)
|
|
232
|
+
*
|
|
233
|
+
* Send email verification using the method configured in auth settings (verifyEmailMethod).
|
|
234
|
+
* When method is 'code', sends a 6-digit numeric code. When method is 'link', sends a magic link.
|
|
235
|
+
* Prevents user enumeration by returning success even if email doesn't exist.
|
|
246
236
|
*/
|
|
247
|
-
|
|
248
|
-
email: string;
|
|
249
|
-
}): Promise<{
|
|
237
|
+
sendVerificationEmail(request: SendVerificationEmailRequest): Promise<{
|
|
250
238
|
data: {
|
|
251
239
|
success: boolean;
|
|
252
240
|
message: string;
|
|
@@ -254,12 +242,14 @@ declare class Auth {
|
|
|
254
242
|
error: InsForgeError | null;
|
|
255
243
|
}>;
|
|
256
244
|
/**
|
|
257
|
-
* Send password reset code
|
|
258
|
-
*
|
|
245
|
+
* Send password reset (code or link based on config)
|
|
246
|
+
*
|
|
247
|
+
* Send password reset email using the method configured in auth settings (resetPasswordMethod).
|
|
248
|
+
* When method is 'code', sends a 6-digit numeric code for two-step flow.
|
|
249
|
+
* When method is 'link', sends a magic link.
|
|
250
|
+
* Prevents user enumeration by returning success even if email doesn't exist.
|
|
259
251
|
*/
|
|
260
|
-
|
|
261
|
-
email: string;
|
|
262
|
-
}): Promise<{
|
|
252
|
+
sendResetPasswordEmail(request: SendResetPasswordEmailRequest): Promise<{
|
|
263
253
|
data: {
|
|
264
254
|
success: boolean;
|
|
265
255
|
message: string;
|
|
@@ -267,22 +257,33 @@ declare class Auth {
|
|
|
267
257
|
error: InsForgeError | null;
|
|
268
258
|
}>;
|
|
269
259
|
/**
|
|
270
|
-
*
|
|
271
|
-
*
|
|
260
|
+
* Exchange reset password code for reset token
|
|
261
|
+
*
|
|
262
|
+
* Step 1 of two-step password reset flow (only used when resetPasswordMethod is 'code'):
|
|
263
|
+
* 1. Verify the 6-digit code sent to user's email
|
|
264
|
+
* 2. Return a reset token that can be used to actually reset the password
|
|
265
|
+
*
|
|
266
|
+
* This endpoint is not used when resetPasswordMethod is 'link' (magic link flow is direct).
|
|
272
267
|
*/
|
|
273
|
-
|
|
274
|
-
email: string;
|
|
275
|
-
code: string;
|
|
276
|
-
}): Promise<{
|
|
268
|
+
exchangeResetPasswordToken(request: ExchangeResetPasswordTokenRequest): Promise<{
|
|
277
269
|
data: {
|
|
278
|
-
|
|
270
|
+
token: string;
|
|
279
271
|
expiresAt: string;
|
|
280
272
|
} | null;
|
|
281
273
|
error: InsForgeError | null;
|
|
282
274
|
}>;
|
|
283
275
|
/**
|
|
284
|
-
* Reset password with
|
|
285
|
-
*
|
|
276
|
+
* Reset password with token
|
|
277
|
+
*
|
|
278
|
+
* Reset user password with a token. The token can be:
|
|
279
|
+
* - Magic link token (64-character hex token from send-reset-password when method is 'link')
|
|
280
|
+
* - Reset token (from exchange-reset-password-token after code verification when method is 'code')
|
|
281
|
+
*
|
|
282
|
+
* Both token types use RESET_PASSWORD purpose and are verified the same way.
|
|
283
|
+
*
|
|
284
|
+
* Flow summary:
|
|
285
|
+
* - Code method: send-reset-password → exchange-reset-password-token → reset-password (with resetToken)
|
|
286
|
+
* - Link method: send-reset-password → reset-password (with link token directly)
|
|
286
287
|
*/
|
|
287
288
|
resetPassword(request: {
|
|
288
289
|
newPassword: string;
|
|
@@ -295,17 +296,23 @@ declare class Auth {
|
|
|
295
296
|
error: InsForgeError | null;
|
|
296
297
|
}>;
|
|
297
298
|
/**
|
|
298
|
-
* Verify email with
|
|
299
|
-
*
|
|
300
|
-
*
|
|
299
|
+
* Verify email with code or link
|
|
300
|
+
*
|
|
301
|
+
* Verify email address using the method configured in auth settings (verifyEmailMethod):
|
|
302
|
+
* - Code verification: Provide both `email` and `otp` (6-digit numeric code)
|
|
303
|
+
* - Link verification: Provide only `otp` (64-character hex token from magic link)
|
|
304
|
+
*
|
|
305
|
+
* Successfully verified users will receive a session token.
|
|
306
|
+
*
|
|
307
|
+
* The email verification link sent to users always points to the backend API endpoint.
|
|
308
|
+
* If `verifyEmailRedirectTo` is configured, the backend will redirect to that URL after successful verification.
|
|
309
|
+
* Otherwise, a default success page is displayed.
|
|
301
310
|
*/
|
|
302
|
-
verifyEmail(request: {
|
|
303
|
-
email?: string;
|
|
304
|
-
otp: string;
|
|
305
|
-
}): Promise<{
|
|
311
|
+
verifyEmail(request: VerifyEmailRequest): Promise<{
|
|
306
312
|
data: {
|
|
307
313
|
accessToken: string;
|
|
308
314
|
user?: any;
|
|
315
|
+
redirectTo?: string;
|
|
309
316
|
} | null;
|
|
310
317
|
error: InsForgeError | null;
|
|
311
318
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -319,14 +319,14 @@ var Auth = class {
|
|
|
319
319
|
this.http = http;
|
|
320
320
|
this.tokenManager = tokenManager;
|
|
321
321
|
this.database = new Database(http, tokenManager);
|
|
322
|
-
this.
|
|
322
|
+
this.detectAuthCallback();
|
|
323
323
|
}
|
|
324
324
|
/**
|
|
325
325
|
* Automatically detect and handle OAuth callback parameters in the URL
|
|
326
326
|
* This runs on initialization to seamlessly complete the OAuth flow
|
|
327
327
|
* Matches the backend's OAuth callback response (backend/src/api/routes/auth.ts:540-544)
|
|
328
328
|
*/
|
|
329
|
-
|
|
329
|
+
detectAuthCallback() {
|
|
330
330
|
if (typeof window === "undefined") return;
|
|
331
331
|
try {
|
|
332
332
|
const params = new URLSearchParams(window.location.search);
|
|
@@ -648,13 +648,16 @@ var Auth = class {
|
|
|
648
648
|
return { data: null, error };
|
|
649
649
|
}
|
|
650
650
|
/**
|
|
651
|
-
* Send email verification code
|
|
652
|
-
*
|
|
651
|
+
* Send email verification (code or link based on config)
|
|
652
|
+
*
|
|
653
|
+
* Send email verification using the method configured in auth settings (verifyEmailMethod).
|
|
654
|
+
* When method is 'code', sends a 6-digit numeric code. When method is 'link', sends a magic link.
|
|
655
|
+
* Prevents user enumeration by returning success even if email doesn't exist.
|
|
653
656
|
*/
|
|
654
|
-
async
|
|
657
|
+
async sendVerificationEmail(request) {
|
|
655
658
|
try {
|
|
656
659
|
const response = await this.http.post(
|
|
657
|
-
"/api/auth/email/send-verification
|
|
660
|
+
"/api/auth/email/send-verification",
|
|
658
661
|
request
|
|
659
662
|
);
|
|
660
663
|
return {
|
|
@@ -676,41 +679,17 @@ var Auth = class {
|
|
|
676
679
|
}
|
|
677
680
|
}
|
|
678
681
|
/**
|
|
679
|
-
* Send
|
|
680
|
-
*
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
"/api/auth/email/send-verification-link",
|
|
686
|
-
request
|
|
687
|
-
);
|
|
688
|
-
return {
|
|
689
|
-
data: response,
|
|
690
|
-
error: null
|
|
691
|
-
};
|
|
692
|
-
} catch (error) {
|
|
693
|
-
if (error instanceof InsForgeError) {
|
|
694
|
-
return { data: null, error };
|
|
695
|
-
}
|
|
696
|
-
return {
|
|
697
|
-
data: null,
|
|
698
|
-
error: new InsForgeError(
|
|
699
|
-
"An unexpected error occurred while sending verification link",
|
|
700
|
-
500,
|
|
701
|
-
"UNEXPECTED_ERROR"
|
|
702
|
-
)
|
|
703
|
-
};
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
/**
|
|
707
|
-
* Send password reset code to user's email
|
|
708
|
-
* Always returns success to prevent user enumeration
|
|
682
|
+
* Send password reset (code or link based on config)
|
|
683
|
+
*
|
|
684
|
+
* Send password reset email using the method configured in auth settings (resetPasswordMethod).
|
|
685
|
+
* When method is 'code', sends a 6-digit numeric code for two-step flow.
|
|
686
|
+
* When method is 'link', sends a magic link.
|
|
687
|
+
* Prevents user enumeration by returning success even if email doesn't exist.
|
|
709
688
|
*/
|
|
710
|
-
async
|
|
689
|
+
async sendResetPasswordEmail(request) {
|
|
711
690
|
try {
|
|
712
691
|
const response = await this.http.post(
|
|
713
|
-
"/api/auth/email/send-reset-password
|
|
692
|
+
"/api/auth/email/send-reset-password",
|
|
714
693
|
request
|
|
715
694
|
);
|
|
716
695
|
return {
|
|
@@ -732,13 +711,18 @@ var Auth = class {
|
|
|
732
711
|
}
|
|
733
712
|
}
|
|
734
713
|
/**
|
|
735
|
-
*
|
|
736
|
-
*
|
|
714
|
+
* Exchange reset password code for reset token
|
|
715
|
+
*
|
|
716
|
+
* Step 1 of two-step password reset flow (only used when resetPasswordMethod is 'code'):
|
|
717
|
+
* 1. Verify the 6-digit code sent to user's email
|
|
718
|
+
* 2. Return a reset token that can be used to actually reset the password
|
|
719
|
+
*
|
|
720
|
+
* This endpoint is not used when resetPasswordMethod is 'link' (magic link flow is direct).
|
|
737
721
|
*/
|
|
738
|
-
async
|
|
722
|
+
async exchangeResetPasswordToken(request) {
|
|
739
723
|
try {
|
|
740
724
|
const response = await this.http.post(
|
|
741
|
-
"/api/auth/
|
|
725
|
+
"/api/auth/email/exchange-reset-password-token",
|
|
742
726
|
request
|
|
743
727
|
);
|
|
744
728
|
return {
|
|
@@ -760,13 +744,22 @@ var Auth = class {
|
|
|
760
744
|
}
|
|
761
745
|
}
|
|
762
746
|
/**
|
|
763
|
-
* Reset password with
|
|
764
|
-
*
|
|
747
|
+
* Reset password with token
|
|
748
|
+
*
|
|
749
|
+
* Reset user password with a token. The token can be:
|
|
750
|
+
* - Magic link token (64-character hex token from send-reset-password when method is 'link')
|
|
751
|
+
* - Reset token (from exchange-reset-password-token after code verification when method is 'code')
|
|
752
|
+
*
|
|
753
|
+
* Both token types use RESET_PASSWORD purpose and are verified the same way.
|
|
754
|
+
*
|
|
755
|
+
* Flow summary:
|
|
756
|
+
* - Code method: send-reset-password → exchange-reset-password-token → reset-password (with resetToken)
|
|
757
|
+
* - Link method: send-reset-password → reset-password (with link token directly)
|
|
765
758
|
*/
|
|
766
759
|
async resetPassword(request) {
|
|
767
760
|
try {
|
|
768
761
|
const response = await this.http.post(
|
|
769
|
-
"/api/auth/reset-password",
|
|
762
|
+
"/api/auth/email/reset-password",
|
|
770
763
|
request
|
|
771
764
|
);
|
|
772
765
|
return {
|
|
@@ -788,14 +781,22 @@ var Auth = class {
|
|
|
788
781
|
}
|
|
789
782
|
}
|
|
790
783
|
/**
|
|
791
|
-
* Verify email with
|
|
792
|
-
*
|
|
793
|
-
*
|
|
784
|
+
* Verify email with code or link
|
|
785
|
+
*
|
|
786
|
+
* Verify email address using the method configured in auth settings (verifyEmailMethod):
|
|
787
|
+
* - Code verification: Provide both `email` and `otp` (6-digit numeric code)
|
|
788
|
+
* - Link verification: Provide only `otp` (64-character hex token from magic link)
|
|
789
|
+
*
|
|
790
|
+
* Successfully verified users will receive a session token.
|
|
791
|
+
*
|
|
792
|
+
* The email verification link sent to users always points to the backend API endpoint.
|
|
793
|
+
* If `verifyEmailRedirectTo` is configured, the backend will redirect to that URL after successful verification.
|
|
794
|
+
* Otherwise, a default success page is displayed.
|
|
794
795
|
*/
|
|
795
796
|
async verifyEmail(request) {
|
|
796
797
|
try {
|
|
797
798
|
const response = await this.http.post(
|
|
798
|
-
"/api/auth/verify
|
|
799
|
+
"/api/auth/email/verify",
|
|
799
800
|
request
|
|
800
801
|
);
|
|
801
802
|
if (response.accessToken) {
|