eservices-back-core 1.0.91 → 1.0.94

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/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;CA2BlC"}
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,45 +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
- });
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,
41
21
  });
42
- }
22
+ });
43
23
  }
44
- exports.default = Server;
24
+ exports.initServer = initServer;
45
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,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,OAAO,CAAA,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QAErE,GAAG,CAAC,GAA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AC,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eservices-back-core",
3
- "version": "1.0.91",
3
+ "version": "1.0.94",
4
4
  "description": "",
5
5
  "main": "dist/Server.js",
6
6
  "scripts": {
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,37 +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
-
52
-
33
+ });
34
+
53
35
  }
package/tsconfig.json CHANGED
@@ -19,5 +19,5 @@
19
19
  "./src/**/*",
20
20
  "app.ts"
21
21
  ],
22
-
22
+ "exclude": ["app.ts"]
23
23
  }
package/src/app.ts DELETED
@@ -1,27 +0,0 @@
1
- import Server from "./Server";
2
- import path from "path";
3
-
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'),
13
-
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
- }
27
- })
@@ -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
- }