@@ -22,11 +22,14 @@ type OidcUserInfo = {
2222 name ?: string ;
2323 given_name ?: string ;
2424 family_name ?: string ;
25+ // following is not standard, it is just for ProConnect
26+ usual_name ?: string ;
2527} ;
2628
2729export interface OidcClient {
2830 clientId : string ;
2931 redirectUri : string ;
32+ scope : string ;
3033 getAuthorizationEndpoint ( ) : string ;
3134 exchangeCodeForTokens ( code : string ) : Promise < {
3235 access_token : string ;
@@ -39,12 +42,23 @@ export interface OidcClient {
3942 logout ( idToken : string | null ) : Promise < string > ;
4043}
4144
45+ const standardOidcScope = [ "openid" , "email" , "profile" ] ;
46+
47+ const getScope = ( oidcIssuerUri : string ) : string => {
48+ if ( oidcIssuerUri . includes ( "agentconnect" ) || oidcIssuerUri . includes ( "proconnect" ) )
49+ return [ ...standardOidcScope , "given_name" , "usual_name" ] . join ( " " ) ;
50+ return standardOidcScope . join ( " " ) ;
51+ } ;
52+
4253export class HttpOidcClient implements OidcClient {
4354 #config! : OidcConfiguration ;
4455 #oidcParams: OidcParams ;
4556
57+ public scope : string ;
58+
4659 private constructor ( oidcParams : OidcParams ) {
4760 this . #oidcParams = oidcParams ;
61+ this . scope = getScope ( oidcParams . issuerUri ) ;
4862 }
4963
5064 static async create ( oidcParams : OidcParams ) : Promise < HttpOidcClient > {
@@ -123,8 +137,6 @@ export class HttpOidcClient implements OidcClient {
123137
124138 const userInfoAsString = responseBody . startsWith ( "ey" ) ? atob ( responseBody . split ( "." ) [ 1 ] ) : responseBody ;
125139
126- console . log ( "\n \n userInfoAsString : " , userInfoAsString ) ;
127-
128140 return JSON . parse ( userInfoAsString ) ;
129141 }
130142
@@ -152,9 +164,11 @@ export class TestOidcClient implements OidcClient {
152164 #config: OidcConfiguration ;
153165 #oidcParams: OidcParams ;
154166 #calls: TestOidcClientCall [ ] = [ ] ;
167+ scope : string ;
155168
156169 constructor ( oidcParams : OidcParams ) {
157170 this . #oidcParams = oidcParams ;
171+ this . scope = getScope ( oidcParams . issuerUri ) ;
158172 this . #config = {
159173 authorization_endpoint : `${ oidcParams . issuerUri } /auth` ,
160174 token_endpoint : `${ oidcParams . issuerUri } /token` ,
0 commit comments