eservices-back-core 1.0.92 → 1.0.95

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/.env ADDED
@@ -0,0 +1,5 @@
1
+ TYPE=front
2
+ PORT=3000
3
+ BASE_URL=http://localhost:3000
4
+ API_URL=http://localhost:15016
5
+ OIDC_ISSUE=https://id.dev.eservices.dev
package/dist/Server.d.ts CHANGED
@@ -12,10 +12,6 @@ interface ServerOptions {
12
12
  staticFolderDir?: string;
13
13
  usingContextFile?: string;
14
14
  }
15
- export default class Server {
16
- app: Express;
17
- options: ServerOptions;
18
- constructor(options: ServerOptions);
19
- }
15
+ export declare function initServer(app: Express, options: ServerOptions): void;
20
16
  export {};
21
17
  //# sourceMappingURL=Server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../src/Server.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AACzC,OAAO,EAAC,YAAY,EAAO,MAAM,wBAAwB,CAAC;AAK1D,UAAU,aAAa;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAG,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC1B;AAID,MAAM,CAAC,OAAO,OAAO,MAAM;IAC1B,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,aAAa,CAAC;gBAEX,OAAO,EAAE,aAAa;CA+BlC"}
1
+ {"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../src/Server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAChC,OAAO,EAAC,YAAY,EAAO,MAAM,wBAAwB,CAAC;AAG1D,UAAU,aAAa;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAG,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,QAiB9D"}
package/dist/Server.js CHANGED
@@ -1,48 +1,25 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
14
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const express_1 = __importDefault(require("express"));
6
+ exports.initServer = void 0;
16
7
  const express_openid_connect_1 = require("express-openid-connect");
17
8
  const cors_1 = __importDefault(require("cors"));
18
- const path_1 = __importDefault(require("path"));
19
- let serverLink = null;
20
- class Server {
21
- constructor(options) {
22
- serverLink = this;
23
- const app = this.app = (0, express_1.default)();
24
- this.options = options;
25
- this.options.typeName = this.options.type === 'front' ? 'SCP' : 'BAP';
26
- app.use((0, cors_1.default)());
27
- app.use((0, express_openid_connect_1.auth)(options.oidc));
28
- app.get("/test-page", (req, res) => {
29
- const user = req.oidc.user;
30
- const userId = Number(user['AppRegister.Claim.PersonId']);
31
- res.send(`hello <b>${req.oidc.user.name}</b>, ${req.oidc.user.sub}, ${userId}`);
32
- });
33
- app.get("/main*", (req, res) => __awaiter(this, void 0, void 0, function* () {
34
- res.sendFile(path_1.default.join(options.frontendDir, `${options.type}-main.html`));
35
- }));
36
- app.use((err, req, res, next) => {
37
- console.log(err);
38
- res.status(500).json({
39
- success: false,
40
- });
41
- });
42
- app.listen(options.port, () => {
43
- console.log(`Server start on ${options.port}`);
9
+ function initServer(app, options) {
10
+ app.use((0, cors_1.default)());
11
+ app.use((0, express_openid_connect_1.auth)(options.oidc));
12
+ app.get("/test-page", (req, res) => {
13
+ const user = req.oidc.user;
14
+ const userId = Number(user['AppRegister.Claim.PersonId']);
15
+ res.send(`hello <b>${req.oidc.user.name}</b>, ${req.oidc.user.sub}, ${userId}`);
16
+ });
17
+ app.use((err, req, res, next) => {
18
+ console.log(err);
19
+ res.status(500).json({
20
+ success: false,
44
21
  });
45
- }
22
+ });
46
23
  }
47
- exports.default = Server;
24
+ exports.initServer = initServer;
48
25
  //# sourceMappingURL=Server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Server.js","sourceRoot":"","sources":["../src/Server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAAyC;AACzC,mEAA0D;AAE1D,gDAAuB;AACvB,gDAAwB;AAexB,IAAI,UAAU,GAAG,IAAI,CAAC;AAEtB,MAAqB,MAAM;IAI1B,YAAY,OAAsB;QACjC,UAAU,GAAG,IAAI,CAAC;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;QACjC,IAAI,CAA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AM,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE;YAC7B,OAAO,CAAC,GAAG,CAAC,mBAAmB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAChD,CAAC,CAAC,CAAA;IACH,CAAC;CAGD;AAnCD,yBAmCC"}
1
+ {"version":3,"file":"Server.js","sourceRoot":"","sources":["../src/Server.ts"],"names":[],"mappings":";;;;;;AACA,mEAA0D;AAC1D,gDAAuB;AAevB,SAAgB,UAAU,CAAC,GAAY,EAAE,OAAsB;IAC9D,GAAG,CAAC,GAAG,CAAC,IAAA,cAAI,GAAE,CAAC,CAAC;IAChB,GAAG,CAAC,GAAG,CAAC,IAAA,6BAAI,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5B,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAClC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;QAC3B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC,CAAC;QAC1D,GAAG,CAAC,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,SAAS,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,MAAM,EAAE,CAAC,CAAC;IACjF,CAAC,CAAC,CAAA;IAGF,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC/B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACpB,OAAO,EAAE,KAAK;SACd,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AAEJ,CAAC;AAjBD,gCAiBC"}
package/dist/app.js CHANGED
@@ -3,29 +3,43 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const Server_1 = __importDefault(require("./Server"));
6
+ const Server_1 = require("./Server");
7
7
  const path_1 = __importDefault(require("path"));
8
- new Server_1.default({
8
+ const express_1 = __importDefault(require("express"));
9
+ const projectDir = path_1.default.join(__dirname, '..');
10
+ const dotenv_1 = require("dotenv");
11
+ (0, dotenv_1.config)({
12
+ path: path_1.default.join(__dirname, '../.env')
13
+ });
14
+ const app = (0, express_1.default)();
15
+ const options = {
9
16
  baseUrl: process.env.BASE_URL,
10
- port: Number(process.env.PORT),
11
17
  type: process.env.TYPE,
12
- apiUrl: 'https://sandbox.eservices.dev:15015',
13
- projectDir: path_1.default.join(__dirname, '..'),
14
- frontendDir: path_1.default.join(__dirname, '../..', 'frontend'),
15
- staticFolderDir: path_1.default.join(__dirname, '..', 'static'),
16
- usingContextFile: path_1.default.join(__dirname, '..', 'using-context.json'),
18
+ port: Number(process.env.PORT),
19
+ frontendDir: path_1.default.join(projectDir, '..', 'frontend'),
20
+ staticFolderDir: path_1.default.join(projectDir, 'static'),
21
+ projectDir: projectDir,
22
+ apiUrl: process.env.API_URL,
23
+ usingContextFile: path_1.default.join(projectDir, 'using-context.json'),
17
24
  oidc: {
18
25
  issuerBaseURL: process.env.OIDC_ISSUE,
19
26
  baseURL: process.env.BASE_URL,
20
- clientID: process.env.OIDC_CLIENT_ID,
21
27
  secret: 'aaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccce',
22
- clientSecret: process.env.OIDC_SECRET,
28
+ clientID: 'AppRegister.WebServer.Public.Client',
23
29
  idpLogout: true,
30
+ routes: {
31
+ postLogoutRedirect: '/auth'
32
+ },
33
+ clientSecret: '64D5FAA8-97FB-403F-898C-5D30718AB830',
24
34
  authorizationParams: {
25
35
  response_type: 'code',
26
- audience: 'https://api.example.com/products',
36
+ audience: process.env.API_URL,
27
37
  scope: 'openid profile email',
28
38
  },
29
- }
39
+ },
40
+ };
41
+ (0, Server_1.initServer)(app, options);
42
+ app.listen(options.port, () => {
43
+ console.log(`Running on ${options.port}`);
30
44
  });
31
45
  //# sourceMappingURL=app.js.map
package/dist/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;AAAA,sDAA8B;AAC9B,gDAAwB;AAExB,IAAI,gBAAM,CAAC;IACV,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ;IAC7B,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;IAC9B,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAwB;IAC1C,MAAM,EAAE,qCAAqC;IAC7C,UAAU,EAAE,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC;IACtC,WAAW,EAAE,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC;IACtD,eAAe,EAAE,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC;IACrD,gBAAgB,EAAE,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,oBAAoB,CAAC;IAElE,IAAI,EAAE;QACL,aAAa,EAAG,OAAO,CAAC,GAAG,CAAC,UAAU;QACtC,OAAO,EAAK,OAAO,CAAC,GAAG,CAAC,QAAQ;QAChC,QAAQ,EAAI,OAAO,CAAC,GAAG,CAAC,cAAc;QACtC,MAAM,EAAK,qEAAqE;QAChF,YAAY,EAAG,OAAO,CAAC,GAAG,CAAC,WAAW;QACtC,SAAS,EAAI,IAAI;QACjB,mBAAmB,EAAE;YACpB,aAAa,EAAE,MAAM;YACrB,QAAQ,EAAE,kCAAkC;YAC5C,KAAK,EAAE,sBAAsB;SAC7B;KACD;CACD,CAAC,CAAA"}
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../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,mBAAU,EAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACzB,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE;IAC1B,OAAO,CAAC,GAAG,CAAC,cAAc,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;AAC7C,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eservices-back-core",
3
- "version": "1.0.92",
3
+ "version": "1.0.95",
4
4
  "description": "",
5
5
  "main": "dist/Server.js",
6
6
  "scripts": {
@@ -15,6 +15,7 @@
15
15
  "dependencies": {
16
16
  "body-parser": "^1.20.0",
17
17
  "cors": "^2.8.5",
18
+ "dotenv": "^16.0.1",
18
19
  "express": "^4.18.1",
19
20
  "express-openid-connect": "^2.7.2",
20
21
  "log4js": "^6.5.2",
package/src/Server.ts CHANGED
@@ -1,8 +1,6 @@
1
- import express, {Express} from "express";
1
+ import {Express} from "express";
2
2
  import {ConfigParams, auth} from "express-openid-connect";
3
-
4
3
  import cors from 'cors'
5
- import path from "path";
6
4
 
7
5
  interface ServerOptions{
8
6
  port: number,
@@ -17,41 +15,21 @@ interface ServerOptions{
17
15
  usingContextFile?: string,
18
16
  }
19
17
 
20
- let serverLink = null;
21
-
22
- export default class Server{
23
- app: Express;
24
- options: ServerOptions;
25
-
26
- constructor(options: ServerOptions) {
27
- serverLink = this;
28
- const app = this.app = express();
29
- this.options = options;
30
- this.options.typeName = this.options.type === 'front'? 'SCP' : 'BAP';
31
-
32
- app.use(cors());
33
- app.use(auth(options.oidc));
34
- app.get("/test-page", (req, res) => {
35
- const user = req.oidc.user;
36
- const userId = Number(user['AppRegister.Claim.PersonId']);
37
- res.send(`hello <b>${req.oidc.user.name}</b>, ${req.oidc.user.sub}, ${userId}`);
38
- })
39
-
40
- app.get("/main*",async (req, res) => {
41
- res.sendFile(path.join( options.frontendDir, `${options.type}-main.html` ));
42
- })
43
- app.use((err, req, res, next) => {
44
- console.log(err);
45
- res.status(500).json({
46
- success: false,
47
- });
18
+ export function initServer(app: Express, options: ServerOptions) {
19
+ app.use(cors());
20
+ app.use(auth(options.oidc));
21
+ app.get("/test-page", (req, res) => {
22
+ const user = req.oidc.user;
23
+ const userId = Number(user['AppRegister.Claim.PersonId']);
24
+ res.send(`hello <b>${req.oidc.user.name}</b>, ${req.oidc.user.sub}, ${userId}`);
25
+ })
26
+
27
+
28
+ app.use((err, req, res, next) => {
29
+ console.log(err);
30
+ res.status(500).json({
31
+ success: false,
48
32
  });
49
-
50
-
51
- app.listen(options.port, () => {
52
- console.log(`Server start on ${options.port}`);
53
- })
54
- }
55
-
56
-
33
+ });
34
+
57
35
  }
package/src/app.ts CHANGED
@@ -1,27 +1,42 @@
1
- import Server from "./Server";
1
+ import {initServer} from "./Server";
2
2
  import path from "path";
3
+ import express from "express";
3
4
 
4
- new Server({
5
- baseUrl: process.env.BASE_URL,
6
- port: Number(process.env.PORT),
7
- type: process.env.TYPE as 'front' | 'back',// process.env.TYPE,
8
- apiUrl: 'https://sandbox.eservices.dev:15015',
9
- projectDir: path.join(__dirname, '..'),
10
- frontendDir: path.join(__dirname, '../..', 'frontend'),
11
- staticFolderDir: path.join(__dirname, '..', 'static'),
12
- usingContextFile: path.join(__dirname, '..', 'using-context.json'),
5
+ const projectDir = path.join(__dirname, '..');
6
+ import {config as configDotenv} from "dotenv";
13
7
 
14
- oidc: {
15
- issuerBaseURL : process.env.OIDC_ISSUE,
16
- baseURL : process.env.BASE_URL,
17
- clientID : process.env.OIDC_CLIENT_ID,
18
- secret : 'aaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccce',
19
- clientSecret : process.env.OIDC_SECRET,
20
- idpLogout : true,
21
- authorizationParams: {
22
- response_type: 'code', // This requires you to provide a client secret
23
- audience: 'https://api.example.com/products',
24
- scope: 'openid profile email',
25
- },
26
- }
8
+ configDotenv({
9
+ path: path.join(__dirname, '../.env')
10
+ })
11
+ const app = express();
12
+
13
+ const options = {
14
+ baseUrl: process.env.BASE_URL,
15
+ type: process.env.TYPE as ('front' | 'back'),
16
+ port: Number(process.env.PORT),
17
+ frontendDir: path.join(projectDir, '..', 'frontend'),
18
+ staticFolderDir: path.join(projectDir, 'static'),
19
+ projectDir: projectDir,
20
+ apiUrl: process.env.API_URL,
21
+ usingContextFile: path.join(projectDir, 'using-context.json'),
22
+ oidc: {
23
+ issuerBaseURL : process.env.OIDC_ISSUE,
24
+ baseURL : process.env.BASE_URL,
25
+ secret : 'aaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccce',
26
+ clientID : 'AppRegister.WebServer.Public.Client',
27
+ idpLogout : true,
28
+ routes: {
29
+ postLogoutRedirect: '/auth'
30
+ },
31
+ clientSecret : '64D5FAA8-97FB-403F-898C-5D30718AB830',
32
+ authorizationParams: {
33
+ response_type: 'code', // This requires you to provide a client secret
34
+ audience: process.env.API_URL,
35
+ scope: 'openid profile email',
36
+ },
37
+ },
38
+ }
39
+ initServer(app, options);
40
+ app.listen(options.port, () => {
41
+ console.log(`Running on ${options.port}`)
27
42
  })
package/tsconfig.json CHANGED
@@ -19,5 +19,4 @@
19
19
  "./src/**/*",
20
20
  "app.ts"
21
21
  ],
22
-
23
22
  }
@@ -1,13 +0,0 @@
1
- module.exports = function corsMiddleware(req, res, next) {
2
- const origin = req.headers.origin;
3
-
4
- res.header("Access-Control-Allow-Origin", origin);
5
-
6
- res.header("Access-Control-Allow-Headers", "Auth_old-Token,Authorization, Origin, X-Requested-With, content-type, Content-Type, Content-Type, content-type, Content_Type, Accept");
7
- res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
8
-
9
- if (req.method === "OPTIONS") {
10
- return res.status(200).end();
11
- }
12
- next();
13
- }
@@ -1,17 +0,0 @@
1
-
2
- module.exports = async (req, res, next) => {
3
-
4
- try {
5
- let accessToken = req.oidc.accessToken;
6
-
7
- if (accessToken.isExpired()) {
8
- accessToken = await accessToken.refresh();
9
- }
10
- req.__token = `${accessToken.token_type} ${accessToken.access_token}`;
11
- req.userInfo = await req.oidc.fetchUserInfo();
12
-
13
- next();
14
- } catch (e) {
15
- next(e);
16
- }
17
- }