11import { Provider } from '@angular/core' ;
22import { TranslocoService } from '@jsverse/transloco' ;
3+ import { FilesService } from '@nestjs-mod-sso/files-angular' ;
34import {
4- SsoRestService ,
5+ RestSdkAngularService ,
56 SsoUserDtoInterface ,
67 TokensResponseInterface ,
78} from '@nestjs-mod-sso/rest-sdk-angular' ;
8- import { FilesService } from '@nestjs-mod-sso/files-angular' ;
99import {
1010 FingerprintService ,
1111 OAuthProvider ,
@@ -28,16 +28,14 @@ import { catchError, map, mergeMap, Observable, of } from 'rxjs';
2828
2929export class SsoIntegrationConfiguration implements SsoConfiguration {
3030 constructor (
31- private readonly ssoRestService : SsoRestService ,
31+ private readonly restSdkAngularService : RestSdkAngularService ,
3232 private readonly filesService : FilesService ,
3333 private readonly translocoService : TranslocoService ,
3434 private readonly tokensService : TokensService ,
3535 private readonly ssoActiveProjectService : SsoActiveProjectService ,
3636 private readonly fingerprintService : FingerprintService ,
3737 private readonly nzMessageService : NzMessageService
38- ) {
39- ssoRestService . configuration . withCredentials = true ;
40- }
38+ ) { }
4139
4240 getAuthorizationHeaders ( ) : Record < string , string > {
4341 const lang = this . translocoService . getActiveLang ( ) ;
@@ -58,7 +56,9 @@ export class SsoIntegrationConfiguration implements SsoConfiguration {
5856 }
5957
6058 oAuthProviders ( ) : Observable < OAuthProvider [ ] > {
61- return this . ssoRestService . ssoOAuthControllerOauthProviders ( ) ;
59+ return this . restSdkAngularService
60+ . getSsoApi ( )
61+ . ssoOAuthControllerOauthProviders ( ) ;
6262 }
6363
6464 oAuthVerification ( {
@@ -67,7 +67,8 @@ export class SsoIntegrationConfiguration implements SsoConfiguration {
6767 } : OAuthVerificationInput ) : Observable < SsoUserAndTokens > {
6868 return this . fingerprintService . getFingerprint ( ) . pipe (
6969 mergeMap ( ( fingerprint ) =>
70- this . ssoRestService
70+ this . restSdkAngularService
71+ . getSsoApi ( )
7172 . ssoOAuthControllerOauthVerification ( {
7273 fingerprint,
7374 verificationCode,
@@ -84,7 +85,8 @@ export class SsoIntegrationConfiguration implements SsoConfiguration {
8485
8586 logout ( ) : Observable < void | null > {
8687 const refreshToken = this . tokensService . getRefreshToken ( ) ;
87- return this . ssoRestService
88+ return this . restSdkAngularService
89+ . getSsoApi ( )
8890 . ssoControllerSignOut (
8991 refreshToken
9092 ? {
@@ -100,11 +102,14 @@ export class SsoIntegrationConfiguration implements SsoConfiguration {
100102 }
101103
102104 getProfile ( ) : Observable < SsoUser | undefined > {
103- return this . ssoRestService . ssoControllerProfile ( ) . pipe (
104- map ( ( result ) => {
105- return this . mapToSsoUser ( result ) ;
106- } )
107- ) ;
105+ return this . restSdkAngularService
106+ . getSsoApi ( )
107+ . ssoControllerProfile ( )
108+ . pipe (
109+ map ( ( result ) => {
110+ return this . mapToSsoUser ( result ) ;
111+ } )
112+ ) ;
108113 }
109114
110115 private mapToSsoTokens ( tokens : TokensResponseInterface ) {
@@ -149,19 +154,23 @@ export class SsoIntegrationConfiguration implements SsoConfiguration {
149154 return of ( undefined ) ;
150155 } ) ,
151156 mergeMap ( ( picture ) => {
152- return this . ssoRestService . ssoControllerUpdateProfile ( {
153- birthdate : data . birthdate ,
154- firstname : data . givenName ,
155- gender : data . gender ,
156- lastname : data . familyName ,
157- picture,
158- password : data . newPassword ,
159- confirmPassword : data . confirmNewPassword ,
160- oldPassword : data . oldPassword ,
161- timezone : data . timezone ,
162- } ) ;
157+ return this . restSdkAngularService
158+ . getSsoApi ( )
159+ . ssoControllerUpdateProfile ( {
160+ birthdate : data . birthdate ,
161+ firstname : data . givenName ,
162+ gender : data . gender ,
163+ lastname : data . familyName ,
164+ picture,
165+ password : data . newPassword ,
166+ confirmPassword : data . confirmNewPassword ,
167+ oldPassword : data . oldPassword ,
168+ timezone : data . timezone ,
169+ } ) ;
163170 } ) ,
164- mergeMap ( ( ) => this . ssoRestService . ssoControllerProfile ( ) ) ,
171+ mergeMap ( ( ) =>
172+ this . restSdkAngularService . getSsoApi ( ) . ssoControllerProfile ( )
173+ ) ,
165174 mergeMap ( ( newData ) => {
166175 if (
167176 oldData ?. picture &&
@@ -182,7 +191,8 @@ export class SsoIntegrationConfiguration implements SsoConfiguration {
182191 const refreshToken = this . tokensService . getRefreshToken ( ) ;
183192 return this . fingerprintService . getFingerprint ( ) . pipe (
184193 mergeMap ( ( fingerprint ) =>
185- this . ssoRestService
194+ this . restSdkAngularService
195+ . getSsoApi ( )
186196 . ssoControllerRefreshTokens ( {
187197 ...( refreshToken
188198 ? {
@@ -214,7 +224,8 @@ export class SsoIntegrationConfiguration implements SsoConfiguration {
214224 }
215225 return this . fingerprintService . getFingerprint ( ) . pipe (
216226 mergeMap ( ( fingerprint ) =>
217- this . ssoRestService
227+ this . restSdkAngularService
228+ . getSsoApi ( )
218229 . ssoControllerSignUp ( {
219230 email,
220231 fingerprint,
@@ -239,7 +250,8 @@ export class SsoIntegrationConfiguration implements SsoConfiguration {
239250 }
240251 return this . fingerprintService . getFingerprint ( ) . pipe (
241252 mergeMap ( ( fingerprint ) =>
242- this . ssoRestService
253+ this . restSdkAngularService
254+ . getSsoApi ( )
243255 . ssoControllerSignIn ( {
244256 email,
245257 fingerprint,
@@ -262,7 +274,8 @@ export class SsoIntegrationConfiguration implements SsoConfiguration {
262274 }
263275 return this . fingerprintService . getFingerprint ( ) . pipe (
264276 mergeMap ( ( fingerprint ) =>
265- this . ssoRestService
277+ this . restSdkAngularService
278+ . getSsoApi ( )
266279 . ssoControllerCompleteSignUp ( {
267280 code,
268281 fingerprint,
@@ -292,7 +305,8 @@ export class SsoIntegrationConfiguration implements SsoConfiguration {
292305 }
293306 return this . fingerprintService . getFingerprint ( ) . pipe (
294307 mergeMap ( ( fingerprint ) =>
295- this . ssoRestService
308+ this . restSdkAngularService
309+ . getSsoApi ( )
296310 . ssoControllerCompleteForgotPassword ( {
297311 password,
298312 confirmPassword,
@@ -314,7 +328,8 @@ export class SsoIntegrationConfiguration implements SsoConfiguration {
314328 if ( ! email ) {
315329 throw new Error ( 'email not set' ) ;
316330 }
317- return this . ssoRestService
331+ return this . restSdkAngularService
332+ . getSsoApi ( )
318333 . ssoControllerForgotPassword ( {
319334 email,
320335 redirectUri,
@@ -328,7 +343,7 @@ export function provideSsoConfiguration(): Provider {
328343 provide : SSO_CONFIGURATION_TOKEN ,
329344 useClass : SsoIntegrationConfiguration ,
330345 deps : [
331- SsoRestService ,
346+ RestSdkAngularService ,
332347 FilesService ,
333348 TranslocoService ,
334349 TokensService ,
0 commit comments