@fluxbase/sdk 0.0.1-rc.114 → 0.0.1-rc.116
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 +53 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -1
- package/dist/index.d.ts +58 -1
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -948,6 +948,59 @@ var FluxbaseAuth = class {
|
|
|
948
948
|
return { provider, url };
|
|
949
949
|
});
|
|
950
950
|
}
|
|
951
|
+
/**
|
|
952
|
+
* Get OAuth logout URL for a provider
|
|
953
|
+
* Use this to get the logout URL without automatically redirecting
|
|
954
|
+
* @param provider - OAuth provider name (e.g., 'google', 'github')
|
|
955
|
+
* @param options - Optional logout configuration
|
|
956
|
+
* @returns Promise with OAuth logout response including redirect URL if applicable
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```typescript
|
|
960
|
+
* const { data, error } = await client.auth.getOAuthLogoutUrl('google')
|
|
961
|
+
* if (!error && data.redirect_url) {
|
|
962
|
+
* // Redirect user to complete logout at provider
|
|
963
|
+
* window.location.href = data.redirect_url
|
|
964
|
+
* }
|
|
965
|
+
* ```
|
|
966
|
+
*/
|
|
967
|
+
async getOAuthLogoutUrl(provider, options) {
|
|
968
|
+
return wrapAsync(async () => {
|
|
969
|
+
const response = await this.fetch.post(
|
|
970
|
+
`/api/v1/auth/oauth/${provider}/logout`,
|
|
971
|
+
options || {}
|
|
972
|
+
);
|
|
973
|
+
this.clearSession();
|
|
974
|
+
return response;
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* Sign out with OAuth provider logout
|
|
979
|
+
* Revokes tokens at the OAuth provider and optionally redirects for OIDC logout
|
|
980
|
+
* @param provider - OAuth provider name (e.g., 'google', 'github')
|
|
981
|
+
* @param options - Optional logout configuration
|
|
982
|
+
* @returns Promise with OAuth logout response
|
|
983
|
+
*
|
|
984
|
+
* @example
|
|
985
|
+
* ```typescript
|
|
986
|
+
* // This will revoke tokens and redirect to provider's logout page if supported
|
|
987
|
+
* await client.auth.signOutWithOAuth('google', {
|
|
988
|
+
* redirect_url: 'https://myapp.com/logged-out'
|
|
989
|
+
* })
|
|
990
|
+
* ```
|
|
991
|
+
*/
|
|
992
|
+
async signOutWithOAuth(provider, options) {
|
|
993
|
+
return wrapAsync(async () => {
|
|
994
|
+
const result = await this.getOAuthLogoutUrl(provider, options);
|
|
995
|
+
if (result.error) {
|
|
996
|
+
throw result.error;
|
|
997
|
+
}
|
|
998
|
+
if (result.data.requires_redirect && result.data.redirect_url && typeof window !== "undefined") {
|
|
999
|
+
window.location.href = result.data.redirect_url;
|
|
1000
|
+
}
|
|
1001
|
+
return result.data;
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
951
1004
|
/**
|
|
952
1005
|
* Sign in with OTP (One-Time Password) - Supabase-compatible
|
|
953
1006
|
* Sends a one-time password via email or SMS for passwordless authentication
|