-
Notifications
You must be signed in to change notification settings - Fork 68
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
refactor!: replace oidc-client-js with oidc-client-ts #860
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import React, { FC, useState, useEffect, useRef, PropsWithChildren } from 'react'; | ||
import { UserManager, User } from 'oidc-client'; | ||
import { UserManager, User } from 'oidc-client-ts'; | ||
import { | ||
Location, | ||
AuthProviderProps, | ||
|
@@ -50,10 +50,10 @@ export const initUserManager = (props: AuthProviderProps): UserManager => { | |
popupWindowTarget, | ||
} = props; | ||
return new UserManager({ | ||
authority, | ||
client_id: clientId, | ||
authority: authority || '', | ||
client_id: clientId || '', | ||
client_secret: clientSecret, | ||
redirect_uri: redirectUri, | ||
redirect_uri: redirectUri || '', | ||
silent_redirect_uri: silentRedirectUri || redirectUri, | ||
post_logout_redirect_uri: postLogoutRedirectUri || redirectUri, | ||
response_type: responseType || 'code', | ||
|
@@ -107,7 +107,7 @@ export const AuthProvider: FC<PropsWithChildren<AuthProviderProps>> = ({ | |
* Check if the user is returning back from OIDC. | ||
*/ | ||
if (hasCodeInUrl(location)) { | ||
const user = await userManager.signinCallback(); | ||
const user: any = await userManager.signinCallback(); | ||
setUserData(user); | ||
setIsLoading(false); | ||
onSignIn && onSignIn(user); | ||
|
@@ -142,7 +142,7 @@ export const AuthProvider: FC<PropsWithChildren<AuthProviderProps>> = ({ | |
return ( | ||
<AuthContext.Provider | ||
value={{ | ||
signIn: async (args: unknown): Promise<void> => { | ||
signIn: async (args: any): Promise<void> => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we sure we want to use |
||
await userManager.signinRedirect(args); | ||
}, | ||
signInPopup: async (): Promise<void> => { | ||
|
@@ -152,7 +152,7 @@ export const AuthProvider: FC<PropsWithChildren<AuthProviderProps>> = ({ | |
await userManager!.removeUser(); | ||
await signOutHooks(); | ||
}, | ||
signOutRedirect: async (args?: unknown): Promise<void> => { | ||
signOutRedirect: async (args?: any): Promise<void> => { | ||
await userManager!.signoutRedirect(args); | ||
await signOutHooks(); | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { UserManager, User } from 'oidc-client'; | ||
import {UserManager, User, PopupWindowFeatures} from 'oidc-client-ts'; | ||
export interface Location { | ||
search: string; | ||
hash: string; | ||
|
@@ -25,7 +25,7 @@ export interface AuthProviderSignOutProps { | |
|
||
export interface AuthProviderProps { | ||
/** | ||
* See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details. | ||
* See [UserManager](https://github.com/authts/oidc-client-ts) for more details. | ||
*/ | ||
userManager?: UserManager; | ||
/** | ||
|
@@ -87,7 +87,7 @@ export interface AuthProviderProps { | |
* | ||
* defaults to 'location=no,toolbar=no,width=500,height=500,left=100,top=100' | ||
*/ | ||
popupWindowFeatures?: string; | ||
popupWindowFeatures?: PopupWindowFeatures; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a union now? |
||
/** | ||
* The URL for the page containing the call to signinPopupCallback to handle the callback from the OIDC/OAuth2 | ||
* | ||
|
@@ -134,11 +134,11 @@ export interface AuthContextProps { | |
*/ | ||
signOutRedirect: (args?: unknown) => Promise<void>; | ||
/** | ||
* See [UserManager](https://github.com/IdentityModel/oidc-client-js/wiki#usermanager) for more details. | ||
* See [UserManager](https://authts.github.io/oidc-client-ts/classes/UserManager.html) for more details. | ||
*/ | ||
userManager: UserManager; | ||
/** | ||
* See [User](https://github.com/IdentityModel/oidc-client-js/wiki#user) for more details. | ||
* See [User](https://authts.github.io/oidc-client-ts/classes/User.html) for more details. | ||
*/ | ||
userData?: User | null; | ||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these being defaulted to an empty string? It's been a while since I worked with this code base, so I'm a bit rusty 😅