Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS] [Azure] [Clerk] Allow getToken(options?) argument #11918

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/auth/src/AuthContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface AuthContextInterface<
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand Down Expand Up @@ -51,7 +52,7 @@ export interface AuthContextInterface<
* Clients should always return null or string
* It is expected that they catch any errors internally
*/
getToken(): Promise<null | string>
getToken(options?: TGetTokenOptions): Promise<null | string>
/**
* Fetches the "currentUser" from the api side,
* but does not update the current user state.
Expand Down Expand Up @@ -89,6 +90,7 @@ export function createAuthContext<
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand All @@ -104,6 +106,7 @@ export function createAuthContext<
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand Down
3 changes: 2 additions & 1 deletion packages/auth/src/AuthImplementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface AuthImplementation<
TLogOut = unknown,
TSignUpOptions = unknown,
TSignUp = unknown,
TGetTokenOptions = unknown,
TForgotPassword = unknown,
TResetPasswordOptions = unknown,
TResetPassword = unknown,
Expand All @@ -20,7 +21,7 @@ export interface AuthImplementation<
login(options?: TLogInOptions): Promise<TLogIn>
logout(options?: TLogOutOptions): Promise<TLogOut>
signup(options?: TSignUpOptions): Promise<TSignUp>
getToken(): Promise<string | null>
getToken(options?: TGetTokenOptions): Promise<string | null>
forgotPassword?(username: string): Promise<TForgotPassword>
resetPassword?(options?: TResetPasswordOptions): Promise<TResetPassword>
validateResetToken?(token: string | null): Promise<TValidateResetToken>
Expand Down
3 changes: 3 additions & 0 deletions packages/auth/src/AuthProvider/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function createAuthProvider<
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand All @@ -46,6 +47,7 @@ export function createAuthProvider<
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand All @@ -63,6 +65,7 @@ export function createAuthProvider<
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand Down
12 changes: 3 additions & 9 deletions packages/auth/src/AuthProvider/useForgotPassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ export const useForgotPassword = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
TValidateResetToken,
TClient,
>(
authImplementation: AuthImplementation<
TUser,
Expand All @@ -26,11 +23,8 @@ export const useForgotPassword = <
TLogOut,
TSignUpOptions,
TSignUp,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
TValidateResetToken,
TClient
TGetTokenOptions,
TForgotPassword
>,
) => {
return useCallback(
Expand Down
27 changes: 2 additions & 25 deletions packages/auth/src/AuthProvider/useLogIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,12 @@ import { spaDefaultAuthProviderState } from './AuthProviderState.js'
import type { useCurrentUser } from './useCurrentUser.js'
import { useReauthenticate } from './useReauthenticate.js'

export const useLogIn = <
TUser,
TRestoreAuth,
TLogInOptions,
TLogIn,
TLogOutOptions,
TLogOut,
TSignUpOptions,
TSignUp,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
TValidateResetToken,
TClient,
>(
export const useLogIn = <TUser, TRestoreAuth, TLogInOptions, TLogIn>(
authImplementation: AuthImplementation<
TUser,
TRestoreAuth,
TLogInOptions,
TLogIn,
TLogOutOptions,
TLogOut,
TSignUpOptions,
TSignUp,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
TValidateResetToken,
TClient
TLogIn
>,
setAuthProviderState: React.Dispatch<
React.SetStateAction<AuthProviderState<TUser>>
Expand Down
16 changes: 1 addition & 15 deletions packages/auth/src/AuthProvider/useLogOut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,14 @@ export const useLogOut = <
TLogIn,
TLogOutOptions,
TLogOut,
TSignUpOptions,
TSignUp,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
TValidateResetToken,
TClient,
>(
authImplementation: AuthImplementation<
TUser,
TRestoreAuth,
TLogInOptions,
TLogIn,
TLogOutOptions,
TLogOut,
TSignUpOptions,
TSignUp,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
TValidateResetToken,
TClient
TLogOut
>,
setAuthProviderState: React.Dispatch<
React.SetStateAction<AuthProviderState<TUser>>
Expand Down
8 changes: 3 additions & 5 deletions packages/auth/src/AuthProvider/useResetPassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ export const useResetPassword = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
TValidateResetToken,
TClient,
>(
authImplementation: AuthImplementation<
TUser,
Expand All @@ -26,11 +25,10 @@ export const useResetPassword = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
TValidateResetToken,
TClient
TResetPassword
>,
) => {
return useCallback(
Expand Down
12 changes: 1 addition & 11 deletions packages/auth/src/AuthProvider/useSignUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ export const useSignUp = <
TLogOut,
TSignUpOptions,
TSignUp,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
TValidateResetToken,
TClient,
>(
authImplementation: AuthImplementation<
TUser,
Expand All @@ -29,12 +24,7 @@ export const useSignUp = <
TLogOutOptions,
TLogOut,
TSignUpOptions,
TSignUp,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
TValidateResetToken,
TClient
TSignUp
>,
setAuthProviderState: React.Dispatch<
React.SetStateAction<AuthProviderState<TUser>>
Expand Down
6 changes: 3 additions & 3 deletions packages/auth/src/AuthProvider/useValidateResetToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export const useValidateResetToken = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
TValidateResetToken,
TClient,
>(
authImplementation: AuthImplementation<
TUser,
Expand All @@ -26,11 +26,11 @@ export const useValidateResetToken = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
TValidateResetToken,
TClient
TValidateResetToken
>,
) => {
return useCallback(
Expand Down
3 changes: 3 additions & 0 deletions packages/auth/src/authFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function createAuthentication<
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand All @@ -35,6 +36,7 @@ export function createAuthentication<
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand All @@ -56,6 +58,7 @@ export function createAuthentication<
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand Down
5 changes: 5 additions & 0 deletions packages/auth/src/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function createUseAuth<
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand All @@ -25,6 +26,7 @@ export function createUseAuth<
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand All @@ -42,6 +44,7 @@ export function createUseAuth<
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand Down Expand Up @@ -72,6 +75,7 @@ export function useNoAuth(): AuthContextInterface<
void,
void,
void,
void,
undefined
> {
return {
Expand Down Expand Up @@ -107,5 +111,6 @@ export type UseAuth = () => AuthContextInterface<
unknown,
unknown,
unknown,
unknown,
unknown
>
1 change: 1 addition & 0 deletions packages/router/src/__tests__/pageLoadingContext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type UnknownAuthContextInterface = AuthContextInterface<
unknown,
unknown,
unknown,
unknown,
unknown
>

Expand Down
1 change: 1 addition & 0 deletions packages/router/src/__tests__/router.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type UnknownAuthContextInterface = AuthContextInterface<
unknown,
unknown,
unknown,
unknown,
unknown
>

Expand Down
1 change: 1 addition & 0 deletions packages/router/src/router-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type UseAuth = () => AuthContextInterface<
unknown,
unknown,
unknown,
unknown,
unknown
>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type UnknownAuthContext = AuthContextInterface<
unknown,
unknown,
unknown,
unknown,
unknown
>

Expand Down
Loading