@fluxbase/sdk 0.0.1-rc.116 → 0.0.1-rc.118
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.cjs +20 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +20 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -3784,10 +3784,11 @@ declare class FluxbaseAuth {
|
|
|
3784
3784
|
* Send password reset email (Supabase-compatible)
|
|
3785
3785
|
* Sends a password reset link to the provided email address
|
|
3786
3786
|
* @param email - Email address to send reset link to
|
|
3787
|
-
* @param options - Optional configuration including CAPTCHA token
|
|
3787
|
+
* @param options - Optional configuration including redirect URL and CAPTCHA token
|
|
3788
3788
|
* @returns Promise with OTP-style response
|
|
3789
3789
|
*/
|
|
3790
3790
|
sendPasswordReset(email: string, options?: {
|
|
3791
|
+
redirectTo?: string;
|
|
3791
3792
|
captchaToken?: string;
|
|
3792
3793
|
}): Promise<DataResponse<PasswordResetResponse>>;
|
|
3793
3794
|
/**
|
|
@@ -3845,8 +3846,9 @@ declare class FluxbaseAuth {
|
|
|
3845
3846
|
* Exchange OAuth authorization code for session
|
|
3846
3847
|
* This is typically called in your OAuth callback handler
|
|
3847
3848
|
* @param code - Authorization code from OAuth callback
|
|
3849
|
+
* @param state - State parameter from OAuth callback (for CSRF protection)
|
|
3848
3850
|
*/
|
|
3849
|
-
exchangeCodeForSession(code: string): Promise<FluxbaseAuthResponse>;
|
|
3851
|
+
exchangeCodeForSession(code: string, state?: string): Promise<FluxbaseAuthResponse>;
|
|
3850
3852
|
/**
|
|
3851
3853
|
* Convenience method to initiate OAuth sign-in
|
|
3852
3854
|
* Redirects the user to the OAuth provider's authorization page
|
package/dist/index.d.ts
CHANGED
|
@@ -3784,10 +3784,11 @@ declare class FluxbaseAuth {
|
|
|
3784
3784
|
* Send password reset email (Supabase-compatible)
|
|
3785
3785
|
* Sends a password reset link to the provided email address
|
|
3786
3786
|
* @param email - Email address to send reset link to
|
|
3787
|
-
* @param options - Optional configuration including CAPTCHA token
|
|
3787
|
+
* @param options - Optional configuration including redirect URL and CAPTCHA token
|
|
3788
3788
|
* @returns Promise with OTP-style response
|
|
3789
3789
|
*/
|
|
3790
3790
|
sendPasswordReset(email: string, options?: {
|
|
3791
|
+
redirectTo?: string;
|
|
3791
3792
|
captchaToken?: string;
|
|
3792
3793
|
}): Promise<DataResponse<PasswordResetResponse>>;
|
|
3793
3794
|
/**
|
|
@@ -3845,8 +3846,9 @@ declare class FluxbaseAuth {
|
|
|
3845
3846
|
* Exchange OAuth authorization code for session
|
|
3846
3847
|
* This is typically called in your OAuth callback handler
|
|
3847
3848
|
* @param code - Authorization code from OAuth callback
|
|
3849
|
+
* @param state - State parameter from OAuth callback (for CSRF protection)
|
|
3848
3850
|
*/
|
|
3849
|
-
exchangeCodeForSession(code: string): Promise<FluxbaseAuthResponse>;
|
|
3851
|
+
exchangeCodeForSession(code: string, state?: string): Promise<FluxbaseAuthResponse>;
|
|
3850
3852
|
/**
|
|
3851
3853
|
* Convenience method to initiate OAuth sign-in
|
|
3852
3854
|
* Redirects the user to the OAuth provider's authorization page
|
package/dist/index.js
CHANGED
|
@@ -331,6 +331,7 @@ async function wrapAsyncVoid(operation) {
|
|
|
331
331
|
|
|
332
332
|
// src/auth.ts
|
|
333
333
|
var AUTH_STORAGE_KEY = "fluxbase.auth.session";
|
|
334
|
+
var OAUTH_PROVIDER_KEY = "fluxbase.auth.oauth_provider";
|
|
334
335
|
var AUTO_REFRESH_TICK_THRESHOLD = 10;
|
|
335
336
|
var AUTO_REFRESH_TICK_MINIMUM = 1e3;
|
|
336
337
|
var MAX_REFRESH_RETRIES = 3;
|
|
@@ -755,12 +756,15 @@ var FluxbaseAuth = class {
|
|
|
755
756
|
* Send password reset email (Supabase-compatible)
|
|
756
757
|
* Sends a password reset link to the provided email address
|
|
757
758
|
* @param email - Email address to send reset link to
|
|
758
|
-
* @param options - Optional configuration including CAPTCHA token
|
|
759
|
+
* @param options - Optional configuration including redirect URL and CAPTCHA token
|
|
759
760
|
* @returns Promise with OTP-style response
|
|
760
761
|
*/
|
|
761
762
|
async sendPasswordReset(email, options) {
|
|
762
763
|
return wrapAsync(async () => {
|
|
763
764
|
const requestBody = { email };
|
|
765
|
+
if (options?.redirectTo) {
|
|
766
|
+
requestBody.redirect_to = options.redirectTo;
|
|
767
|
+
}
|
|
764
768
|
if (options?.captchaToken) {
|
|
765
769
|
requestBody.captcha_token = options.captchaToken;
|
|
766
770
|
}
|
|
@@ -776,6 +780,7 @@ var FluxbaseAuth = class {
|
|
|
776
780
|
*/
|
|
777
781
|
async resetPasswordForEmail(email, options) {
|
|
778
782
|
return this.sendPasswordReset(email, {
|
|
783
|
+
redirectTo: options?.redirectTo,
|
|
779
784
|
captchaToken: options?.captchaToken
|
|
780
785
|
});
|
|
781
786
|
}
|
|
@@ -908,13 +913,22 @@ var FluxbaseAuth = class {
|
|
|
908
913
|
* Exchange OAuth authorization code for session
|
|
909
914
|
* This is typically called in your OAuth callback handler
|
|
910
915
|
* @param code - Authorization code from OAuth callback
|
|
916
|
+
* @param state - State parameter from OAuth callback (for CSRF protection)
|
|
911
917
|
*/
|
|
912
|
-
async exchangeCodeForSession(code) {
|
|
918
|
+
async exchangeCodeForSession(code, state) {
|
|
913
919
|
return wrapAsync(async () => {
|
|
914
|
-
const
|
|
915
|
-
|
|
916
|
-
|
|
920
|
+
const provider = this.storage?.getItem(OAUTH_PROVIDER_KEY);
|
|
921
|
+
if (!provider) {
|
|
922
|
+
throw new Error("No OAuth provider found. Call signInWithOAuth first.");
|
|
923
|
+
}
|
|
924
|
+
const params = new URLSearchParams({ code });
|
|
925
|
+
if (state) {
|
|
926
|
+
params.append("state", state);
|
|
927
|
+
}
|
|
928
|
+
const response = await this.fetch.get(
|
|
929
|
+
`/api/v1/auth/oauth/${provider}/callback?${params.toString()}`
|
|
917
930
|
);
|
|
931
|
+
this.storage?.removeItem(OAUTH_PROVIDER_KEY);
|
|
918
932
|
const session = {
|
|
919
933
|
...response,
|
|
920
934
|
expires_at: Date.now() + response.expires_in * 1e3
|
|
@@ -937,6 +951,7 @@ var FluxbaseAuth = class {
|
|
|
937
951
|
}
|
|
938
952
|
const url = result.data.url;
|
|
939
953
|
if (typeof window !== "undefined") {
|
|
954
|
+
this.storage?.setItem(OAUTH_PROVIDER_KEY, provider);
|
|
940
955
|
window.location.href = url;
|
|
941
956
|
} else {
|
|
942
957
|
throw new Error(
|