@hmcts/opal-frontend-common-node 0.0.12 → 0.0.14
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/interfaces/index.d.ts +1 -2
- package/interfaces/index.d.ts.map +1 -1
- package/interfaces/index.js +1 -2
- package/interfaces/index.js.map +1 -1
- package/interfaces/routes-config.d.ts +5 -0
- package/interfaces/routes-config.d.ts.map +1 -1
- package/interfaces/routes-config.js +5 -0
- package/interfaces/routes-config.js.map +1 -1
- package/interfaces/securityToken.d.ts +1 -2
- package/interfaces/securityToken.d.ts.map +1 -1
- package/interfaces/securityToken.js.map +1 -1
- package/interfaces/session-config.d.ts +0 -1
- package/interfaces/session-config.d.ts.map +1 -1
- package/interfaces/session-config.js +0 -1
- package/interfaces/session-config.js.map +1 -1
- package/package.json +4 -3
- package/routes/index.d.ts +1 -0
- package/routes/index.d.ts.map +1 -1
- package/routes/index.js +38 -23
- package/routes/index.js.map +1 -1
- package/session/index.d.ts +1 -2
- package/session/index.d.ts.map +1 -1
- package/session/index.js +1 -2
- package/session/index.js.map +1 -1
- package/session.d.ts +2 -2
- package/sso/index.d.ts +2 -2
- package/sso/index.d.ts.map +1 -1
- package/sso/index.js +2 -2
- package/sso/index.js.map +1 -1
- package/sso/sso-authenticated.d.ts +24 -0
- package/sso/sso-authenticated.d.ts.map +1 -1
- package/sso/sso-authenticated.js +26 -3
- package/sso/sso-authenticated.js.map +1 -1
- package/sso/sso-configuration.d.ts +12 -0
- package/sso/sso-configuration.d.ts.map +1 -0
- package/sso/sso-configuration.js +44 -0
- package/sso/sso-configuration.js.map +1 -0
- package/sso/sso-login-callback.d.ts +21 -3
- package/sso/sso-login-callback.d.ts.map +1 -1
- package/sso/sso-login-callback.js +72 -19
- package/sso/sso-login-callback.js.map +1 -1
- package/sso/sso-login.d.ts +17 -2
- package/sso/sso-login.d.ts.map +1 -1
- package/sso/sso-login.js +24 -17
- package/sso/sso-login.js.map +1 -1
- package/sso/sso-logout-callback.d.ts +10 -0
- package/sso/sso-logout-callback.d.ts.map +1 -1
- package/sso/sso-logout-callback.js +10 -0
- package/sso/sso-logout-callback.js.map +1 -1
- package/sso/sso-logout.d.ts +14 -3
- package/sso/sso-logout.d.ts.map +1 -1
- package/sso/sso-logout.js +19 -25
- package/sso/sso-logout.js.map +1 -1
- package/stubs/sso/sso-authenticated.stub.d.ts +18 -0
- package/stubs/sso/sso-authenticated.stub.d.ts.map +1 -1
- package/stubs/sso/sso-authenticated.stub.js +20 -3
- package/stubs/sso/sso-authenticated.stub.js.map +1 -1
- package/stubs/sso/sso-login-callback.stub.d.ts +17 -0
- package/stubs/sso/sso-login-callback.stub.d.ts.map +1 -1
- package/stubs/sso/sso-login-callback.stub.js +37 -6
- package/stubs/sso/sso-login-callback.stub.js.map +1 -1
- package/stubs/sso/sso-login.stub.d.ts +11 -0
- package/stubs/sso/sso-login.stub.d.ts.map +1 -1
- package/stubs/sso/sso-login.stub.js +17 -8
- package/stubs/sso/sso-login.stub.js.map +1 -1
- package/stubs/sso/sso-logout-callback.stub.d.ts +12 -0
- package/stubs/sso/sso-logout-callback.stub.d.ts.map +1 -1
- package/stubs/sso/sso-logout-callback.stub.js +12 -0
- package/stubs/sso/sso-logout-callback.stub.js.map +1 -1
- package/stubs/sso/sso-logout.stub.d.ts +14 -2
- package/stubs/sso/sso-logout.stub.d.ts.map +1 -1
- package/stubs/sso/sso-logout.stub.js +21 -3
- package/stubs/sso/sso-logout.stub.js.map +1 -1
- package/interfaces/userState.d.ts +0 -16
- package/interfaces/userState.d.ts.map +0 -1
- package/interfaces/userState.js +0 -16
- package/interfaces/userState.js.map +0 -1
- package/session/session-user-state/index.d.ts +0 -4
- package/session/session-user-state/index.d.ts.map +0 -1
- package/session/session-user-state/index.js +0 -20
- package/session/session-user-state/index.js.map +0 -1
package/interfaces/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import UserState from './userState';
|
|
2
1
|
import SecurityToken from './securityToken';
|
|
3
2
|
import launchDarklyConfig from './launch-darkly-config';
|
|
4
3
|
import appInsightsConfig from './app-insights-config';
|
|
@@ -8,5 +7,5 @@ import SessionStorageConfiguration from './session-storage-config';
|
|
|
8
7
|
import RoutesConfiguration from './routes-config';
|
|
9
8
|
import SsoConfiguration from './sso-config';
|
|
10
9
|
import SessionConfiguration from './session-config';
|
|
11
|
-
export {
|
|
10
|
+
export { SecurityToken, launchDarklyConfig, appInsightsConfig, TransferServerState, ExpiryConfiguration, SessionStorageConfiguration, RoutesConfiguration, SsoConfiguration, SessionConfiguration, };
|
|
12
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,kBAAkB,MAAM,wBAAwB,CAAC;AACxD,OAAO,iBAAiB,MAAM,uBAAuB,CAAC;AACtD,OAAO,mBAAmB,MAAM,yBAAyB,CAAC;AAC1D,OAAO,mBAAmB,MAAM,yBAAyB,CAAC;AAC1D,OAAO,2BAA2B,MAAM,0BAA0B,CAAC;AACnE,OAAO,mBAAmB,MAAM,iBAAiB,CAAC;AAClD,OAAO,gBAAgB,MAAM,cAAc,CAAC;AAC5C,OAAO,oBAAoB,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,GACrB,CAAC"}
|
package/interfaces/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import UserState from './userState';
|
|
2
1
|
import SecurityToken from './securityToken';
|
|
3
2
|
import launchDarklyConfig from './launch-darkly-config';
|
|
4
3
|
import appInsightsConfig from './app-insights-config';
|
|
@@ -8,5 +7,5 @@ import SessionStorageConfiguration from './session-storage-config';
|
|
|
8
7
|
import RoutesConfiguration from './routes-config';
|
|
9
8
|
import SsoConfiguration from './sso-config';
|
|
10
9
|
import SessionConfiguration from './session-config';
|
|
11
|
-
export {
|
|
10
|
+
export { SecurityToken, launchDarklyConfig, appInsightsConfig, TransferServerState, ExpiryConfiguration, SessionStorageConfiguration, RoutesConfiguration, SsoConfiguration, SessionConfiguration, };
|
|
12
11
|
//# sourceMappingURL=index.js.map
|
package/interfaces/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,kBAAkB,MAAM,wBAAwB,CAAC;AACxD,OAAO,iBAAiB,MAAM,uBAAuB,CAAC;AACtD,OAAO,mBAAmB,MAAM,yBAAyB,CAAC;AAC1D,OAAO,mBAAmB,MAAM,yBAAyB,CAAC;AAC1D,OAAO,2BAA2B,MAAM,0BAA0B,CAAC;AACnE,OAAO,mBAAmB,MAAM,iBAAiB,CAAC;AAClD,OAAO,gBAAgB,MAAM,cAAc,CAAC;AAC5C,OAAO,oBAAoB,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,GACrB,CAAC"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
declare class RoutesConfiguration {
|
|
2
2
|
opalApiTarget: string;
|
|
3
3
|
opalFinesServiceTarget: string;
|
|
4
|
+
opalUserServiceTarget: string;
|
|
4
5
|
frontendHostname: string;
|
|
5
6
|
prefix: string;
|
|
7
|
+
clientId: string;
|
|
8
|
+
clientSecret: string;
|
|
9
|
+
tenantId: string;
|
|
10
|
+
microsoftUrl: string;
|
|
6
11
|
}
|
|
7
12
|
export default RoutesConfiguration;
|
|
8
13
|
//# sourceMappingURL=routes-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes-config.d.ts","sourceRoot":"","sources":["../../src/interfaces/routes-config.ts"],"names":[],"mappings":"AAAA,cAAM,mBAAmB;IACvB,aAAa,EAAG,MAAM,CAAC;IACvB,sBAAsB,EAAG,MAAM,CAAC;IAChC,gBAAgB,EAAG,MAAM,CAAC;IAC1B,MAAM,EAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"routes-config.d.ts","sourceRoot":"","sources":["../../src/interfaces/routes-config.ts"],"names":[],"mappings":"AAAA,cAAM,mBAAmB;IACvB,aAAa,EAAG,MAAM,CAAC;IACvB,sBAAsB,EAAG,MAAM,CAAC;IAChC,qBAAqB,EAAG,MAAM,CAAC;IAC/B,gBAAgB,EAAG,MAAM,CAAC;IAC1B,MAAM,EAAG,MAAM,CAAC;IAChB,QAAQ,EAAG,MAAM,CAAC;IAClB,YAAY,EAAG,MAAM,CAAC;IACtB,QAAQ,EAAG,MAAM,CAAC;IAClB,YAAY,EAAG,MAAM,CAAC;CACvB;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
class RoutesConfiguration {
|
|
2
2
|
opalApiTarget;
|
|
3
3
|
opalFinesServiceTarget;
|
|
4
|
+
opalUserServiceTarget;
|
|
4
5
|
frontendHostname;
|
|
5
6
|
prefix;
|
|
7
|
+
clientId;
|
|
8
|
+
clientSecret;
|
|
9
|
+
tenantId;
|
|
10
|
+
microsoftUrl;
|
|
6
11
|
}
|
|
7
12
|
export default RoutesConfiguration;
|
|
8
13
|
//# sourceMappingURL=routes-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes-config.js","sourceRoot":"","sources":["../../src/interfaces/routes-config.ts"],"names":[],"mappings":"AAAA,MAAM,mBAAmB;IACvB,aAAa,CAAU;IACvB,sBAAsB,CAAU;IAChC,gBAAgB,CAAU;IAC1B,MAAM,CAAU;
|
|
1
|
+
{"version":3,"file":"routes-config.js","sourceRoot":"","sources":["../../src/interfaces/routes-config.ts"],"names":[],"mappings":"AAAA,MAAM,mBAAmB;IACvB,aAAa,CAAU;IACvB,sBAAsB,CAAU;IAChC,qBAAqB,CAAU;IAC/B,gBAAgB,CAAU;IAC1B,MAAM,CAAU;IAChB,QAAQ,CAAU;IAClB,YAAY,CAAU;IACtB,QAAQ,CAAU;IAClB,YAAY,CAAU;CACvB;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"securityToken.d.ts","sourceRoot":"","sources":["../../src/interfaces/securityToken.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"securityToken.d.ts","sourceRoot":"","sources":["../../src/interfaces/securityToken.ts"],"names":[],"mappings":"AAAA,cAAM,aAAa;IACjB,UAAU,EAAE,SAAS,CAAC;IACtB,YAAY,EAAG,MAAM,CAAC;CACvB;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"securityToken.js","sourceRoot":"","sources":["../../src/interfaces/securityToken.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"securityToken.js","sourceRoot":"","sources":["../../src/interfaces/securityToken.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa;IACjB,UAAU,CAAY;IACtB,YAAY,CAAU;CACvB;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-config.d.ts","sourceRoot":"","sources":["../../src/interfaces/session-config.ts"],"names":[],"mappings":"AAAA,cAAM,oBAAoB;IACxB,
|
|
1
|
+
{"version":3,"file":"session-config.d.ts","sourceRoot":"","sources":["../../src/interfaces/session-config.ts"],"names":[],"mappings":"AAAA,cAAM,oBAAoB;IACxB,gBAAgB,EAAG,MAAM,CAAC;CAC3B;AACD,eAAe,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-config.js","sourceRoot":"","sources":["../../src/interfaces/session-config.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB;IACxB,
|
|
1
|
+
{"version":3,"file":"session-config.js","sourceRoot":"","sources":["../../src/interfaces/session-config.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB;IACxB,gBAAgB,CAAU;CAC3B;AACD,eAAe,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmcts/opal-frontend-common-node",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.14",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Common nodejs library components for opal",
|
|
7
7
|
"main": "dist/index",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"audit:check": "yarn audit --recursive --environment production --json > yarn-known-issues-current || true && jq -s '[.[] | select(.type==\"auditAdvisory\") | .data.advisory.id] | sort' yarn-known-issues-current > current-ids.json && jq -s '[.[] | select(.type==\"auditAdvisory\") | .data.advisory.id] | sort' yarn-known-issues > known-ids.json && diff -q known-ids.json current-ids.json || (echo '❌ New vulnerabilities detected. Please review.' && exit 1)"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@azure/msal-browser": "^4.11.0",
|
|
19
20
|
"@hmcts/info-provider": "^1.1.0",
|
|
20
21
|
"@hmcts/nodejs-healthcheck": "^1.8.5",
|
|
21
22
|
"@hmcts/nodejs-logging": "^4.0.4",
|
|
@@ -44,8 +45,8 @@
|
|
|
44
45
|
"@types/luxon": "^3.4.2",
|
|
45
46
|
"@types/node": "^22.0.0",
|
|
46
47
|
"@types/session-file-store": "^1.2.5",
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
48
|
-
"@typescript-eslint/parser": "8.
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "8.44.1",
|
|
49
|
+
"@typescript-eslint/parser": "8.44.1",
|
|
49
50
|
"eslint": "^9.0.0",
|
|
50
51
|
"eslint-plugin-prettier": "^5.2.6",
|
|
51
52
|
"typescript": "~5.9.0",
|
package/routes/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import SsoConfiguration from '@hmcts/opal-frontend-common-node/interfaces/sso-co
|
|
|
5
5
|
import SessionConfiguration from '@hmcts/opal-frontend-common-node/interfaces/session-config';
|
|
6
6
|
export declare class Routes {
|
|
7
7
|
private setupSSORoutes;
|
|
8
|
+
private setupStubRoutes;
|
|
8
9
|
enableFor(app: Application, ssoEnabled: boolean, expiryConfiguration: ExpiryConfiguration, routesConfiguration: RoutesConfiguration, sessionConfiguration: SessionConfiguration, ssoConfiguration: SsoConfiguration): void;
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
package/routes/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAQtC,OAAO,mBAAmB,MAAM,mEAAmE,CAAC;AACpG,OAAO,mBAAmB,MAAM,2DAA2D,CAAC;AAC5F,OAAO,gBAAgB,MAAM,wDAAwD,CAAC;AACtF,OAAO,oBAAoB,MAAM,4DAA4D,CAAC;AAG9F,qBAAa,MAAM;IACjB,OAAO,CAAC,cAAc;IAoDtB,OAAO,CAAC,eAAe;IA2BhB,SAAS,CACd,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,OAAO,EACnB,mBAAmB,EAAE,mBAAmB,EACxC,mBAAmB,EAAE,mBAAmB,EACxC,oBAAoB,EAAE,oBAAoB,EAC1C,gBAAgB,EAAE,gBAAgB,GACjC,IAAI;CAqBR"}
|
package/routes/index.js
CHANGED
|
@@ -1,35 +1,50 @@
|
|
|
1
1
|
import bodyParser from 'body-parser';
|
|
2
|
-
import { ssoAuthenticated,
|
|
3
|
-
import
|
|
2
|
+
import { ssoAuthenticated, ssoLogin, ssoLoginCallback } from '../sso';
|
|
3
|
+
import createMsalInstance from '../sso/sso-configuration';
|
|
4
|
+
import ssoLogout from '../sso/sso-logout';
|
|
5
|
+
import { ssoAuthenticatedStub, ssoLogoutCallbackStub, ssoLoginStub, ssoLoginCallbackStub } from '../stubs/sso';
|
|
4
6
|
import sessionExpiry from '@hmcts/opal-frontend-common-node/session/session-expiry';
|
|
5
|
-
import
|
|
7
|
+
import ssoLogoutCallback from '../sso/sso-logout-callback';
|
|
6
8
|
export class Routes {
|
|
7
|
-
setupSSORoutes(app,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const logout = ssoEnabled ? ssoLogout : ssoLogoutStub;
|
|
11
|
-
const logoutCallback = ssoEnabled ? ssoLogoutCallback : ssoLogoutCallbackStub;
|
|
12
|
-
const authenticated = ssoEnabled ? ssoAuthenticated : ssoAuthenticatedStub;
|
|
13
|
-
const loginCallbackType = ssoEnabled ? 'post' : 'get';
|
|
14
|
-
app.get(ssoConfiguration.login, (req, res, next) => login(req, res, next, opalApiUrl, frontendHostname));
|
|
15
|
-
const routePath = ssoConfiguration.loginCallback;
|
|
16
|
-
const callbackHandler = (req, res, next) => loginCallback(req, res, next, opalApiUrl);
|
|
17
|
-
if (loginCallbackType === 'post') {
|
|
18
|
-
app.post(routePath, callbackHandler);
|
|
9
|
+
setupSSORoutes(app, ssoConfiguration, routesConfiguration) {
|
|
10
|
+
if (!routesConfiguration.clientId || !routesConfiguration.clientSecret || !routesConfiguration.tenantId) {
|
|
11
|
+
throw new Error('Missing essential SSO configuration fields: clientId, clientSecret, or tenantId');
|
|
19
12
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
app.get(ssoConfiguration.
|
|
24
|
-
|
|
25
|
-
app.
|
|
13
|
+
// SSO CONFIGURATION
|
|
14
|
+
const confidentialClient = createMsalInstance(routesConfiguration.clientId, routesConfiguration.clientSecret, routesConfiguration.tenantId, routesConfiguration.microsoftUrl);
|
|
15
|
+
// LOGIN
|
|
16
|
+
app.get(ssoConfiguration.login, (req, res, next) => ssoLogin(res, next, confidentialClient, routesConfiguration.frontendHostname, ssoConfiguration.loginCallback));
|
|
17
|
+
// LOGIN CALLBACK
|
|
18
|
+
app.post(ssoConfiguration.loginCallback, (req, res) => ssoLoginCallback(req, res, confidentialClient, routesConfiguration.clientId, routesConfiguration.frontendHostname, ssoConfiguration.loginCallback));
|
|
19
|
+
// LOGOUT
|
|
20
|
+
app.get(ssoConfiguration.logout, (req, res) => ssoLogout(res, `${routesConfiguration.microsoftUrl}${routesConfiguration.tenantId}`, `${routesConfiguration.frontendHostname}${ssoConfiguration.logoutCallback}`));
|
|
21
|
+
// LOGOUT CALLBACK
|
|
22
|
+
app.get(ssoConfiguration.logoutCallback, (req, res, next) => ssoLogoutCallback(req, res, next, routesConfiguration.prefix));
|
|
23
|
+
// AUTHENTICATED
|
|
24
|
+
app.get(ssoConfiguration.authenticated, (req, res) => ssoAuthenticated(req, res));
|
|
25
|
+
}
|
|
26
|
+
setupStubRoutes(app, ssoConfiguration, routesConfiguration) {
|
|
27
|
+
// LOGIN
|
|
28
|
+
app.get(ssoConfiguration.login, (req, res, next) => ssoLoginStub(req, res, next));
|
|
29
|
+
// LOGIN CALLBACK
|
|
30
|
+
app.get(ssoConfiguration.loginCallback, (req, res, next) => ssoLoginCallbackStub(req, res, next, routesConfiguration.opalApiTarget));
|
|
31
|
+
// LOGOUT
|
|
32
|
+
app.get(ssoConfiguration.logout, (req, res, next) => ssoLogoutCallbackStub(req, res, next, routesConfiguration.prefix));
|
|
33
|
+
// LOGOUT CALLBACK
|
|
34
|
+
app.get(ssoConfiguration.logoutCallback, (req, res, next) => ssoLogoutCallbackStub(req, res, next, routesConfiguration.prefix));
|
|
35
|
+
// AUTHENTICATED
|
|
36
|
+
app.get(ssoConfiguration.authenticated, (req, res) => ssoAuthenticatedStub(req, res));
|
|
26
37
|
}
|
|
27
38
|
enableFor(app, ssoEnabled, expiryConfiguration, routesConfiguration, sessionConfiguration, ssoConfiguration) {
|
|
28
39
|
// Declare use of body-parser AFTER the use of proxy https://github.com/villadora/express-http-proxy
|
|
29
40
|
app.use(bodyParser.json());
|
|
30
41
|
app.use(bodyParser.urlencoded({ extended: false }));
|
|
31
|
-
|
|
32
|
-
|
|
42
|
+
if (ssoEnabled) {
|
|
43
|
+
this.setupSSORoutes(app, ssoConfiguration, routesConfiguration);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.setupStubRoutes(app, ssoConfiguration, routesConfiguration);
|
|
47
|
+
}
|
|
33
48
|
app.get(sessionConfiguration.sessionExpiryUrl, (req, res) => sessionExpiry(req, res, expiryConfiguration.testMode, expiryConfiguration.expiryTimeInMilliseconds, expiryConfiguration.warningThresholdInMilliseconds));
|
|
34
49
|
}
|
|
35
50
|
}
|
package/routes/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,EA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|
package/session/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import SessionStorage from './session-storage';
|
|
2
2
|
import sessionExpiry from './session-expiry';
|
|
3
|
-
|
|
4
|
-
export { SessionStorage, sessionUserState, sessionExpiry };
|
|
3
|
+
export { SessionStorage, sessionExpiry };
|
|
5
4
|
//# sourceMappingURL=index.d.ts.map
|
package/session/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,aAAa,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC"}
|
package/session/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import SessionStorage from './session-storage';
|
|
2
2
|
import sessionExpiry from './session-expiry';
|
|
3
|
-
|
|
4
|
-
export { SessionStorage, sessionUserState, sessionExpiry };
|
|
3
|
+
export { SessionStorage, sessionExpiry };
|
|
5
4
|
//# sourceMappingURL=index.js.map
|
package/session/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,aAAa,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC"}
|
package/session.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SecurityToken
|
|
1
|
+
import { SecurityToken } from './interfaces/index';
|
|
2
2
|
|
|
3
3
|
declare module 'express-session' {
|
|
4
4
|
interface SessionData {
|
|
5
|
-
user_state:
|
|
5
|
+
user_state: undefined;
|
|
6
6
|
securityToken: SecurityToken | undefined;
|
|
7
7
|
}
|
|
8
8
|
}
|
package/sso/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ssoLogin from './sso-login';
|
|
2
2
|
import ssoLogout from './sso-logout';
|
|
3
3
|
import ssoLoginCallback from './sso-login-callback';
|
|
4
|
-
import ssoLogoutCallback from './sso-logout-callback';
|
|
5
4
|
import ssoAuthenticated from './sso-authenticated';
|
|
6
|
-
|
|
5
|
+
import ssoConfig from './sso-configuration';
|
|
6
|
+
export { ssoLogin, ssoLoginCallback, ssoLogout, ssoAuthenticated, ssoConfig };
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/sso/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sso/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sso/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AACpD,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC"}
|
package/sso/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ssoLogin from './sso-login';
|
|
2
2
|
import ssoLogout from './sso-logout';
|
|
3
3
|
import ssoLoginCallback from './sso-login-callback';
|
|
4
|
-
import ssoLogoutCallback from './sso-logout-callback';
|
|
5
4
|
import ssoAuthenticated from './sso-authenticated';
|
|
6
|
-
|
|
5
|
+
import ssoConfig from './sso-configuration';
|
|
6
|
+
export { ssoLogin, ssoLoginCallback, ssoLogout, ssoAuthenticated, ssoConfig };
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/sso/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sso/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sso/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AACpD,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
import { Request, Response } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Express handler that verifies whether the current session has a valid (non-expired) access token.
|
|
4
|
+
*
|
|
5
|
+
* Behavior:
|
|
6
|
+
* - Reads the access token from `req.session.securityToken?.access_token`.
|
|
7
|
+
* - Prevents caching of the endpoint by setting the `Cache-Control: no-store, must-revalidate` header.
|
|
8
|
+
* - If the token is missing or expired (determined by `Jwt.isJwtExpired`), responds with HTTP 401 and sends `false`.
|
|
9
|
+
* - If the token is present and not expired, responds with HTTP 200 and sends `true`.
|
|
10
|
+
*
|
|
11
|
+
* @param req - Express Request; expected to contain `session.securityToken?.access_token` (string).
|
|
12
|
+
* @param res - Express Response used to set headers, status code, and send a boolean result.
|
|
13
|
+
* @returns void
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* This endpoint is a lightweight authentication status check and has the side-effect of modifying response headers
|
|
17
|
+
* and sending an HTTP status and boolean payload. It relies on `Jwt.isJwtExpired` for token expiry checks.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // GET /sso/authenticated
|
|
21
|
+
* // -> 200 true (valid token)
|
|
22
|
+
* // -> 401 false (missing or expired token)
|
|
23
|
+
*
|
|
24
|
+
* @see Jwt.isJwtExpired
|
|
25
|
+
*/
|
|
2
26
|
declare const _default: (req: Request, res: Response) => void;
|
|
3
27
|
export default _default;
|
|
4
28
|
//# sourceMappingURL=sso-authenticated.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sso-authenticated.d.ts","sourceRoot":"","sources":["../../src/sso/sso-authenticated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"sso-authenticated.d.ts","sourceRoot":"","sources":["../../src/sso/sso-authenticated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAG5C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;yBACa,KAAK,OAAO,EAAE,KAAK,QAAQ;AAA3C,wBAWE"}
|
package/sso/sso-authenticated.js
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
import { Jwt } from '../utils';
|
|
2
|
+
/**
|
|
3
|
+
* Express handler that verifies whether the current session has a valid (non-expired) access token.
|
|
4
|
+
*
|
|
5
|
+
* Behavior:
|
|
6
|
+
* - Reads the access token from `req.session.securityToken?.access_token`.
|
|
7
|
+
* - Prevents caching of the endpoint by setting the `Cache-Control: no-store, must-revalidate` header.
|
|
8
|
+
* - If the token is missing or expired (determined by `Jwt.isJwtExpired`), responds with HTTP 401 and sends `false`.
|
|
9
|
+
* - If the token is present and not expired, responds with HTTP 200 and sends `true`.
|
|
10
|
+
*
|
|
11
|
+
* @param req - Express Request; expected to contain `session.securityToken?.access_token` (string).
|
|
12
|
+
* @param res - Express Response used to set headers, status code, and send a boolean result.
|
|
13
|
+
* @returns void
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* This endpoint is a lightweight authentication status check and has the side-effect of modifying response headers
|
|
17
|
+
* and sending an HTTP status and boolean payload. It relies on `Jwt.isJwtExpired` for token expiry checks.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // GET /sso/authenticated
|
|
21
|
+
* // -> 200 true (valid token)
|
|
22
|
+
* // -> 401 false (missing or expired token)
|
|
23
|
+
*
|
|
24
|
+
* @see Jwt.isJwtExpired
|
|
25
|
+
*/
|
|
2
26
|
export default (req, res) => {
|
|
3
|
-
const
|
|
4
|
-
const userId = req.session.securityToken?.user_state?.user_id;
|
|
27
|
+
const accessToken = req.session.securityToken?.access_token;
|
|
5
28
|
// Don't allow caching of this endpoint
|
|
6
29
|
res.header('Cache-Control', 'no-store, must-revalidate');
|
|
7
|
-
if (
|
|
30
|
+
if (!accessToken || Jwt.isJwtExpired(accessToken)) {
|
|
8
31
|
res.status(401).send(false);
|
|
9
32
|
}
|
|
10
33
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sso-authenticated.js","sourceRoot":"","sources":["../../src/sso/sso-authenticated.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,eAAe,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE;IAC7C,MAAM,
|
|
1
|
+
{"version":3,"file":"sso-authenticated.js","sourceRoot":"","sources":["../../src/sso/sso-authenticated.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAe,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE;IAC7C,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC;IAE5D,uCAAuC;IACvC,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,2BAA2B,CAAC,CAAC;IAEzD,IAAI,CAAC,WAAW,IAAI,GAAG,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC;QAClD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ConfidentialClientApplication } from '@azure/msal-node';
|
|
2
|
+
/**
|
|
3
|
+
* Creates and configures a new instance of `ConfidentialClientApplication` for Microsoft SSO authentication.
|
|
4
|
+
*
|
|
5
|
+
* @param clientId - The client (application) ID registered in Azure AD.
|
|
6
|
+
* @param clientSecret - The client secret associated with the application.
|
|
7
|
+
* @param tenantId - The Azure AD tenant ID.
|
|
8
|
+
* @param microsoftUrl - The base Microsoft authority URL (e.g., "https://login.microsoftonline.com/").
|
|
9
|
+
* @returns A configured `ConfidentialClientApplication` instance for use with MSAL.
|
|
10
|
+
*/
|
|
11
|
+
export default function ssoConfig(clientId: string, clientSecret: string, tenantId: string, microsoftUrl: string): ConfidentialClientApplication;
|
|
12
|
+
//# sourceMappingURL=sso-configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sso-configuration.d.ts","sourceRoot":"","sources":["../../src/sso/sso-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAA2B,MAAM,kBAAkB,CAAC;AAG1F;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,6BAA6B,CAiC/B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ConfidentialClientApplication, LogLevel } from '@azure/msal-node';
|
|
2
|
+
import { Logger } from '@hmcts/nodejs-logging';
|
|
3
|
+
/**
|
|
4
|
+
* Creates and configures a new instance of `ConfidentialClientApplication` for Microsoft SSO authentication.
|
|
5
|
+
*
|
|
6
|
+
* @param clientId - The client (application) ID registered in Azure AD.
|
|
7
|
+
* @param clientSecret - The client secret associated with the application.
|
|
8
|
+
* @param tenantId - The Azure AD tenant ID.
|
|
9
|
+
* @param microsoftUrl - The base Microsoft authority URL (e.g., "https://login.microsoftonline.com/").
|
|
10
|
+
* @returns A configured `ConfidentialClientApplication` instance for use with MSAL.
|
|
11
|
+
*/
|
|
12
|
+
export default function ssoConfig(clientId, clientSecret, tenantId, microsoftUrl) {
|
|
13
|
+
const logger = Logger.getLogger('sso-msal-configuration');
|
|
14
|
+
const msalConfig = {
|
|
15
|
+
auth: {
|
|
16
|
+
clientId,
|
|
17
|
+
authority: microsoftUrl + tenantId,
|
|
18
|
+
clientSecret,
|
|
19
|
+
},
|
|
20
|
+
system: {
|
|
21
|
+
loggerOptions: {
|
|
22
|
+
loggerCallback(logLevel, message, containsPii) {
|
|
23
|
+
if (containsPii) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
switch (logLevel) {
|
|
27
|
+
case LogLevel.Error:
|
|
28
|
+
logger.error('Error on SSO Configuration:', message);
|
|
29
|
+
break;
|
|
30
|
+
case LogLevel.Warning:
|
|
31
|
+
case LogLevel.Info:
|
|
32
|
+
case LogLevel.Verbose:
|
|
33
|
+
default:
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
piiLoggingEnabled: false,
|
|
38
|
+
logLevel: LogLevel.Verbose,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
return new ConfidentialClientApplication(msalConfig);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=sso-configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sso-configuration.js","sourceRoot":"","sources":["../../src/sso/sso-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAiB,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAgB,EAChB,YAAoB,EACpB,QAAgB,EAChB,YAAoB;IAEpB,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAkB;QAChC,IAAI,EAAE;YACJ,QAAQ;YACR,SAAS,EAAE,YAAY,GAAG,QAAQ;YAClC,YAAY;SACb;QACD,MAAM,EAAE;YACN,aAAa,EAAE;gBACb,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW;oBAC3C,IAAI,WAAW,EAAE,CAAC;wBAChB,OAAO;oBACT,CAAC;oBAED,QAAQ,QAAQ,EAAE,CAAC;wBACjB,KAAK,QAAQ,CAAC,KAAK;4BACjB,MAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE,OAAO,CAAC,CAAC;4BACrD,MAAM;wBACR,KAAK,QAAQ,CAAC,OAAO,CAAC;wBACtB,KAAK,QAAQ,CAAC,IAAI,CAAC;wBACnB,KAAK,QAAQ,CAAC,OAAO,CAAC;wBACtB;4BACE,MAAM;oBACV,CAAC;gBACH,CAAC;gBACD,iBAAiB,EAAE,KAAK;gBACxB,QAAQ,EAAE,QAAQ,CAAC,OAAO;aAC3B;SACF;KACF,CAAC;IAEF,OAAO,IAAI,6BAA6B,CAAC,UAAU,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -1,4 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
import { ConfidentialClientApplication } from '@azure/msal-node';
|
|
3
|
+
import 'express-session';
|
|
4
|
+
/**
|
|
5
|
+
* Handles the SSO login callback by exchanging the authorization code for tokens using MSAL,
|
|
6
|
+
* storing the access token in the session, and redirecting the user to the frontend.
|
|
7
|
+
*
|
|
8
|
+
* @param req - The Express request object, expected to contain the authorization code in the body.
|
|
9
|
+
* @param res - The Express response object, used to send responses or perform redirects.
|
|
10
|
+
* @param msalInstance - An instance of MSAL ConfidentialClientApplication used to acquire tokens.
|
|
11
|
+
* @param clientId - The client ID of the application, used to build the token request scope.
|
|
12
|
+
* @param frontendHostname - The base URL of the frontend application, used for redirect URIs.
|
|
13
|
+
* @param ssoLoginCallback - The path of the SSO login callback, appended to the frontend hostname for redirect URI.
|
|
14
|
+
* @returns A promise that resolves when the callback handling is complete.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* - If the authorization code is missing, responds with HTTP 400.
|
|
18
|
+
* - On successful token acquisition, stores the access token in the session and redirects to the frontend.
|
|
19
|
+
* - On error, logs the error and responds with HTTP 500.
|
|
20
|
+
*/
|
|
21
|
+
export default function ssoLoginCallbackHandler(req: Request, res: Response, msalInstance: ConfidentialClientApplication, clientId: string, frontendHostname: string, ssoLoginCallback: string): Promise<void>;
|
|
4
22
|
//# sourceMappingURL=sso-login-callback.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sso-login-callback.d.ts","sourceRoot":"","sources":["../../src/sso/sso-login-callback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sso-login-callback.d.ts","sourceRoot":"","sources":["../../src/sso/sso-login-callback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,iBAAiB,CAAC;AAOzB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAA8B,uBAAuB,CACnD,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,YAAY,EAAE,6BAA6B,EAC3C,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC,CA6Df"}
|