@kolektor/nucleus-identity 0.0.8-pre.5676 → 0.0.9-pre.5874

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/{esm2015/kolektor-nucleus-identity.js → esm2020/kolektor-nucleus-identity.mjs} +0 -0
  2. package/{esm2015/lib/models/client-registration.js → esm2020/lib/models/client-registration.mjs} +0 -0
  3. package/{esm2015/lib/models/device-code.js → esm2020/lib/models/device-code.mjs} +0 -0
  4. package/{esm2015/lib/models/identity.js → esm2020/lib/models/identity.mjs} +0 -0
  5. package/{esm2015/lib/models/otp.js → esm2020/lib/models/otp.mjs} +0 -0
  6. package/{esm2015/lib/models/service-principal.js → esm2020/lib/models/service-principal.mjs} +0 -0
  7. package/{esm2015/lib/nucleus-identity-config.js → esm2020/lib/nucleus-identity-config.mjs} +0 -0
  8. package/{esm2015/lib/nucleus-identity.module.js → esm2020/lib/nucleus-identity.module.mjs} +4 -4
  9. package/esm2020/lib/nucleus-identity.service.mjs +338 -0
  10. package/esm2020/lib/nucleus-token-interceptor.service.mjs +64 -0
  11. package/{esm2015/lib/utils/angular-requestor.js → esm2020/lib/utils/angular-requestor.mjs} +5 -6
  12. package/{esm2015/lib/utils/authorization-service-configuration.js → esm2020/lib/utils/authorization-service-configuration.mjs} +0 -0
  13. package/{esm2015/lib/utils/location.service.js → esm2020/lib/utils/location.service.mjs} +3 -3
  14. package/{esm2015/lib/utils/nucleus-authorization-notifier.js → esm2020/lib/utils/nucleus-authorization-notifier.mjs} +0 -0
  15. package/{esm2015/lib/utils/nucleus-crypto.js → esm2020/lib/utils/nucleus-crypto.mjs} +0 -0
  16. package/esm2020/lib/utils/oidc-configuration.service.mjs +90 -0
  17. package/esm2020/lib/utils/secrets-store.mjs +117 -0
  18. package/esm2020/lib/utils/token-client.mjs +140 -0
  19. package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
  20. package/fesm2015/{kolektor-nucleus-identity.js → kolektor-nucleus-identity.mjs} +177 -166
  21. package/fesm2015/kolektor-nucleus-identity.mjs.map +1 -0
  22. package/fesm2020/kolektor-nucleus-identity.mjs +1054 -0
  23. package/fesm2020/kolektor-nucleus-identity.mjs.map +1 -0
  24. package/lib/nucleus-identity.service.d.ts +3 -2
  25. package/lib/utils/secrets-store.d.ts +3 -0
  26. package/package.json +22 -9
  27. package/bundles/kolektor-nucleus-identity.umd.js +0 -1910
  28. package/bundles/kolektor-nucleus-identity.umd.js.map +0 -1
  29. package/esm2015/lib/nucleus-identity.service.js +0 -385
  30. package/esm2015/lib/nucleus-token-interceptor.service.js +0 -66
  31. package/esm2015/lib/utils/oidc-configuration.service.js +0 -95
  32. package/esm2015/lib/utils/secrets-store.js +0 -113
  33. package/esm2015/lib/utils/token-client.js +0 -159
  34. package/fesm2015/kolektor-nucleus-identity.js.map +0 -1
@@ -2,24 +2,16 @@ import * as i0 from '@angular/core';
2
2
  import { Injectable, NgModule } from '@angular/core';
3
3
  import * as i1$1 from '@angular/common/http';
4
4
  import { HttpErrorResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
5
- import { from, throwError } from 'rxjs';
5
+ import { lastValueFrom, from, throwError } from 'rxjs';
6
+ import { mergeMap, catchError } from 'rxjs/operators';
6
7
  import { __awaiter } from 'tslib';
7
- import { AppAuthError, AuthorizationNotifier, TokenResponse, Requestor, AuthorizationServiceConfiguration, JQueryRequestor, nowInSeconds, BaseTokenRequestHandler, BasicQueryStringUtils, TokenRequest, GRANT_TYPE_AUTHORIZATION_CODE, GRANT_TYPE_REFRESH_TOKEN, LocalStorageBackend, RedirectRequestHandler, AuthorizationRequest } from '@openid/appauth';
8
+ import { AppAuthError, AuthorizationNotifier, TokenResponse, AuthorizationServiceConfiguration, JQueryRequestor, Requestor, nowInSeconds, BaseTokenRequestHandler, BasicQueryStringUtils, TokenRequest, GRANT_TYPE_AUTHORIZATION_CODE, GRANT_TYPE_REFRESH_TOKEN, LocalStorageBackend, RedirectRequestHandler, AuthorizationRequest } from '@openid/appauth';
8
9
  import { App } from '@capacitor/app';
9
10
  import { Browser } from '@capacitor/browser';
10
11
  import { Device } from '@capacitor/device';
11
12
  import * as base64 from 'base64-js';
12
- import * as i1 from '@kolektor/nucleus-common';
13
13
  import { SecureStoragePlugin } from 'capacitor-secure-storage-plugin';
14
- import { mergeMap, catchError } from 'rxjs/operators';
15
-
16
- class NucleusIdentityConfig {
17
- constructor() {
18
- this.authority = null;
19
- this.httpInterceptorUrls = [];
20
- this.automaticLoginOnHttp401 = false;
21
- }
22
- }
14
+ import * as i1 from '@kolektor/nucleus-common';
23
15
 
24
16
  const CHARSET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
25
17
  class NucleusCrypto {
@@ -87,73 +79,6 @@ class NucleusCrypto {
87
79
  }
88
80
  }
89
81
 
90
- class LocationService {
91
- constructor(appService) {
92
- this.appService = appService;
93
- }
94
- get hash() {
95
- return window.location.hash;
96
- }
97
- set hash(v) {
98
- window.location.hash = v;
99
- }
100
- get host() {
101
- return window.location.host;
102
- }
103
- set host(v) {
104
- window.location.host = v;
105
- }
106
- get origin() {
107
- return window.location.origin;
108
- }
109
- get hostname() {
110
- return window.location.hostname;
111
- }
112
- set hostname(v) {
113
- window.location.hostname = v;
114
- }
115
- get pathname() {
116
- return window.location.pathname;
117
- }
118
- set pathname(v) {
119
- window.location.pathname = v;
120
- }
121
- get port() {
122
- return window.location.port;
123
- }
124
- set port(v) {
125
- window.location.port = v;
126
- }
127
- get protocol() {
128
- return window.location.protocol;
129
- }
130
- set protocol(v) {
131
- window.location.protocol = v;
132
- }
133
- get search() {
134
- return window.location.search;
135
- }
136
- set search(v) {
137
- window.location.search = v;
138
- }
139
- assign(url) {
140
- if (this.appService.isNative) {
141
- Browser.open({ url });
142
- }
143
- else {
144
- window.location.assign(url);
145
- }
146
- }
147
- }
148
- LocationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: LocationService, deps: [{ token: i1.NucleusAppService }], target: i0.ɵɵFactoryTarget.Injectable });
149
- LocationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: LocationService, providedIn: 'root' });
150
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: LocationService, decorators: [{
151
- type: Injectable,
152
- args: [{
153
- providedIn: 'root'
154
- }]
155
- }], ctorParameters: function () { return [{ type: i1.NucleusAppService }]; } });
156
-
157
82
  class NucleusAuthorizationNotifier extends AuthorizationNotifier {
158
83
  constructor() {
159
84
  super();
@@ -219,8 +144,13 @@ class SecretsStore {
219
144
  constructor(clientId) {
220
145
  this._tokens = {};
221
146
  this._identities = {};
222
- this._tokenStorageKeyPrefix = `Nucleus.Identity.${clientId}`; // do not change this or login fith existing refresh tokens will fail
223
- this._servicePrincipalKey = `Nucleus.Identity.${clientId}.SvcP`;
147
+ // this specify which identity id is used by default, when If id is not specified in getToken or getIdentity
148
+ this._defaultIdentityId = null;
149
+ this._defaultIdentityIdStorageKey = null;
150
+ this._tokenStorageKeyPrefix = `Nucleus.Identity.${clientId}`; // do not change this or login with existing tokens will fail
151
+ this._servicePrincipalKey = `${this._tokenStorageKeyPrefix}.SvcP`;
152
+ this._defaultIdentityIdStorageKey = `${this._tokenStorageKeyPrefix}.IdId`;
153
+ this._defaultIdentityId = localStorage.getItem(this._defaultIdentityIdStorageKey);
224
154
  }
225
155
  removeServicePrincipal() {
226
156
  this._servicePrincipal = null;
@@ -247,6 +177,15 @@ class SecretsStore {
247
177
  const key = this.getTokenKey(id);
248
178
  return this._identities[key];
249
179
  }
180
+ setDefaultIdentityId(id) {
181
+ this._defaultIdentityId = id;
182
+ if (this._defaultIdentityId) {
183
+ localStorage.setItem(this._defaultIdentityIdStorageKey, this._defaultIdentityId);
184
+ }
185
+ else {
186
+ localStorage.removeItem(this._defaultIdentityIdStorageKey);
187
+ }
188
+ }
250
189
  getToken(id = null) {
251
190
  return __awaiter(this, void 0, void 0, function* () {
252
191
  const key = this.getTokenKey(id);
@@ -297,6 +236,9 @@ class SecretsStore {
297
236
  });
298
237
  }
299
238
  getTokenKey(id = null) {
239
+ if (!id) {
240
+ id = this._defaultIdentityId;
241
+ }
300
242
  return id ? `${this._tokenStorageKeyPrefix}.${id}` : this._tokenStorageKeyPrefix;
301
243
  }
302
244
  clear(key) {
@@ -323,6 +265,111 @@ class SecretsStore {
323
265
  }
324
266
  }
325
267
 
268
+ class ServicePrincipal {
269
+ }
270
+ class ServicePrincipalRegistrationStatus {
271
+ constructor(servicePrincipal) {
272
+ this.isRegistered = false;
273
+ if (servicePrincipal) {
274
+ this.isRegistered = true;
275
+ this.id = servicePrincipal.id;
276
+ this.expiresAt = servicePrincipal.expiresAt;
277
+ }
278
+ }
279
+ get isExpired() {
280
+ return false;
281
+ }
282
+ }
283
+
284
+ class LocationService {
285
+ constructor(appService) {
286
+ this.appService = appService;
287
+ }
288
+ get hash() {
289
+ return window.location.hash;
290
+ }
291
+ set hash(v) {
292
+ window.location.hash = v;
293
+ }
294
+ get host() {
295
+ return window.location.host;
296
+ }
297
+ set host(v) {
298
+ window.location.host = v;
299
+ }
300
+ get origin() {
301
+ return window.location.origin;
302
+ }
303
+ get hostname() {
304
+ return window.location.hostname;
305
+ }
306
+ set hostname(v) {
307
+ window.location.hostname = v;
308
+ }
309
+ get pathname() {
310
+ return window.location.pathname;
311
+ }
312
+ set pathname(v) {
313
+ window.location.pathname = v;
314
+ }
315
+ get port() {
316
+ return window.location.port;
317
+ }
318
+ set port(v) {
319
+ window.location.port = v;
320
+ }
321
+ get protocol() {
322
+ return window.location.protocol;
323
+ }
324
+ set protocol(v) {
325
+ window.location.protocol = v;
326
+ }
327
+ get search() {
328
+ return window.location.search;
329
+ }
330
+ set search(v) {
331
+ window.location.search = v;
332
+ }
333
+ assign(url) {
334
+ if (this.appService.isNative) {
335
+ Browser.open({ url });
336
+ }
337
+ else {
338
+ window.location.assign(url);
339
+ }
340
+ }
341
+ }
342
+ LocationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: LocationService, deps: [{ token: i1.NucleusAppService }], target: i0.ɵɵFactoryTarget.Injectable });
343
+ LocationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: LocationService, providedIn: 'root' });
344
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: LocationService, decorators: [{
345
+ type: Injectable,
346
+ args: [{
347
+ providedIn: 'root'
348
+ }]
349
+ }], ctorParameters: function () { return [{ type: i1.NucleusAppService }]; } });
350
+
351
+ const WELL_KNOWN_PATH = '.well-known';
352
+ const OPENID_CONFIGURATION = 'openid-configuration';
353
+ class NucleusAuthorizationServiceConfiguration extends AuthorizationServiceConfiguration {
354
+ constructor(request) {
355
+ super(request);
356
+ this.deviceAuthorizationEndpoint = request.device_authorization_endpoint;
357
+ this.registrationEndpoint = request.registration_endpoint;
358
+ }
359
+ static fetchFromIssuer(openIdIssuerUrl, requestor) {
360
+ const fullUrl = `${openIdIssuerUrl}/${WELL_KNOWN_PATH}/${OPENID_CONFIGURATION}`;
361
+ const requestorToUse = requestor || new JQueryRequestor();
362
+ return requestorToUse
363
+ .xhr({ url: fullUrl, dataType: 'json', method: 'GET' })
364
+ .then(json => new NucleusAuthorizationServiceConfiguration(json));
365
+ }
366
+ toJson() {
367
+ const res = super.toJson();
368
+ res.device_authorization_endpoint = this.deviceAuthorizationEndpoint;
369
+ return res;
370
+ }
371
+ }
372
+
326
373
  class AngularRequestor extends Requestor {
327
374
  constructor(http) {
328
375
  super();
@@ -348,34 +395,20 @@ class AngularRequestor extends Requestor {
348
395
  });
349
396
  }
350
397
  }
351
- AngularRequestor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: AngularRequestor, deps: [{ token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
352
- AngularRequestor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: AngularRequestor, providedIn: 'root' });
353
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: AngularRequestor, decorators: [{
398
+ AngularRequestor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AngularRequestor, deps: [{ token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
399
+ AngularRequestor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AngularRequestor, providedIn: 'root' });
400
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AngularRequestor, decorators: [{
354
401
  type: Injectable,
355
402
  args: [{
356
403
  providedIn: 'root'
357
404
  }]
358
405
  }], ctorParameters: function () { return [{ type: i1$1.HttpClient }]; } });
359
406
 
360
- const WELL_KNOWN_PATH = '.well-known';
361
- const OPENID_CONFIGURATION = 'openid-configuration';
362
- class NucleusAuthorizationServiceConfiguration extends AuthorizationServiceConfiguration {
363
- constructor(request) {
364
- super(request);
365
- this.deviceAuthorizationEndpoint = request.device_authorization_endpoint;
366
- this.registrationEndpoint = request.registration_endpoint;
367
- }
368
- static fetchFromIssuer(openIdIssuerUrl, requestor) {
369
- const fullUrl = `${openIdIssuerUrl}/${WELL_KNOWN_PATH}/${OPENID_CONFIGURATION}`;
370
- const requestorToUse = requestor || new JQueryRequestor();
371
- return requestorToUse
372
- .xhr({ url: fullUrl, dataType: 'json', method: 'GET' })
373
- .then(json => new NucleusAuthorizationServiceConfiguration(json));
374
- }
375
- toJson() {
376
- const res = super.toJson();
377
- res.device_authorization_endpoint = this.deviceAuthorizationEndpoint;
378
- return res;
407
+ class NucleusIdentityConfig {
408
+ constructor() {
409
+ this.authority = null;
410
+ this.httpInterceptorUrls = [];
411
+ this.automaticLoginOnHttp401 = false;
379
412
  }
380
413
  }
381
414
 
@@ -455,9 +488,9 @@ class OidcConfigurationService {
455
488
  });
456
489
  }
457
490
  }
458
- OidcConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: OidcConfigurationService, deps: [{ token: AngularRequestor }, { token: NucleusIdentityConfig }, { token: i1.NucleusAppService }], target: i0.ɵɵFactoryTarget.Injectable });
459
- OidcConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: OidcConfigurationService, providedIn: 'root' });
460
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: OidcConfigurationService, decorators: [{
491
+ OidcConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OidcConfigurationService, deps: [{ token: AngularRequestor }, { token: NucleusIdentityConfig }, { token: i1.NucleusAppService }], target: i0.ɵɵFactoryTarget.Injectable });
492
+ OidcConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OidcConfigurationService, providedIn: 'root' });
493
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OidcConfigurationService, decorators: [{
461
494
  type: Injectable,
462
495
  args: [{
463
496
  providedIn: 'root'
@@ -630,31 +663,15 @@ class TokenClient {
630
663
  });
631
664
  }
632
665
  }
633
- TokenClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: TokenClient, deps: [{ token: AngularRequestor }, { token: OidcConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
634
- TokenClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: TokenClient, providedIn: 'root' });
635
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: TokenClient, decorators: [{
666
+ TokenClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TokenClient, deps: [{ token: AngularRequestor }, { token: OidcConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
667
+ TokenClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TokenClient, providedIn: 'root' });
668
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TokenClient, decorators: [{
636
669
  type: Injectable,
637
670
  args: [{
638
671
  providedIn: 'root'
639
672
  }]
640
673
  }], ctorParameters: function () { return [{ type: AngularRequestor }, { type: OidcConfigurationService }]; } });
641
674
 
642
- class ServicePrincipal {
643
- }
644
- class ServicePrincipalRegistrationStatus {
645
- constructor(servicePrincipal) {
646
- this.isRegistered = false;
647
- if (servicePrincipal) {
648
- this.isRegistered = true;
649
- this.id = servicePrincipal.id;
650
- this.expiresAt = servicePrincipal.expiresAt;
651
- }
652
- }
653
- get isExpired() {
654
- return false;
655
- }
656
- }
657
-
658
675
  class NucleusIdentityService {
659
676
  constructor(appService, location, http, config, tokenClient) {
660
677
  this.appService = appService;
@@ -701,6 +718,7 @@ class NucleusIdentityService {
701
718
  const request = this._authorizationNotifier.request;
702
719
  const response = this._authorizationNotifier.response;
703
720
  const res = yield this.tokenClient.getByAuthorizationCode(request.redirectUri, response.code, request.internal['code_verifier']);
721
+ this._store.setDefaultIdentityId(null);
704
722
  yield this._store.setToken(res);
705
723
  }
706
724
  else {
@@ -719,6 +737,7 @@ class NucleusIdentityService {
719
737
  const assertionToken = yield this.getServicePrincipalAccessToken();
720
738
  const scope = this.prepareScope(true, (_a = this.config) === null || _a === void 0 ? void 0 : _a.requestedScopes);
721
739
  const res = yield this.tokenClient.getBySecret(provider, secret, assertionToken, scope);
740
+ this._store.setDefaultIdentityId(null);
722
741
  yield this._store.setToken(res);
723
742
  });
724
743
  }
@@ -797,34 +816,40 @@ class NucleusIdentityService {
797
816
  }
798
817
  loginServicePrincipal() {
799
818
  return __awaiter(this, void 0, void 0, function* () {
800
- yield this.loginServicePrincipalInternal();
819
+ const sp = yield this._store.getServicePrincipal();
820
+ if (sp) {
821
+ const scope = this.prepareScope(false, this.config.servicePrincipalRequestedScopes);
822
+ const res = yield this.tokenClient.getByClientCredentials(sp.id, sp.secret, scope);
823
+ yield this._store.setToken(res, this._servicePrincipalTokenId);
824
+ return res;
825
+ }
826
+ else {
827
+ throw Error('Service principal is not registered!');
828
+ }
829
+ });
830
+ }
831
+ loginAsServicePrincipal() {
832
+ return __awaiter(this, void 0, void 0, function* () {
833
+ const token = yield this._store.getToken(this._servicePrincipalTokenId);
834
+ if (!token) {
835
+ yield this.loginServicePrincipal();
836
+ }
837
+ this._store.setDefaultIdentityId(this._servicePrincipalTokenId);
801
838
  });
802
839
  }
803
- /*
804
- public async loginAsServicePrincipal() {
805
- let token = await this._store.getToken(this._servicePrincipalTokenId);
806
- if (!token) {
807
- await this.loginServicePrincipal();
808
- }
809
- token = await this._store.getToken(this._servicePrincipalTokenId);
810
- // TODO: we have to distinguished that token is service principal so refresh token stuff is handled correctly.
811
- // We have to implement universal getAccessToken function that can handle all cases
812
- await this._store.setToken(token);
813
- }
814
- */
815
840
  getOtp(type, expiresIn = -1) {
816
841
  return __awaiter(this, void 0, void 0, function* () {
817
842
  let url = this.config.getServerUrl(`/otp/create?type=${type}`);
818
843
  if (expiresIn > 0) {
819
844
  url += `&expiresIn=${expiresIn}`;
820
845
  }
821
- return this.http.get(url).toPromise();
846
+ return lastValueFrom(this.http.get(url));
822
847
  });
823
848
  }
824
849
  getOtpStatus(id) {
825
850
  return __awaiter(this, void 0, void 0, function* () {
826
851
  const url = this.config.getServerUrl(`/otp/status/${id}`);
827
- return this.http.get(url).toPromise();
852
+ return lastValueFrom(this.http.get(url));
828
853
  });
829
854
  }
830
855
  getOtpUrl(redirectUrl, password) {
@@ -908,25 +933,11 @@ class NucleusIdentityService {
908
933
  extras: params,
909
934
  }, this._crypto, true);
910
935
  }
911
- loginServicePrincipalInternal() {
912
- return __awaiter(this, void 0, void 0, function* () {
913
- const sp = yield this._store.getServicePrincipal();
914
- if (sp) {
915
- const scope = this.prepareScope(false, this.config.servicePrincipalRequestedScopes);
916
- const res = yield this.tokenClient.getByClientCredentials(sp.id, sp.secret, scope);
917
- yield this._store.setToken(res, this._servicePrincipalTokenId);
918
- return res;
919
- }
920
- else {
921
- throw Error('Service principal is not registered!');
922
- }
923
- });
924
- }
925
936
  getServicePrincipalAccessTokenInternal() {
926
937
  return __awaiter(this, void 0, void 0, function* () {
927
938
  let token = yield this._store.getToken(this._servicePrincipalTokenId);
928
939
  if (!(token === null || token === void 0 ? void 0 : token.isValid())) {
929
- token = yield this.loginServicePrincipalInternal();
940
+ token = yield this.loginServicePrincipal();
930
941
  }
931
942
  return token === null || token === void 0 ? void 0 : token.accessToken;
932
943
  });
@@ -1010,9 +1021,9 @@ class NucleusIdentityService {
1010
1021
  });
1011
1022
  }
1012
1023
  }
1013
- NucleusIdentityService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: NucleusIdentityService, deps: [{ token: i1.NucleusAppService }, { token: LocationService }, { token: i1$1.HttpClient }, { token: OidcConfigurationService }, { token: TokenClient }], target: i0.ɵɵFactoryTarget.Injectable });
1014
- NucleusIdentityService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: NucleusIdentityService, providedIn: 'root' });
1015
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: NucleusIdentityService, decorators: [{
1024
+ NucleusIdentityService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NucleusIdentityService, deps: [{ token: i1.NucleusAppService }, { token: LocationService }, { token: i1$1.HttpClient }, { token: OidcConfigurationService }, { token: TokenClient }], target: i0.ɵɵFactoryTarget.Injectable });
1025
+ NucleusIdentityService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NucleusIdentityService, providedIn: 'root' });
1026
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NucleusIdentityService, decorators: [{
1016
1027
  type: Injectable,
1017
1028
  args: [{
1018
1029
  providedIn: 'root'
@@ -1067,9 +1078,9 @@ class NucleusTokenInterceptor {
1067
1078
  }));
1068
1079
  }
1069
1080
  }
1070
- NucleusTokenInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: NucleusTokenInterceptor, deps: [{ token: NucleusIdentityService }, { token: NucleusIdentityConfig }], target: i0.ɵɵFactoryTarget.Injectable });
1071
- NucleusTokenInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: NucleusTokenInterceptor, providedIn: 'root' });
1072
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: NucleusTokenInterceptor, decorators: [{
1081
+ NucleusTokenInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NucleusTokenInterceptor, deps: [{ token: NucleusIdentityService }, { token: NucleusIdentityConfig }], target: i0.ɵɵFactoryTarget.Injectable });
1082
+ NucleusTokenInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NucleusTokenInterceptor, providedIn: 'root' });
1083
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NucleusTokenInterceptor, decorators: [{
1073
1084
  type: Injectable,
1074
1085
  args: [{
1075
1086
  providedIn: 'root'
@@ -1087,10 +1098,10 @@ class NucleusIdentityModule {
1087
1098
  };
1088
1099
  }
1089
1100
  }
1090
- NucleusIdentityModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: NucleusIdentityModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1091
- NucleusIdentityModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: NucleusIdentityModule });
1092
- NucleusIdentityModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: NucleusIdentityModule, imports: [[]] });
1093
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0, type: NucleusIdentityModule, decorators: [{
1101
+ NucleusIdentityModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NucleusIdentityModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1102
+ NucleusIdentityModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NucleusIdentityModule });
1103
+ NucleusIdentityModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NucleusIdentityModule, imports: [[]] });
1104
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NucleusIdentityModule, decorators: [{
1094
1105
  type: NgModule,
1095
1106
  args: [{
1096
1107
  imports: [],
@@ -1119,4 +1130,4 @@ var OtpType;
1119
1130
  */
1120
1131
 
1121
1132
  export { DeviceCode, Identity, NucleusIdentityConfig, NucleusIdentityModule, NucleusIdentityService, OtpResponse, OtpStatus, OtpType, ServicePrincipalRegistrationStatus };
1122
- //# sourceMappingURL=kolektor-nucleus-identity.js.map
1133
+ //# sourceMappingURL=kolektor-nucleus-identity.mjs.map