@singularsystems/neo-core 0.10.66 → 0.10.67
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/dist/AppServices/Config/ConfigModel.d.ts +3 -2
- package/dist/AppServices/Config/ConfigModel.js +11 -0
- package/dist/AppServices/Config/ConfigService.js +2 -5
- package/dist/Security/IAuthenticationService.d.ts +5 -0
- package/dist/Security/Oidc/OidcAuthService.d.ts +8 -1
- package/dist/Security/Oidc/OidcAuthService.js +28 -1
- package/dist/Security/Oidc/OidcTypes.d.ts +23 -6
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface IConfigModel {
|
|
2
|
-
baseUrl: string;
|
|
2
|
+
readonly baseUrl: string;
|
|
3
3
|
/**
|
|
4
4
|
* True by default if the NODE_ENV environment variable is "development".
|
|
5
5
|
**/
|
|
@@ -12,9 +12,10 @@ export interface IConfigModel {
|
|
|
12
12
|
initialise(): void;
|
|
13
13
|
}
|
|
14
14
|
export default class ConfigModel implements IConfigModel {
|
|
15
|
-
|
|
15
|
+
private _baseUrl;
|
|
16
16
|
isDevelopment: boolean;
|
|
17
17
|
isTest: boolean;
|
|
18
18
|
get isTestOrDevelopment(): boolean;
|
|
19
|
+
get baseUrl(): string;
|
|
19
20
|
initialise(): void;
|
|
20
21
|
}
|
|
@@ -10,6 +10,17 @@ var ConfigModel = /** @class */ (function () {
|
|
|
10
10
|
enumerable: false,
|
|
11
11
|
configurable: true
|
|
12
12
|
});
|
|
13
|
+
Object.defineProperty(ConfigModel.prototype, "baseUrl", {
|
|
14
|
+
get: function () {
|
|
15
|
+
if (!this._baseUrl) {
|
|
16
|
+
var baseTag = document.getElementsByTagName('base')[0];
|
|
17
|
+
this._baseUrl = baseTag ? baseTag.getAttribute("href") || "" : "";
|
|
18
|
+
}
|
|
19
|
+
return this._baseUrl;
|
|
20
|
+
},
|
|
21
|
+
enumerable: false,
|
|
22
|
+
configurable: true
|
|
23
|
+
});
|
|
13
24
|
ConfigModel.prototype.initialise = function () {
|
|
14
25
|
};
|
|
15
26
|
return ConfigModel;
|
|
@@ -8,13 +8,11 @@ var ConfigService = /** @class */ (function () {
|
|
|
8
8
|
}
|
|
9
9
|
ConfigService.prototype.loadConfig = function (path) {
|
|
10
10
|
return __awaiter(this, void 0, void 0, function () {
|
|
11
|
-
var
|
|
11
|
+
var timestamp, response, error_1;
|
|
12
12
|
return __generator(this, function (_a) {
|
|
13
13
|
switch (_a.label) {
|
|
14
14
|
case 0:
|
|
15
|
-
|
|
16
|
-
baseUrl = baseTag ? baseTag.getAttribute("href") || "" : "";
|
|
17
|
-
path = path !== null && path !== void 0 ? path : "".concat(baseUrl, "/config.json");
|
|
15
|
+
path = path !== null && path !== void 0 ? path : "".concat(this.config.baseUrl, "/config.json");
|
|
18
16
|
_a.label = 1;
|
|
19
17
|
case 1:
|
|
20
18
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -25,7 +23,6 @@ var ConfigService = /** @class */ (function () {
|
|
|
25
23
|
// The raw parsed json objects properties are copied into the config model.
|
|
26
24
|
// It is up to the config model to transform its properties if required (in the initialise method).
|
|
27
25
|
Object.assign(this.config, response.data);
|
|
28
|
-
this.config.baseUrl = baseUrl;
|
|
29
26
|
this.config.initialise();
|
|
30
27
|
return [2 /*return*/, this.config];
|
|
31
28
|
case 3:
|
|
@@ -9,6 +9,11 @@ export default interface IAuthenticationService {
|
|
|
9
9
|
* Load a user from session storage if there is a stored token.
|
|
10
10
|
*/
|
|
11
11
|
loadUserFromSession(): Promise<IUser | null>;
|
|
12
|
+
/**
|
|
13
|
+
* Checks if the user is signed in, and if not, redirects to login.
|
|
14
|
+
* Returns true if the user is logged in.
|
|
15
|
+
*/
|
|
16
|
+
ensureSignedIn(redirectLocal?: string): boolean;
|
|
12
17
|
/**
|
|
13
18
|
* Starts the sign in process
|
|
14
19
|
* @param redirectLocal The path to redirect to after calling endSignIn
|
|
@@ -20,6 +20,7 @@ export default abstract class OidcAuthService<TUser extends OidcUser = OidcUser>
|
|
|
20
20
|
constructor(userManager: IUserManager, axios: AxiosInstance);
|
|
21
21
|
loadUserFromToken(): Promise<TUser | null>;
|
|
22
22
|
loadUserFromSession(): Promise<TUser | null>;
|
|
23
|
+
ensureSignedIn(redirectLocal?: string): boolean;
|
|
23
24
|
/**
|
|
24
25
|
* Redirect to identity server to get the auth token.
|
|
25
26
|
* @param redirectPath Local path to redirect to once login is complete.
|
|
@@ -40,7 +41,7 @@ export default abstract class OidcAuthService<TUser extends OidcUser = OidcUser>
|
|
|
40
41
|
protected createUser(user: IOidcUser): OidcUser;
|
|
41
42
|
private onUserUnloaded;
|
|
42
43
|
private setUser;
|
|
43
|
-
signinSilent(): Promise<IOidcUser>;
|
|
44
|
+
signinSilent(): Promise<IOidcUser | null>;
|
|
44
45
|
beginSignOut(): void;
|
|
45
46
|
endSignOut(): Promise<any>;
|
|
46
47
|
signOutLocal(): void;
|
|
@@ -57,4 +58,10 @@ export default abstract class OidcAuthService<TUser extends OidcUser = OidcUser>
|
|
|
57
58
|
revocation_endpoint: string;
|
|
58
59
|
introspection_endpoint: string;
|
|
59
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* If this is a silent sign in (based on the current uri), `endSignInSilent()` is called on the oidc client, and this method returns true.
|
|
63
|
+
* This should be called on startup of your app. If this returns true, don't continue with startup, since this iframe will be shortly disposed.
|
|
64
|
+
* @param silentRedirectRoute The app relative path used for silent sign in callbacks.
|
|
65
|
+
*/
|
|
66
|
+
static isSilentSignIn(silentRedirectRoute: string): boolean;
|
|
60
67
|
}
|
|
@@ -21,7 +21,10 @@ var OidcAuthService = /** @class */ (function () {
|
|
|
21
21
|
this.userManager = userManager;
|
|
22
22
|
this.userManager.events.addUserLoaded(this.onUserLoaded.bind(this));
|
|
23
23
|
this.userManager.events.addUserUnloaded(this.onUserUnloaded.bind(this));
|
|
24
|
-
this.userManager.
|
|
24
|
+
if (!this.userManager.settings.automaticSilentRenew) {
|
|
25
|
+
// If automaticSilentRenew is set to true, then the user manager will handle automatic renewal.
|
|
26
|
+
this.userManager.events.addAccessTokenExpiring(this.signinSilent.bind(this));
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
29
|
OidcAuthService.prototype.loadUserFromToken = function () {
|
|
27
30
|
return this.loadUserFromSession();
|
|
@@ -43,6 +46,16 @@ var OidcAuthService = /** @class */ (function () {
|
|
|
43
46
|
});
|
|
44
47
|
});
|
|
45
48
|
};
|
|
49
|
+
OidcAuthService.prototype.ensureSignedIn = function (redirectLocal) {
|
|
50
|
+
var settings = this.userManager.settings;
|
|
51
|
+
if (!this.isAuthenticated &&
|
|
52
|
+
(!settings.redirect_uri || !window.location.href.startsWith(settings.redirect_uri)) &&
|
|
53
|
+
(!settings.silent_redirect_uri || !window.location.href.startsWith(settings.silent_redirect_uri))) {
|
|
54
|
+
this.beginSignIn(redirectLocal);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
};
|
|
46
59
|
/**
|
|
47
60
|
* Redirect to identity server to get the auth token.
|
|
48
61
|
* @param redirectPath Local path to redirect to once login is complete.
|
|
@@ -175,6 +188,20 @@ var OidcAuthService = /** @class */ (function () {
|
|
|
175
188
|
introspection_endpoint: identityServerUrl + "/connect/introspect"
|
|
176
189
|
};
|
|
177
190
|
};
|
|
191
|
+
/**
|
|
192
|
+
* If this is a silent sign in (based on the current uri), `endSignInSilent()` is called on the oidc client, and this method returns true.
|
|
193
|
+
* This should be called on startup of your app. If this returns true, don't continue with startup, since this iframe will be shortly disposed.
|
|
194
|
+
* @param silentRedirectRoute The app relative path used for silent sign in callbacks.
|
|
195
|
+
*/
|
|
196
|
+
OidcAuthService.isSilentSignIn = function (silentRedirectRoute) {
|
|
197
|
+
var config = Misc.Globals.appService.get(NeoTypes.Config.ConfigModel);
|
|
198
|
+
var silentRedirectUri = "".concat(window.location.origin).concat(config.baseUrl).concat(silentRedirectRoute);
|
|
199
|
+
if (window.location.href.startsWith(silentRedirectUri)) {
|
|
200
|
+
Misc.Globals.appService.get(NeoTypes.Security.AuthenticationService).endSignInSilent();
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
return false;
|
|
204
|
+
};
|
|
178
205
|
__decorate([
|
|
179
206
|
Observable(),
|
|
180
207
|
__metadata("design:type", Object)
|
|
@@ -1,26 +1,43 @@
|
|
|
1
1
|
export interface IOidcUser {
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* A JSON Web Token (JWT). Only provided if `openid` scope was requested.
|
|
4
|
+
* The application can access the data decoded by using the `profile` property.
|
|
5
|
+
*/
|
|
6
|
+
id_token?: string;
|
|
7
|
+
/** Typically "Bearer" */
|
|
3
8
|
token_type: string;
|
|
9
|
+
/**
|
|
10
|
+
* The requested access token returned from the OIDC provider. The application can use this token to
|
|
11
|
+
* authenticate itself to the secured resource.
|
|
12
|
+
*/
|
|
4
13
|
access_token: string;
|
|
14
|
+
/** The scopes that the requested access token is valid for. */
|
|
15
|
+
scope?: string;
|
|
5
16
|
profile: any;
|
|
6
|
-
expires_at
|
|
17
|
+
expires_at?: number;
|
|
7
18
|
/** State passed to IDS which is returned to us. */
|
|
8
19
|
state: any;
|
|
9
20
|
readonly expired: boolean | undefined;
|
|
10
21
|
}
|
|
11
22
|
export interface IUserManager {
|
|
12
23
|
events: IUserManagerEvents;
|
|
24
|
+
settings: IUserManagerSettings;
|
|
13
25
|
signinRedirect(args?: any): Promise<any>;
|
|
14
26
|
signinRedirectCallback(url?: string): Promise<IOidcUser>;
|
|
15
27
|
signoutRedirect(args?: any): Promise<any>;
|
|
16
28
|
signoutRedirectCallback(url?: string): Promise<any>;
|
|
17
|
-
signinSilent(args?: any): Promise<IOidcUser>;
|
|
29
|
+
signinSilent(args?: any): Promise<IOidcUser | null>;
|
|
18
30
|
signinSilentCallback(url?: string): Promise<any>;
|
|
19
31
|
clearStaleState(): Promise<void>;
|
|
20
32
|
getUser(): Promise<IOidcUser | null>;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
}
|
|
34
|
+
export interface IUserManagerSettings {
|
|
35
|
+
/** The redirect URI of your client application to receive a response from the OIDC/OAuth2 provider */
|
|
36
|
+
redirect_uri?: string;
|
|
37
|
+
/** Flag to indicate if there should be an automatic attempt to renew the access token prior to its expiration */
|
|
38
|
+
automaticSilentRenew?: boolean;
|
|
39
|
+
/** The URL for the page containing the code handling the silent renew */
|
|
40
|
+
silent_redirect_uri?: string;
|
|
24
41
|
}
|
|
25
42
|
export interface IUserManagerEvents {
|
|
26
43
|
addUserLoaded(callback: (...ev: any[]) => void): void;
|