@rxap/oauth 16.0.0-dev.2 → 16.0.0-dev.21
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.
- package/CHANGELOG.md +488 -0
- package/LICENSE +621 -27
- package/LICENSE.md +621 -0
- package/README.md +7 -22
- package/esm2022/index.mjs +6 -13
- package/esm2022/lib/authentication-guard.mjs +15 -0
- package/esm2022/lib/authentication.service.mjs +83 -0
- package/esm2022/lib/provide-auth.mjs +20 -0
- package/esm2022/rxap-oauth.mjs +1 -1
- package/fesm2022/rxap-oauth.mjs +94 -703
- package/fesm2022/rxap-oauth.mjs.map +1 -1
- package/index.d.ts +3 -12
- package/lib/authentication-guard.d.ts +2 -0
- package/lib/authentication.service.d.ts +16 -0
- package/lib/provide-auth.d.ts +4 -0
- package/package.json +56 -63
- package/theme.css +1 -0
- package/collection.json +0 -10
- package/esm2022/lib/container/container.component.mjs +0 -39
- package/esm2022/lib/get-o-auth-profile.method.mjs +0 -41
- package/esm2022/lib/loading/loading.component.mjs +0 -14
- package/esm2022/lib/o-auth-extract.guard.mjs +0 -56
- package/esm2022/lib/o-auth-redirect.guard.mjs +0 -32
- package/esm2022/lib/o-auth.method.mjs +0 -117
- package/esm2022/lib/o-auth.module.mjs +0 -28
- package/esm2022/lib/o-auth.service.mjs +0 -321
- package/esm2022/lib/profile.resolve.mjs +0 -38
- package/esm2022/lib/routes.mjs +0 -26
- package/esm2022/lib/sign-in-with-redirect/sign-in-with-redirect.component.mjs +0 -51
- package/esm2022/lib/tokens.mjs +0 -17
- package/esm2022/single-sign-on/lib/continue/continue.component.mjs +0 -79
- package/esm2022/single-sign-on/lib/error/error.component.mjs +0 -47
- package/esm2022/single-sign-on/lib/o-auth-single-sign-on-routing.module.mjs +0 -37
- package/esm2022/single-sign-on/lib/o-auth-single-sign-on.guard.mjs +0 -70
- package/esm2022/single-sign-on/lib/o-auth-single-sign-on.service.mjs +0 -78
- package/esm2022/single-sign-on/lib/routes.mjs +0 -33
- package/esm2022/single-sign-on/lib/tokens.mjs +0 -10
- package/esm2022/single-sign-on/public_api.mjs +0 -8
- package/esm2022/single-sign-on/rxap-oauth-single-sign-on.mjs +0 -5
- package/fesm2022/rxap-oauth-single-sign-on.mjs +0 -325
- package/fesm2022/rxap-oauth-single-sign-on.mjs.map +0 -1
- package/lib/container/container.component.d.ts +0 -7
- package/lib/get-o-auth-profile.method.d.ts +0 -18
- package/lib/loading/loading.component.d.ts +0 -5
- package/lib/o-auth-extract.guard.d.ts +0 -11
- package/lib/o-auth-redirect.guard.d.ts +0 -11
- package/lib/o-auth.method.d.ts +0 -45
- package/lib/o-auth.module.d.ts +0 -12
- package/lib/o-auth.service.d.ts +0 -64
- package/lib/profile.resolve.d.ts +0 -12
- package/lib/routes.d.ts +0 -2
- package/lib/sign-in-with-redirect/sign-in-with-redirect.component.d.ts +0 -9
- package/lib/tokens.d.ts +0 -6
- package/migration.json +0 -4
- package/single-sign-on/index.d.ts +0 -5
- package/single-sign-on/lib/continue/continue.component.d.ts +0 -17
- package/single-sign-on/lib/error/error.component.d.ts +0 -7
- package/single-sign-on/lib/o-auth-single-sign-on-routing.module.d.ts +0 -11
- package/single-sign-on/lib/o-auth-single-sign-on.guard.d.ts +0 -14
- package/single-sign-on/lib/o-auth-single-sign-on.service.d.ts +0 -13
- package/single-sign-on/lib/routes.d.ts +0 -2
- package/single-sign-on/lib/tokens.d.ts +0 -4
- package/single-sign-on/public_api.d.ts +0 -7
- package/src/schematics/ng-add/index.d.ts +0 -2
- package/src/schematics/ng-add/index.js +0 -8
- package/src/schematics/ng-add/index.js.map +0 -1
- package/src/schematics/ng-add/schema.json +0 -7
package/fesm2022/rxap-oauth.mjs
CHANGED
|
@@ -1,731 +1,122 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import * as i1
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
12
|
-
import * as i4 from '@angular/material/button';
|
|
13
|
-
import { MatButtonModule } from '@angular/material/button';
|
|
14
|
-
import * as i3 from '@angular/material/icon';
|
|
15
|
-
import { MatIconModule } from '@angular/material/icon';
|
|
16
|
-
import * as i2 from '@angular/flex-layout/flex';
|
|
17
|
-
import { FlexModule } from '@angular/flex-layout/flex';
|
|
2
|
+
import { Injectable, Optional, Inject, inject } from '@angular/core';
|
|
3
|
+
import { AuthenticationEventType, RXAP_AUTHENTICATION_ACCESS_TOKEN, RxapAuthenticationService } from '@rxap/authentication';
|
|
4
|
+
import { isDefined } from '@rxap/rxjs';
|
|
5
|
+
import * as i1 from 'angular-oauth2-oidc';
|
|
6
|
+
import { AUTH_CONFIG } from 'angular-oauth2-oidc';
|
|
7
|
+
import { JwksValidationHandler } from 'angular-oauth2-oidc-jwks';
|
|
8
|
+
import * as i2 from 'rxjs';
|
|
9
|
+
import { BehaviorSubject, distinctUntilChanged, startWith, firstValueFrom } from 'rxjs';
|
|
10
|
+
import { map } from 'rxjs/operators';
|
|
18
11
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
function IsOAuthMethodWithRefreshTokenParameters(parameters) {
|
|
56
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
57
|
-
return parameters.hasOwnProperty('refreshToken');
|
|
58
|
-
}
|
|
59
|
-
function IsOAuthMethodWithUsernamePasswordParameters(parameters) {
|
|
60
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
61
|
-
return (parameters.hasOwnProperty('username') &&
|
|
62
|
-
parameters.hasOwnProperty('password'));
|
|
63
|
-
}
|
|
64
|
-
function AssertOAuthMethodWithUsernamePasswordParameters(parameters) {
|
|
65
|
-
if (!IsOAuthMethodWithUsernamePasswordParameters(parameters)) {
|
|
66
|
-
throw new Error('The grant type password requires the parameters username and password');
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
function AssertOAuthMethodWithRefreshTokenParameters(parameters) {
|
|
70
|
-
if (!IsOAuthMethodWithRefreshTokenParameters(parameters)) {
|
|
71
|
-
throw new Error('The grant type refresh token requires the parameters refreshToken');
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function AssertOAuthMethodParameters(parameters) {
|
|
75
|
-
if (!parameters.authEndpoint) {
|
|
76
|
-
throw new Error('The authEndpoint parameter must be defined');
|
|
77
|
-
}
|
|
78
|
-
if (!parameters.secret) {
|
|
79
|
-
throw new Error('The secret parameter must be defined');
|
|
80
|
-
}
|
|
81
|
-
if (parameters.grantType) {
|
|
82
|
-
switch (parameters.grantType) {
|
|
83
|
-
case 'password':
|
|
84
|
-
AssertOAuthMethodWithUsernamePasswordParameters(parameters);
|
|
85
|
-
break;
|
|
86
|
-
case 'refresh_token':
|
|
87
|
-
AssertOAuthMethodWithRefreshTokenParameters(parameters);
|
|
88
|
-
break;
|
|
89
|
-
default:
|
|
90
|
-
throw new Error(`The grant type '${parameters.grantType}' is not supported`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
if (!IsOAuthMethodWithRefreshTokenParameters(parameters) &&
|
|
95
|
-
!IsOAuthMethodWithUsernamePasswordParameters(parameters)) {
|
|
96
|
-
throw new Error('Either the refresh token or the username and password must be defined');
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
class OAuthMethod {
|
|
101
|
-
constructor(http) {
|
|
102
|
-
this.http = http;
|
|
103
|
-
}
|
|
104
|
-
async call(parameters) {
|
|
105
|
-
AssertOAuthMethodParameters(parameters);
|
|
106
|
-
const params = new URLSearchParams();
|
|
107
|
-
const grantType = this.getGrantType(parameters);
|
|
108
|
-
params.append('grant_type', grantType);
|
|
109
|
-
switch (grantType) {
|
|
110
|
-
case 'password':
|
|
111
|
-
AssertOAuthMethodWithUsernamePasswordParameters(parameters);
|
|
112
|
-
params.append('username', parameters.username);
|
|
113
|
-
params.append('password', parameters.password);
|
|
114
|
-
break;
|
|
115
|
-
case 'refresh_token':
|
|
116
|
-
AssertOAuthMethodWithRefreshTokenParameters(parameters);
|
|
117
|
-
params.append('refresh_token', parameters.refreshToken);
|
|
118
|
-
break;
|
|
119
|
-
default:
|
|
120
|
-
throw new Error('Not supported grant type');
|
|
121
|
-
}
|
|
122
|
-
let headers = new HttpHeaders();
|
|
123
|
-
headers = headers.append('Content-type', 'application/x-www-form-urlencoded; charset=utf-8');
|
|
124
|
-
if (parameters.secret && parameters.clientId) {
|
|
125
|
-
params.append('client_id', parameters.clientId);
|
|
126
|
-
params.append('client_secret', parameters.secret);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
headers = headers.append('Authorization', `Basic ${parameters.secret}`);
|
|
130
|
-
}
|
|
131
|
-
const response = await this.http
|
|
132
|
-
.post(parameters.authEndpoint, params.toString(), {
|
|
133
|
-
headers,
|
|
134
|
-
withCredentials: parameters.withCredentials ?? true,
|
|
135
|
-
})
|
|
136
|
-
.toPromise();
|
|
137
|
-
return {
|
|
138
|
-
accessToken: response.access_token,
|
|
139
|
-
refreshToken: response.refresh_token,
|
|
140
|
-
expiresIn: response.expires_in,
|
|
141
|
-
expiresAt: new Date(Date.now() + response.expires_in * 1000),
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
getGrantType(parameters) {
|
|
145
|
-
if (parameters.grantType) {
|
|
146
|
-
return parameters.grantType;
|
|
147
|
-
}
|
|
148
|
-
if (IsOAuthMethodWithRefreshTokenParameters(parameters)) {
|
|
149
|
-
return 'refresh_token';
|
|
150
|
-
}
|
|
151
|
-
if (IsOAuthMethodWithUsernamePasswordParameters(parameters)) {
|
|
152
|
-
return 'password';
|
|
153
|
-
}
|
|
154
|
-
throw new Error('Could not guess the grant type');
|
|
155
|
-
}
|
|
156
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: OAuthMethod, deps: [{ token: HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
157
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: OAuthMethod, providedIn: 'root' }); }
|
|
158
|
-
}
|
|
159
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: OAuthMethod, decorators: [{
|
|
160
|
-
type: Injectable,
|
|
161
|
-
args: [{ providedIn: 'root' }]
|
|
162
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient, decorators: [{
|
|
163
|
-
type: Inject,
|
|
164
|
-
args: [HttpClient]
|
|
165
|
-
}] }]; } });
|
|
166
|
-
|
|
167
|
-
function DefaultRedirectSignInFactory() {
|
|
168
|
-
return ['/', 'authentication', 'login'];
|
|
169
|
-
}
|
|
170
|
-
const RXAP_O_AUTH_REDIRECT_SIGN_IN = new InjectionToken('rxap/o-auth/redirect-sign-in', {
|
|
171
|
-
providedIn: 'root',
|
|
172
|
-
factory: DefaultRedirectSignInFactory
|
|
173
|
-
});
|
|
174
|
-
const RXAP_O_AUTH_REDIRECT_SIGN_OUT = new InjectionToken('rxap/o-auth/redirect-sign-out');
|
|
175
|
-
function DefaultRedirectUrl() {
|
|
176
|
-
return location.origin + '/oauth';
|
|
177
|
-
}
|
|
178
|
-
const RXAP_O_AUTH_REDIRECT_URL = new InjectionToken('rxap/o-auth/redirect-url', {
|
|
179
|
-
providedIn: 'root',
|
|
180
|
-
factory: DefaultRedirectUrl
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
const OAUTH_SECRET = new InjectionToken('OAUTH_SECRET');
|
|
184
|
-
const OAUTH_AUTH_ENDPOINT = new InjectionToken('OAUTH_AUTH_ENDPOINT');
|
|
185
|
-
const OAUTH_SSO_URL = new InjectionToken('OAUTH_SSO_URL');
|
|
186
|
-
const OAUTH_CLIENT_ID = new InjectionToken('OAUTH_CLIENT_ID');
|
|
187
|
-
const ACCESS_TOKEN_LOCAL_STORAGE_KEY = 'access_token';
|
|
188
|
-
const REFRESH_TOKEN_LOCAL_STORAGE_KEY = 'refresh_token';
|
|
189
|
-
const EXPIRES_AT_LOCAL_STORAGE_KEY = 'expires_at';
|
|
190
|
-
const REMEMBER_LOCAL_STORAGE_KEY = 'remember';
|
|
191
|
-
class OAuthService {
|
|
192
|
-
get expiresAt() {
|
|
193
|
-
const expiresAt = this.getItem(EXPIRES_AT_LOCAL_STORAGE_KEY);
|
|
194
|
-
if (expiresAt) {
|
|
195
|
-
return new Date(parseInt(this.getItem(EXPIRES_AT_LOCAL_STORAGE_KEY), 10));
|
|
196
|
-
}
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
set expiresAt(value) {
|
|
200
|
-
if (value) {
|
|
201
|
-
this.setItem(EXPIRES_AT_LOCAL_STORAGE_KEY, value.getTime().toFixed(0));
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
this.removeItem(EXPIRES_AT_LOCAL_STORAGE_KEY);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
get refreshToken() {
|
|
208
|
-
return this.getItem(REFRESH_TOKEN_LOCAL_STORAGE_KEY);
|
|
209
|
-
}
|
|
210
|
-
set refreshToken(value) {
|
|
211
|
-
if (value) {
|
|
212
|
-
this.setItem(REFRESH_TOKEN_LOCAL_STORAGE_KEY, value);
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
this.removeItem(REFRESH_TOKEN_LOCAL_STORAGE_KEY);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
get accessToken() {
|
|
219
|
-
return this.getItem(ACCESS_TOKEN_LOCAL_STORAGE_KEY);
|
|
220
|
-
}
|
|
221
|
-
set accessToken(value) {
|
|
222
|
-
if (value) {
|
|
223
|
-
this.setItem(ACCESS_TOKEN_LOCAL_STORAGE_KEY, value);
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
this.removeItem(ACCESS_TOKEN_LOCAL_STORAGE_KEY);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* The time until the access token expires in seconds
|
|
231
|
-
*/
|
|
232
|
-
get expiresIn() {
|
|
233
|
-
const expiresAt = this.expiresAt;
|
|
234
|
-
if (expiresAt) {
|
|
235
|
-
return Math.round((expiresAt.getTime() - Date.now()) / 1000);
|
|
236
|
-
}
|
|
237
|
-
return null;
|
|
238
|
-
}
|
|
239
|
-
get remember() {
|
|
240
|
-
return !!this.getItem(REMEMBER_LOCAL_STORAGE_KEY);
|
|
241
|
-
}
|
|
242
|
-
set remember(value) {
|
|
243
|
-
if (value) {
|
|
244
|
-
this.setItem(REMEMBER_LOCAL_STORAGE_KEY, 'true');
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
this.removeItem(REMEMBER_LOCAL_STORAGE_KEY);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
get profile() {
|
|
251
|
-
return this._profile;
|
|
252
|
-
}
|
|
253
|
-
constructor(oAuthMethod, getOAuthProfileMethod, router, profileEndpoint = null, authEndpoint = null, secret = null, ssoUrl = null, redirectSignOut = null, redirectUrl = null, clientId = null) {
|
|
254
|
-
this.oAuthMethod = oAuthMethod;
|
|
255
|
-
this.getOAuthProfileMethod = getOAuthProfileMethod;
|
|
256
|
-
this.router = router;
|
|
257
|
-
this.profileEndpoint = profileEndpoint;
|
|
258
|
-
this.authEndpoint = authEndpoint;
|
|
259
|
-
this.secret = secret;
|
|
260
|
-
this.ssoUrl = ssoUrl;
|
|
261
|
-
this.redirectSignOut = redirectSignOut;
|
|
262
|
-
this.redirectUrl = redirectUrl;
|
|
263
|
-
this.clientId = clientId;
|
|
264
|
-
this.events$ = new ReplaySubject();
|
|
265
|
-
this._isAuthenticated = null;
|
|
266
|
-
}
|
|
267
|
-
signInWithRedirect(lastUrl) {
|
|
268
|
-
if (!this.redirectUrl) {
|
|
269
|
-
throw new Error('Redirect url is not defined');
|
|
270
|
-
}
|
|
271
|
-
location.replace(`${this.ssoUrl}?redirect=${btoa(this.redirectUrl)}&secret=${this.secret}&payload=${btoa(JSON.stringify({ lastUrl }))}`);
|
|
272
|
-
}
|
|
273
|
-
async isAuthenticated() {
|
|
274
|
-
if (!this.secret) {
|
|
275
|
-
throw new Error('The oauth secret is not defined');
|
|
276
|
-
}
|
|
277
|
-
if (!this.authEndpoint) {
|
|
278
|
-
throw new Error('The oauth auth endpoint is not defined');
|
|
279
|
-
}
|
|
280
|
-
if (this._isAuthenticated !== null) {
|
|
281
|
-
return this._isAuthenticated;
|
|
282
|
-
}
|
|
283
|
-
if (this.accessToken) {
|
|
284
|
-
console.debug('Access token is defined: ' + this.accessToken);
|
|
285
|
-
if (this.expiresIn && this.expiresIn > 60) {
|
|
286
|
-
const profile = await this.getProfile();
|
|
287
|
-
if (!profile) {
|
|
288
|
-
console.log('profile is not defined');
|
|
289
|
-
return (this._isAuthenticated = false);
|
|
290
|
-
}
|
|
291
|
-
this.authenticated({
|
|
292
|
-
refreshToken: this.refreshToken,
|
|
293
|
-
accessToken: this.accessToken,
|
|
294
|
-
expiresAt: this.expiresAt ?? new Date(Date.now() + 60 * 1000),
|
|
295
|
-
expiresIn: this.expiresIn,
|
|
296
|
-
}, this.remember);
|
|
297
|
-
return (this._isAuthenticated = true);
|
|
12
|
+
class AuthenticationService {
|
|
13
|
+
constructor(oauthService, authConfig, authenticationAccessToken) {
|
|
14
|
+
this.oauthService = oauthService;
|
|
15
|
+
this.authenticationAccessToken = authenticationAccessToken;
|
|
16
|
+
this.isAuthenticated$ = new BehaviorSubject(null);
|
|
17
|
+
if (authConfig) {
|
|
18
|
+
this.oauthService.configure(authConfig);
|
|
19
|
+
}
|
|
20
|
+
this.events$ = this.oauthService.events.pipe(map(event => {
|
|
21
|
+
switch (true) {
|
|
22
|
+
case ['token_received', 'token_refreshed', 'silently_refreshed'].includes(event.type):
|
|
23
|
+
this.authenticationAccessToken.next({
|
|
24
|
+
token: this.oauthService.getAccessToken(),
|
|
25
|
+
valid: this.oauthService.hasValidAccessToken(),
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
type: AuthenticationEventType.OnAuthSuccess,
|
|
29
|
+
payload: event,
|
|
30
|
+
};
|
|
31
|
+
case event.type.endsWith('_error') ||
|
|
32
|
+
['silent_refresh_timeout', 'invalid_nonce_in_state'].includes(event.type):
|
|
33
|
+
this.authenticationAccessToken.next(null);
|
|
34
|
+
return {
|
|
35
|
+
type: AuthenticationEventType.OnAuthError,
|
|
36
|
+
payload: event,
|
|
37
|
+
};
|
|
38
|
+
case ['token_expires', 'logout', 'session_terminated'].includes(event.type):
|
|
39
|
+
this.authenticationAccessToken.next(null);
|
|
40
|
+
return {
|
|
41
|
+
type: AuthenticationEventType.OnLogout,
|
|
42
|
+
payload: event,
|
|
43
|
+
};
|
|
44
|
+
default:
|
|
45
|
+
console.warn('Unhandled event', event);
|
|
46
|
+
return null;
|
|
298
47
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
catch (e) {
|
|
312
|
-
if (![401, 403, 400].includes(e.status)) {
|
|
313
|
-
console.error('Could not sign in with refresh token', e.message);
|
|
314
|
-
throw e;
|
|
315
|
-
}
|
|
316
|
-
console.warn('Refresh token is expired');
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
console.warn('Unauthenticated');
|
|
320
|
-
return (this._isAuthenticated = false);
|
|
321
|
-
}
|
|
322
|
-
async signInWithEmailAndPassword(email, password, remember) {
|
|
323
|
-
if (!this.secret) {
|
|
324
|
-
throw new Error('The oauth secret is not defined');
|
|
325
|
-
}
|
|
326
|
-
if (!this.authEndpoint) {
|
|
327
|
-
throw new Error('The oauth auth endpoint is not defined');
|
|
328
|
-
}
|
|
329
|
-
const response = await this.oAuthMethod.call({
|
|
330
|
-
username: email,
|
|
331
|
-
password: password,
|
|
332
|
-
authEndpoint: this.authEndpoint,
|
|
333
|
-
secret: this.secret,
|
|
334
|
-
clientId: this.clientId ?? undefined
|
|
335
|
-
}).catch(e => {
|
|
336
|
-
this.events$.next({ type: AuthenticationEventType.OnAuthError });
|
|
337
|
-
throw e;
|
|
48
|
+
}), isDefined());
|
|
49
|
+
this.events$.pipe(map(event => event ? event.type === AuthenticationEventType.OnAuthSuccess : null), distinctUntilChanged(), startWith(null)).subscribe(this.isAuthenticated$);
|
|
50
|
+
// Use setStorage to use sessionStorage or another implementation of the TS-type Storage
|
|
51
|
+
// instead of localStorage
|
|
52
|
+
this.oauthService.setStorage(sessionStorage);
|
|
53
|
+
if (this.oauthService.silentRefreshRedirectUri) {
|
|
54
|
+
this.oauthService.setupAutomaticSilentRefresh();
|
|
55
|
+
}
|
|
56
|
+
this.oauthService.tokenValidationHandler = new JwksValidationHandler();
|
|
57
|
+
this.oauthService.loadDiscoveryDocumentAndTryLogin().then(status => {
|
|
58
|
+
this.isAuthenticated$.next(status);
|
|
338
59
|
});
|
|
339
|
-
this.authenticated(response, remember);
|
|
340
|
-
return response;
|
|
341
|
-
}
|
|
342
|
-
async getProfile() {
|
|
343
|
-
let profile = null;
|
|
344
|
-
if (!this.accessToken) {
|
|
345
|
-
throw new Error('The access token is not defined');
|
|
346
|
-
}
|
|
347
|
-
if (this.profileEndpoint) {
|
|
348
|
-
try {
|
|
349
|
-
profile = await this.getOAuthProfileMethod.call({
|
|
350
|
-
accessToken: this.accessToken,
|
|
351
|
-
profileEndpoint: this.profileEndpoint
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
catch (e) {
|
|
355
|
-
console.error('Could not request the user profile', e.message);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
else {
|
|
359
|
-
console.warn('The profile endpoint is not defined!');
|
|
360
|
-
}
|
|
361
|
-
return (this._profile = profile);
|
|
362
60
|
}
|
|
363
61
|
async signOut() {
|
|
364
|
-
this.
|
|
365
|
-
this.accessToken = null;
|
|
366
|
-
this.refreshToken = null;
|
|
367
|
-
this.expiresAt = null;
|
|
368
|
-
this._isAuthenticated = false;
|
|
369
|
-
if (this.redirectSignOut) {
|
|
370
|
-
await this.router.navigate(this.redirectSignOut);
|
|
371
|
-
}
|
|
372
|
-
else {
|
|
373
|
-
if (!this.redirectUrl) {
|
|
374
|
-
throw new Error('Redirect url is not defined');
|
|
375
|
-
}
|
|
376
|
-
location.replace(`${this.ssoUrl}?redirect=${btoa(this.redirectUrl)}&secret=${this.secret}&action=signOut`);
|
|
377
|
-
}
|
|
378
|
-
this.events$.next({ type: AuthenticationEventType.OnLogout });
|
|
62
|
+
this.oauthService.logOut();
|
|
379
63
|
}
|
|
380
|
-
|
|
381
|
-
this.
|
|
382
|
-
this.refreshToken = response.refreshToken ?? null;
|
|
383
|
-
this.expiresAt = response.expiresAt;
|
|
384
|
-
console.log(`Authenticated until ${this.expiresAt.toISOString()}`);
|
|
385
|
-
this.remember = remember;
|
|
386
|
-
if (remember) {
|
|
387
|
-
this.setItem(ACCESS_TOKEN_LOCAL_STORAGE_KEY, response.accessToken);
|
|
388
|
-
if (response.refreshToken) {
|
|
389
|
-
this.setItem(REFRESH_TOKEN_LOCAL_STORAGE_KEY, response.refreshToken);
|
|
390
|
-
}
|
|
391
|
-
this.setItem(REMEMBER_LOCAL_STORAGE_KEY, 'true');
|
|
392
|
-
if (response.expiresAt) {
|
|
393
|
-
console.log(`Authenticated until ${response.expiresAt.toISOString()}`);
|
|
394
|
-
this.setItem(EXPIRES_AT_LOCAL_STORAGE_KEY, response.expiresAt.getTime().toFixed(0));
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
else {
|
|
398
|
-
this.removeItem(ACCESS_TOKEN_LOCAL_STORAGE_KEY);
|
|
399
|
-
this.removeItem(REFRESH_TOKEN_LOCAL_STORAGE_KEY);
|
|
400
|
-
this.removeItem(REMEMBER_LOCAL_STORAGE_KEY);
|
|
401
|
-
this.removeItem(EXPIRES_AT_LOCAL_STORAGE_KEY);
|
|
402
|
-
}
|
|
403
|
-
this._isAuthenticated = true;
|
|
404
|
-
this.events$.next({ type: AuthenticationEventType.OnAuthSuccess });
|
|
405
|
-
}
|
|
406
|
-
getKey(key) {
|
|
407
|
-
return [this.secret, key].join('__');
|
|
408
|
-
}
|
|
409
|
-
getItem(key) {
|
|
410
|
-
return localStorage.getItem(this.getKey(key));
|
|
411
|
-
}
|
|
412
|
-
setItem(key, value) {
|
|
413
|
-
localStorage.setItem(this.getKey(key), value);
|
|
414
|
-
}
|
|
415
|
-
removeItem(key) {
|
|
416
|
-
localStorage.removeItem(this.getKey(key));
|
|
64
|
+
signIn() {
|
|
65
|
+
this.oauthService.initLoginFlow();
|
|
417
66
|
}
|
|
418
|
-
|
|
419
|
-
this.
|
|
420
|
-
this.removeItem(REFRESH_TOKEN_LOCAL_STORAGE_KEY);
|
|
421
|
-
this.removeItem(REMEMBER_LOCAL_STORAGE_KEY);
|
|
422
|
-
this.removeItem(EXPIRES_AT_LOCAL_STORAGE_KEY);
|
|
67
|
+
isAuthenticated() {
|
|
68
|
+
return firstValueFrom(this.isAuthenticated$.pipe(isDefined()));
|
|
423
69
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
throw new Error('The oauth secret is not defined');
|
|
427
|
-
}
|
|
428
|
-
if (!this.authEndpoint) {
|
|
429
|
-
throw new Error('The oauth auth endpoint is not defined');
|
|
430
|
-
}
|
|
431
|
-
const response = await this.oAuthMethod.call({
|
|
432
|
-
refreshToken,
|
|
433
|
-
authEndpoint: this.authEndpoint,
|
|
434
|
-
secret: this.secret,
|
|
435
|
-
clientId: this.clientId ?? undefined,
|
|
436
|
-
});
|
|
437
|
-
this.authenticated(response);
|
|
438
|
-
return response;
|
|
439
|
-
}
|
|
440
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: OAuthService, deps: [{ token: OAuthMethod }, { token: GetOAuthProfileMethod }, { token: Router }, { token: PROFILE_AUTH_ENDPOINT, optional: true }, { token: OAUTH_AUTH_ENDPOINT, optional: true }, { token: OAUTH_SECRET, optional: true }, { token: OAUTH_SSO_URL, optional: true }, { token: RXAP_O_AUTH_REDIRECT_SIGN_OUT, optional: true }, { token: RXAP_O_AUTH_REDIRECT_URL, optional: true }, { token: OAUTH_CLIENT_ID, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
441
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: OAuthService, providedIn: 'root' }); }
|
|
70
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AuthenticationService, deps: [{ token: i1.OAuthService }, { token: AUTH_CONFIG, optional: true }, { token: RXAP_AUTHENTICATION_ACCESS_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
71
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AuthenticationService }); }
|
|
442
72
|
}
|
|
443
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.
|
|
444
|
-
type: Injectable
|
|
445
|
-
|
|
446
|
-
}], ctorParameters: function () { return [{ type: OAuthMethod, decorators: [{
|
|
447
|
-
type: Inject,
|
|
448
|
-
args: [OAuthMethod]
|
|
449
|
-
}] }, { type: GetOAuthProfileMethod, decorators: [{
|
|
450
|
-
type: Inject,
|
|
451
|
-
args: [GetOAuthProfileMethod]
|
|
452
|
-
}] }, { type: i1$1.Router, decorators: [{
|
|
453
|
-
type: Inject,
|
|
454
|
-
args: [Router]
|
|
455
|
-
}] }, { type: undefined, decorators: [{
|
|
456
|
-
type: Optional
|
|
457
|
-
}, {
|
|
458
|
-
type: Inject,
|
|
459
|
-
args: [PROFILE_AUTH_ENDPOINT]
|
|
460
|
-
}] }, { type: undefined, decorators: [{
|
|
461
|
-
type: Optional
|
|
462
|
-
}, {
|
|
463
|
-
type: Inject,
|
|
464
|
-
args: [OAUTH_AUTH_ENDPOINT]
|
|
465
|
-
}] }, { type: undefined, decorators: [{
|
|
466
|
-
type: Optional
|
|
467
|
-
}, {
|
|
468
|
-
type: Inject,
|
|
469
|
-
args: [OAUTH_SECRET]
|
|
470
|
-
}] }, { type: undefined, decorators: [{
|
|
471
|
-
type: Optional
|
|
472
|
-
}, {
|
|
473
|
-
type: Inject,
|
|
474
|
-
args: [OAUTH_SSO_URL]
|
|
475
|
-
}] }, { type: undefined, decorators: [{
|
|
476
|
-
type: Optional
|
|
477
|
-
}, {
|
|
478
|
-
type: Inject,
|
|
479
|
-
args: [RXAP_O_AUTH_REDIRECT_SIGN_OUT]
|
|
480
|
-
}] }, { type: undefined, decorators: [{
|
|
73
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AuthenticationService, decorators: [{
|
|
74
|
+
type: Injectable
|
|
75
|
+
}], ctorParameters: function () { return [{ type: i1.OAuthService }, { type: i1.AuthConfig, decorators: [{
|
|
481
76
|
type: Optional
|
|
482
77
|
}, {
|
|
483
78
|
type: Inject,
|
|
484
|
-
args: [
|
|
485
|
-
}] }, { type:
|
|
486
|
-
type: Optional
|
|
487
|
-
}, {
|
|
79
|
+
args: [AUTH_CONFIG]
|
|
80
|
+
}] }, { type: i2.BehaviorSubject, decorators: [{
|
|
488
81
|
type: Inject,
|
|
489
|
-
args: [
|
|
82
|
+
args: [RXAP_AUTHENTICATION_ACCESS_TOKEN]
|
|
490
83
|
}] }]; } });
|
|
491
84
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
85
|
+
async function AuthenticationGuard(route, state) {
|
|
86
|
+
const authService = inject(RxapAuthenticationService);
|
|
87
|
+
if (!(authService instanceof AuthenticationService)) {
|
|
88
|
+
throw new Error('The RxapAuthenticationService must be an instance of AuthenticationService. Ensure the ProvideAuth() function is used in the application config.');
|
|
496
89
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
500
|
-
const accessToken = route.queryParamMap.get('accessToken');
|
|
501
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
502
|
-
const refreshToken = route.queryParamMap.get('refreshToken');
|
|
503
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
504
|
-
const expiresIn = parseInt(route.queryParamMap.get('expiresIn'), 10);
|
|
505
|
-
const payloadBase64 = route.queryParamMap.get('payload');
|
|
506
|
-
const expiresAt = new Date(Date.now() + expiresIn * 1000);
|
|
507
|
-
this.oAuthService.authenticated({
|
|
508
|
-
accessToken,
|
|
509
|
-
refreshToken,
|
|
510
|
-
expiresIn,
|
|
511
|
-
expiresAt
|
|
512
|
-
}, true);
|
|
513
|
-
let redirectUrl = '/';
|
|
514
|
-
if (payloadBase64) {
|
|
515
|
-
try {
|
|
516
|
-
const payload = JSON.parse(atob(payloadBase64));
|
|
517
|
-
console.debug('sso redirect payload', payload);
|
|
518
|
-
if (payload.lastUrl) {
|
|
519
|
-
redirectUrl = payload.lastUrl;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
catch (e) {
|
|
523
|
-
console.error('Could not parse redirect payload', e.message);
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
return this.router.createUrlTree([redirectUrl]);
|
|
527
|
-
}
|
|
528
|
-
else {
|
|
529
|
-
console.warn('Not every query parameter is defined!');
|
|
530
|
-
}
|
|
531
|
-
return this.router.createUrlTree([...route.url.map(url => url.path), 'redirect']);
|
|
90
|
+
if (await authService.isAuthenticated()) {
|
|
91
|
+
return true;
|
|
532
92
|
}
|
|
533
|
-
|
|
534
|
-
|
|
93
|
+
authService.signIn();
|
|
94
|
+
return false;
|
|
535
95
|
}
|
|
536
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: OAuthExtractGuard, decorators: [{
|
|
537
|
-
type: Injectable,
|
|
538
|
-
args: [{ providedIn: 'root' }]
|
|
539
|
-
}], ctorParameters: function () { return [{ type: i1$1.Router }, { type: OAuthService }]; } });
|
|
540
96
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}
|
|
557
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: OAuthRedirectGuard, deps: [{ token: OAuthService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
558
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: OAuthRedirectGuard, providedIn: 'root' }); }
|
|
559
|
-
}
|
|
560
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: OAuthRedirectGuard, decorators: [{
|
|
561
|
-
type: Injectable,
|
|
562
|
-
args: [{ providedIn: 'root' }]
|
|
563
|
-
}], ctorParameters: function () { return [{ type: OAuthService, decorators: [{
|
|
564
|
-
type: Inject,
|
|
565
|
-
args: [OAuthService]
|
|
566
|
-
}] }]; } });
|
|
567
|
-
|
|
568
|
-
class OAuthModule {
|
|
569
|
-
static forRoot(options = {}) {
|
|
570
|
-
return {
|
|
571
|
-
ngModule: OAuthModule,
|
|
572
|
-
providers: [
|
|
573
|
-
{
|
|
574
|
-
provide: RXAP_O_AUTH_REDIRECT_SIGN_IN,
|
|
575
|
-
useValue: options.signInPath ?? ['/', 'oauth', 'redirect']
|
|
576
|
-
},
|
|
577
|
-
{
|
|
578
|
-
provide: RXAP_O_AUTH_REDIRECT_SIGN_OUT,
|
|
579
|
-
useValue: options.signOutPath ?? null
|
|
580
|
-
}
|
|
581
|
-
]
|
|
582
|
-
};
|
|
583
|
-
}
|
|
584
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: OAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
585
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.2", ngImport: i0, type: OAuthModule }); }
|
|
586
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: OAuthModule }); }
|
|
587
|
-
}
|
|
588
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: OAuthModule, decorators: [{
|
|
589
|
-
type: NgModule
|
|
590
|
-
}] });
|
|
591
|
-
|
|
592
|
-
class ContainerComponent {
|
|
593
|
-
prepareRoute(outlet) {
|
|
594
|
-
return outlet.isActivated ? outlet.activatedRoute : 'true';
|
|
595
|
-
}
|
|
596
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
597
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.2", type: ContainerComponent, isStandalone: true, selector: "rxap-container", host: { classAttribute: "rxap-container" }, ngImport: i0, template: "<div [@routeAnimations]=\"prepareRoute(outlet)\" class=\"container\">\n\n <div class=\"split mat-elevation-z3\"></div>\n\n <router-outlet #outlet=\"outlet\"></router-outlet>\n\n</div>\n", styles: [".container{height:100vh;width:100vw;display:flex;align-items:center;justify-content:center}.container .split{position:absolute;top:0;left:0;right:0;bottom:65vh;z-index:-10}\n"], dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }], animations: [
|
|
598
|
-
trigger('routeAnimations', [
|
|
599
|
-
transition(':enter', [
|
|
600
|
-
style({ opacity: 0 }),
|
|
601
|
-
animate('512ms', style({ opacity: 1 }))
|
|
602
|
-
]),
|
|
603
|
-
transition(':leave', [
|
|
604
|
-
style({ opacity: 1 }),
|
|
605
|
-
animate('512ms', style({ opacity: 0 }))
|
|
606
|
-
])
|
|
607
|
-
])
|
|
608
|
-
], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
97
|
+
function ProvideAuth(...withConfigs) {
|
|
98
|
+
return [
|
|
99
|
+
AuthenticationService,
|
|
100
|
+
{
|
|
101
|
+
provide: RxapAuthenticationService,
|
|
102
|
+
useExisting: AuthenticationService,
|
|
103
|
+
},
|
|
104
|
+
...withConfigs.flat(),
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
function withAuthConfig(config) {
|
|
108
|
+
return {
|
|
109
|
+
provide: AUTH_CONFIG,
|
|
110
|
+
useValue: config,
|
|
111
|
+
};
|
|
609
112
|
}
|
|
610
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ContainerComponent, decorators: [{
|
|
611
|
-
type: Component,
|
|
612
|
-
args: [{ selector: 'rxap-container', changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'rxap-container' }, animations: [
|
|
613
|
-
trigger('routeAnimations', [
|
|
614
|
-
transition(':enter', [
|
|
615
|
-
style({ opacity: 0 }),
|
|
616
|
-
animate('512ms', style({ opacity: 1 }))
|
|
617
|
-
]),
|
|
618
|
-
transition(':leave', [
|
|
619
|
-
style({ opacity: 1 }),
|
|
620
|
-
animate('512ms', style({ opacity: 0 }))
|
|
621
|
-
])
|
|
622
|
-
])
|
|
623
|
-
], standalone: true, imports: [RouterOutlet], template: "<div [@routeAnimations]=\"prepareRoute(outlet)\" class=\"container\">\n\n <div class=\"split mat-elevation-z3\"></div>\n\n <router-outlet #outlet=\"outlet\"></router-outlet>\n\n</div>\n", styles: [".container{height:100vh;width:100vw;display:flex;align-items:center;justify-content:center}.container .split{position:absolute;top:0;left:0;right:0;bottom:65vh;z-index:-10}\n"] }]
|
|
624
|
-
}] });
|
|
625
113
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.2", type: LoadingComponent, isStandalone: true, selector: "rxap-loading", host: { classAttribute: "rxap-loading" }, ngImport: i0, template: "<mat-progress-bar class=\"loading-bar\" mode=\"indeterminate\"></mat-progress-bar>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: MatProgressBarModule }, { kind: "component", type: i1$2.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
629
|
-
}
|
|
630
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: LoadingComponent, decorators: [{
|
|
631
|
-
type: Component,
|
|
632
|
-
args: [{ selector: 'rxap-loading', changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'rxap-loading' }, standalone: true, imports: [MatProgressBarModule], template: "<mat-progress-bar class=\"loading-bar\" mode=\"indeterminate\"></mat-progress-bar>\n" }]
|
|
633
|
-
}] });
|
|
634
|
-
|
|
635
|
-
class SignInWithRedirectComponent {
|
|
636
|
-
constructor(authService) {
|
|
637
|
-
this.authService = authService;
|
|
638
|
-
}
|
|
639
|
-
signIn() {
|
|
640
|
-
this.authService.signInWithRedirect();
|
|
641
|
-
}
|
|
642
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: SignInWithRedirectComponent, deps: [{ token: OAuthService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
643
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.2", type: SignInWithRedirectComponent, isStandalone: true, selector: "rxap-sign-in-with-redirect", host: { classAttribute: "rxap-sign-in-with-redirect" }, ngImport: i0, template: "<div [@fadeAnimation]=\"'in'\" class=\"inner mat-elevation-z5\" fxLayout=\"column\" fxLayoutAlign=\"center center\" fxLayoutGap=\"32px\">\n\n <div class=\"header\" fxFlex=\"nogrow\" fxLayout=\"column\" fxLayoutAlign=\"center center\">\n\n <mat-icon class=\"avatar-icon\" color=\"primary\" fxFlex=\"nogrow\">account_circle</mat-icon>\n\n </div>\n\n <div fxFlex=\"nogrow\" fxLayout=\"row\" fxLayoutAlign=\"center center\">\n\n <div fxFlex=\"nogrow\">\n <button (click)=\"signIn()\" color=\"primary\" fxFlex=\"nogrow\" mat-raised-button>\n <span fxLayout=\"row\" fxLayoutAlign=\"start center\" fxLayoutGap=\"16px\">\n <mat-icon fxFlex=\"nogrow\">login</mat-icon>\n <span fxFlex=\"nogrow\">Sign In</span>\n </span>\n </button>\n </div>\n\n </div>\n\n</div>\n\n", styles: [".inner{padding:64px;position:relative}.inner .header .avatar-icon{width:100px;height:100px;font-size:100px}\n"], dependencies: [{ kind: "ngmodule", type: FlexModule }, { kind: "directive", type: i2.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { kind: "directive", type: i2.DefaultLayoutGapDirective, selector: " [fxLayoutGap], [fxLayoutGap.xs], [fxLayoutGap.sm], [fxLayoutGap.md], [fxLayoutGap.lg], [fxLayoutGap.xl], [fxLayoutGap.lt-sm], [fxLayoutGap.lt-md], [fxLayoutGap.lt-lg], [fxLayoutGap.lt-xl], [fxLayoutGap.gt-xs], [fxLayoutGap.gt-sm], [fxLayoutGap.gt-md], [fxLayoutGap.gt-lg]", inputs: ["fxLayoutGap", "fxLayoutGap.xs", "fxLayoutGap.sm", "fxLayoutGap.md", "fxLayoutGap.lg", "fxLayoutGap.xl", "fxLayoutGap.lt-sm", "fxLayoutGap.lt-md", "fxLayoutGap.lt-lg", "fxLayoutGap.lt-xl", "fxLayoutGap.gt-xs", "fxLayoutGap.gt-sm", "fxLayoutGap.gt-md", "fxLayoutGap.gt-lg"] }, { kind: "directive", type: i2.DefaultLayoutAlignDirective, selector: " [fxLayoutAlign], [fxLayoutAlign.xs], [fxLayoutAlign.sm], [fxLayoutAlign.md], [fxLayoutAlign.lg], [fxLayoutAlign.xl], [fxLayoutAlign.lt-sm], [fxLayoutAlign.lt-md], [fxLayoutAlign.lt-lg], [fxLayoutAlign.lt-xl], [fxLayoutAlign.gt-xs], [fxLayoutAlign.gt-sm], [fxLayoutAlign.gt-md], [fxLayoutAlign.gt-lg]", inputs: ["fxLayoutAlign", "fxLayoutAlign.xs", "fxLayoutAlign.sm", "fxLayoutAlign.md", "fxLayoutAlign.lg", "fxLayoutAlign.xl", "fxLayoutAlign.lt-sm", "fxLayoutAlign.lt-md", "fxLayoutAlign.lt-lg", "fxLayoutAlign.lt-xl", "fxLayoutAlign.gt-xs", "fxLayoutAlign.gt-sm", "fxLayoutAlign.gt-md", "fxLayoutAlign.gt-lg"] }, { kind: "directive", type: i2.DefaultFlexDirective, selector: " [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md], [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md], [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm], [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i4.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], animations: [
|
|
644
|
-
trigger('fadeAnimation', [
|
|
645
|
-
// the "in" style determines the "resting" state of the element when it is visible.
|
|
646
|
-
state('in', style({ opacity: 1 })),
|
|
647
|
-
// fade in when created. this could also be written as transition('void => *')
|
|
648
|
-
transition(':enter', [
|
|
649
|
-
style({ opacity: 0 }),
|
|
650
|
-
animate(300)
|
|
651
|
-
]),
|
|
652
|
-
// fade out when destroyed. this could also be written as transition('void => *')
|
|
653
|
-
transition(':leave', animate(300, style({ opacity: 0 })))
|
|
654
|
-
])
|
|
655
|
-
], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
656
|
-
}
|
|
657
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: SignInWithRedirectComponent, decorators: [{
|
|
658
|
-
type: Component,
|
|
659
|
-
args: [{ selector: 'rxap-sign-in-with-redirect', changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'rxap-sign-in-with-redirect' }, animations: [
|
|
660
|
-
trigger('fadeAnimation', [
|
|
661
|
-
// the "in" style determines the "resting" state of the element when it is visible.
|
|
662
|
-
state('in', style({ opacity: 1 })),
|
|
663
|
-
// fade in when created. this could also be written as transition('void => *')
|
|
664
|
-
transition(':enter', [
|
|
665
|
-
style({ opacity: 0 }),
|
|
666
|
-
animate(300)
|
|
667
|
-
]),
|
|
668
|
-
// fade out when destroyed. this could also be written as transition('void => *')
|
|
669
|
-
transition(':leave', animate(300, style({ opacity: 0 })))
|
|
670
|
-
])
|
|
671
|
-
], standalone: true, imports: [FlexModule, MatIconModule, MatButtonModule], template: "<div [@fadeAnimation]=\"'in'\" class=\"inner mat-elevation-z5\" fxLayout=\"column\" fxLayoutAlign=\"center center\" fxLayoutGap=\"32px\">\n\n <div class=\"header\" fxFlex=\"nogrow\" fxLayout=\"column\" fxLayoutAlign=\"center center\">\n\n <mat-icon class=\"avatar-icon\" color=\"primary\" fxFlex=\"nogrow\">account_circle</mat-icon>\n\n </div>\n\n <div fxFlex=\"nogrow\" fxLayout=\"row\" fxLayoutAlign=\"center center\">\n\n <div fxFlex=\"nogrow\">\n <button (click)=\"signIn()\" color=\"primary\" fxFlex=\"nogrow\" mat-raised-button>\n <span fxLayout=\"row\" fxLayoutAlign=\"start center\" fxLayoutGap=\"16px\">\n <mat-icon fxFlex=\"nogrow\">login</mat-icon>\n <span fxFlex=\"nogrow\">Sign In</span>\n </span>\n </button>\n </div>\n\n </div>\n\n</div>\n\n", styles: [".inner{padding:64px;position:relative}.inner .header .avatar-icon{width:100px;height:100px;font-size:100px}\n"] }]
|
|
672
|
-
}], ctorParameters: function () { return [{ type: OAuthService }]; } });
|
|
673
|
-
|
|
674
|
-
const RXAP_O_AUTH_ROUTES = [
|
|
675
|
-
{
|
|
676
|
-
path: 'oauth',
|
|
677
|
-
component: ContainerComponent,
|
|
678
|
-
children: [
|
|
679
|
-
{
|
|
680
|
-
path: 'redirect',
|
|
681
|
-
component: SignInWithRedirectComponent
|
|
682
|
-
},
|
|
683
|
-
{
|
|
684
|
-
canActivate: [OAuthExtractGuard],
|
|
685
|
-
path: '',
|
|
686
|
-
component: LoadingComponent
|
|
687
|
-
},
|
|
688
|
-
{
|
|
689
|
-
path: '**',
|
|
690
|
-
redirectTo: ''
|
|
691
|
-
}
|
|
692
|
-
]
|
|
693
|
-
}
|
|
694
|
-
];
|
|
695
|
-
|
|
696
|
-
class ProfileResolve {
|
|
697
|
-
constructor(oAuthService, router, redirectLogin) {
|
|
698
|
-
this.oAuthService = oAuthService;
|
|
699
|
-
this.router = router;
|
|
700
|
-
this.redirectLogin = redirectLogin;
|
|
701
|
-
}
|
|
702
|
-
async resolve() {
|
|
703
|
-
const profile = await this.oAuthService.getProfile();
|
|
704
|
-
if (!profile) {
|
|
705
|
-
await this.router.navigate(this.redirectLogin);
|
|
706
|
-
}
|
|
707
|
-
return profile;
|
|
708
|
-
}
|
|
709
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ProfileResolve, deps: [{ token: OAuthService }, { token: Router }, { token: RXAP_O_AUTH_REDIRECT_SIGN_IN }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
710
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ProfileResolve, providedIn: 'root' }); }
|
|
711
|
-
}
|
|
712
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ProfileResolve, decorators: [{
|
|
713
|
-
type: Injectable,
|
|
714
|
-
args: [{ providedIn: 'root' }]
|
|
715
|
-
}], ctorParameters: function () { return [{ type: OAuthService, decorators: [{
|
|
716
|
-
type: Inject,
|
|
717
|
-
args: [OAuthService]
|
|
718
|
-
}] }, { type: i1$1.Router, decorators: [{
|
|
719
|
-
type: Inject,
|
|
720
|
-
args: [Router]
|
|
721
|
-
}] }, { type: undefined, decorators: [{
|
|
722
|
-
type: Inject,
|
|
723
|
-
args: [RXAP_O_AUTH_REDIRECT_SIGN_IN]
|
|
724
|
-
}] }]; } });
|
|
114
|
+
// region
|
|
115
|
+
// endregion
|
|
725
116
|
|
|
726
117
|
/**
|
|
727
118
|
* Generated bundle index. Do not edit.
|
|
728
119
|
*/
|
|
729
120
|
|
|
730
|
-
export {
|
|
121
|
+
export { AuthenticationGuard, AuthenticationService, ProvideAuth, withAuthConfig };
|
|
731
122
|
//# sourceMappingURL=rxap-oauth.mjs.map
|