Skip to content

Commit

Permalink
Pass generic for getToken argument to AuthImplementation and AuthCont…
Browse files Browse the repository at this point in the history
…extInterface
  • Loading branch information
Philzen committed Jan 22, 2025
1 parent 231e1f9 commit a7773ab
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 2 deletions.
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
2 changes: 2 additions & 0 deletions packages/auth/src/AuthProvider/useForgotPassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const useForgotPassword = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand All @@ -26,6 +27,7 @@ export const useForgotPassword = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand Down
2 changes: 2 additions & 0 deletions packages/auth/src/AuthProvider/useLogIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const useLogIn = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand All @@ -31,6 +32,7 @@ export const useLogIn = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand Down
2 changes: 2 additions & 0 deletions packages/auth/src/AuthProvider/useLogOut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const useLogOut = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand All @@ -28,6 +29,7 @@ export const useLogOut = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand Down
2 changes: 2 additions & 0 deletions packages/auth/src/AuthProvider/useResetPassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const useResetPassword = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand All @@ -26,6 +27,7 @@ export const useResetPassword = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand Down
2 changes: 2 additions & 0 deletions packages/auth/src/AuthProvider/useSignUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const useSignUp = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand All @@ -30,6 +31,7 @@ export const useSignUp = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand Down
2 changes: 2 additions & 0 deletions packages/auth/src/AuthProvider/useValidateResetToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const useValidateResetToken = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
Expand All @@ -26,6 +27,7 @@ export const useValidateResetToken = <
TLogOut,
TSignUpOptions,
TSignUp,
TGetTokenOptions,
TForgotPassword,
TResetPasswordOptions,
TResetPassword,
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

0 comments on commit a7773ab

Please sign in to comment.