@ndbs-dk/afu-shared-services 2.5.33
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/README.md +84 -0
- package/dist/helpers/altinn-helper.d.ts +54 -0
- package/dist/helpers/altinn-helper.d.ts.map +1 -0
- package/dist/helpers/altinn-helper.js +137 -0
- package/dist/helpers/altinn-helper.js.map +1 -0
- package/dist/helpers/mail-helper.d.ts +23 -0
- package/dist/helpers/mail-helper.d.ts.map +1 -0
- package/dist/helpers/mail-helper.js +46 -0
- package/dist/helpers/mail-helper.js.map +1 -0
- package/dist/helpers/sf-helper.d.ts +25 -0
- package/dist/helpers/sf-helper.d.ts.map +1 -0
- package/dist/helpers/sf-helper.js +83 -0
- package/dist/helpers/sf-helper.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/services/altinn-service.d.ts +32 -0
- package/dist/services/altinn-service.d.ts.map +1 -0
- package/dist/services/altinn-service.js +158 -0
- package/dist/services/altinn-service.js.map +1 -0
- package/dist/services/mail-service.d.ts +31 -0
- package/dist/services/mail-service.d.ts.map +1 -0
- package/dist/services/mail-service.js +89 -0
- package/dist/services/mail-service.js.map +1 -0
- package/dist/services/sf-service.d.ts +166 -0
- package/dist/services/sf-service.d.ts.map +1 -0
- package/dist/services/sf-service.js +695 -0
- package/dist/services/sf-service.js.map +1 -0
- package/dist/template/template.d.ts +16 -0
- package/dist/template/template.d.ts.map +1 -0
- package/dist/template/template.js +84 -0
- package/dist/template/template.js.map +1 -0
- package/dist/test/altinn-service.test.d.ts +2 -0
- package/dist/test/altinn-service.test.d.ts.map +1 -0
- package/dist/test/altinn-service.test.js +61 -0
- package/dist/test/altinn-service.test.js.map +1 -0
- package/dist/test/mail-service.test.d.ts +2 -0
- package/dist/test/mail-service.test.d.ts.map +1 -0
- package/dist/test/mail-service.test.js +56 -0
- package/dist/test/mail-service.test.js.map +1 -0
- package/dist/test/scripts/test-altinn-fetch.d.ts +2 -0
- package/dist/test/scripts/test-altinn-fetch.d.ts.map +1 -0
- package/dist/test/scripts/test-altinn-fetch.js +48 -0
- package/dist/test/scripts/test-altinn-fetch.js.map +1 -0
- package/dist/test/sf-service.test.d.ts +2 -0
- package/dist/test/sf-service.test.d.ts.map +1 -0
- package/dist/test/sf-service.test.js +188 -0
- package/dist/test/sf-service.test.js.map +1 -0
- package/dist/types/altinn.types.d.ts +208 -0
- package/dist/types/altinn.types.d.ts.map +1 -0
- package/dist/types/altinn.types.js +3 -0
- package/dist/types/altinn.types.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mail.types.d.ts +72 -0
- package/dist/types/mail.types.d.ts.map +1 -0
- package/dist/types/mail.types.js +3 -0
- package/dist/types/mail.types.js.map +1 -0
- package/dist/types/sf.types.d.ts +248 -0
- package/dist/types/sf.types.d.ts.map +1 -0
- package/dist/types/sf.types.js +3 -0
- package/dist/types/sf.types.js.map +1 -0
- package/dist/utils/altinn-util.d.ts +88 -0
- package/dist/utils/altinn-util.d.ts.map +1 -0
- package/dist/utils/altinn-util.js +471 -0
- package/dist/utils/altinn-util.js.map +1 -0
- package/dist/utils/cache-util.d.ts +22 -0
- package/dist/utils/cache-util.d.ts.map +1 -0
- package/dist/utils/cache-util.js +82 -0
- package/dist/utils/cache-util.js.map +1 -0
- package/dist/utils/mail-util.d.ts +21 -0
- package/dist/utils/mail-util.d.ts.map +1 -0
- package/dist/utils/mail-util.js +61 -0
- package/dist/utils/mail-util.js.map +1 -0
- package/dist/utils/sf-util.d.ts +28 -0
- package/dist/utils/sf-util.d.ts.map +1 -0
- package/dist/utils/sf-util.js +71 -0
- package/dist/utils/sf-util.js.map +1 -0
- package/dist/utils/xml-util.d.ts +10 -0
- package/dist/utils/xml-util.d.ts.map +1 -0
- package/dist/utils/xml-util.js +24 -0
- package/dist/utils/xml-util.js.map +1 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# afu-shared-services
|
|
2
|
+
|
|
3
|
+
## About the Project
|
|
4
|
+
|
|
5
|
+
**afu-shared-services** is a library that provides reusable common services and utility functions for different projects. It is designed to reduce code duplication and accelerate development processes.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Common services (authentication, logging, error handling, etc.)
|
|
10
|
+
- Utility functions (helpers)
|
|
11
|
+
- Easy integration and extensible structure
|
|
12
|
+
- Testability and high code quality
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
To clone the project:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
git clone https://github.com/ndbs-dk/afu-shared-services.git
|
|
20
|
+
cd afu-shared-services
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
To install dependencies:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install
|
|
27
|
+
# or
|
|
28
|
+
yarn install
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
To use the library in your project:
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
import { AuthService, Logger } from 'afu-shared-services';
|
|
37
|
+
|
|
38
|
+
// Authentication example
|
|
39
|
+
const auth = new AuthService();
|
|
40
|
+
auth.login('username', 'password');
|
|
41
|
+
|
|
42
|
+
// Logging example
|
|
43
|
+
Logger.info('Application started.');
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Project Structure
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
afu-shared-services/
|
|
50
|
+
│
|
|
51
|
+
├── src/
|
|
52
|
+
│ ├── services/
|
|
53
|
+
│ ├── utils/
|
|
54
|
+
│ └── index.js
|
|
55
|
+
├── tests/
|
|
56
|
+
├── package.json
|
|
57
|
+
└── README.md
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- **src/services/**: Common services
|
|
61
|
+
- **src/utils/**: Utility functions
|
|
62
|
+
- **tests/**: Unit tests
|
|
63
|
+
|
|
64
|
+
## Contributing
|
|
65
|
+
|
|
66
|
+
To contribute:
|
|
67
|
+
|
|
68
|
+
1. Fork the repository
|
|
69
|
+
2. Create a new branch (`git checkout -b feature/new-feature`)
|
|
70
|
+
3. Make your changes and commit them
|
|
71
|
+
4. Push your branch (`git push origin feature/new-feature`)
|
|
72
|
+
5. Open a pull request
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
## 👥 Maintainers
|
|
76
|
+
|
|
77
|
+
* **gizemsoylutr**
|
|
78
|
+
* Contact: [gizemsoylu.tr@gmail.com](mailto:gizemsoylu.tr@gmail.com)
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 📄 License
|
|
83
|
+
|
|
84
|
+
MIT License © 2025 NDBS-DK
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import https from "https";
|
|
2
|
+
import { type Destination } from "@sap-cloud-sdk/connectivity";
|
|
3
|
+
import type { AltinnDestinationConfig, SickLeaveInfoSummary } from "../types/altinn.types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Creates an HTTPS agent for Altinn requests with the given certificates and passphrase.
|
|
6
|
+
* @param cert Certificate buffer
|
|
7
|
+
* @param key Key buffer
|
|
8
|
+
* @param ca CA buffer
|
|
9
|
+
* @param passphrase Optional passphrase for the key/cert
|
|
10
|
+
*/
|
|
11
|
+
export declare function createAltinnHttpsAgent(cert: Buffer, key: Buffer, ca: Buffer, passphrase?: string): https.Agent;
|
|
12
|
+
/**
|
|
13
|
+
* Validates required Altinn config and returns the config object.
|
|
14
|
+
* @param destination The Altinn destination object
|
|
15
|
+
* @returns The validated Altinn destination config object
|
|
16
|
+
* @throws Error if any required config is missing
|
|
17
|
+
* @example
|
|
18
|
+
* const config = getValidAltinnConfig(destination);
|
|
19
|
+
* // config has properties: authEndpoint, apiKey, username, password, organizationNumbers (optional)
|
|
20
|
+
*/
|
|
21
|
+
export declare function getValidAltinnConfig(destination: Destination): AltinnDestinationConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Creates the request data for Altinn authentication.
|
|
24
|
+
* @param username Altinn username
|
|
25
|
+
* @param password Altinn password
|
|
26
|
+
* @returns The request data object
|
|
27
|
+
* @example
|
|
28
|
+
* const requestData = createAuthRequestData("myUsername", "myPassword");
|
|
29
|
+
* // requestData = { UserName: "myUsername", UserPassword: "myPassword" }
|
|
30
|
+
*/
|
|
31
|
+
export declare function createAuthRequestData(username: string, password: string): {
|
|
32
|
+
UserName: string;
|
|
33
|
+
UserPassword: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Fetches cases from Altinn API.
|
|
37
|
+
* @param destination Destination config
|
|
38
|
+
* @param cert Certificate buffer
|
|
39
|
+
* @param key Key buffer
|
|
40
|
+
* @param ca CA buffer
|
|
41
|
+
* @param accessToken Valid Altinn access token (cookie)
|
|
42
|
+
* @param endpoint (optional) Altinn cases endpoint (default: '/api/cases')
|
|
43
|
+
*/
|
|
44
|
+
export declare function fetchAltinnCases({ destination, cert, key, ca, accessToken, who, dateFrom, dateTo }: {
|
|
45
|
+
destination: Destination;
|
|
46
|
+
cert: Buffer;
|
|
47
|
+
key: Buffer;
|
|
48
|
+
ca: Buffer;
|
|
49
|
+
accessToken: string;
|
|
50
|
+
who: string;
|
|
51
|
+
dateFrom?: string;
|
|
52
|
+
dateTo?: string;
|
|
53
|
+
}): Promise<SickLeaveInfoSummary[]>;
|
|
54
|
+
//# sourceMappingURL=altinn-helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"altinn-helper.d.ts","sourceRoot":"","sources":["../../src/helpers/altinn-helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAG9F;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,eAShG;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,uBAAuB,CAUtF;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;EAKvE;AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CAAC,EACnC,WAAW,EACX,IAAI,EACJ,GAAG,EACH,EAAE,EACF,WAAW,EACX,GAAG,EACH,QAAuB,EACvB,MAAqB,EACxB,EAAE;IACC,WAAW,EAAE,WAAW,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAwDlC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createAltinnHttpsAgent = createAltinnHttpsAgent;
|
|
7
|
+
exports.getValidAltinnConfig = getValidAltinnConfig;
|
|
8
|
+
exports.createAuthRequestData = createAuthRequestData;
|
|
9
|
+
exports.fetchAltinnCases = fetchAltinnCases;
|
|
10
|
+
const axios_1 = __importDefault(require("axios"));
|
|
11
|
+
const https_1 = __importDefault(require("https"));
|
|
12
|
+
const xml_util_1 = require("../utils/xml-util");
|
|
13
|
+
const altinn_util_1 = require("../utils/altinn-util");
|
|
14
|
+
/**
|
|
15
|
+
* Creates an HTTPS agent for Altinn requests with the given certificates and passphrase.
|
|
16
|
+
* @param cert Certificate buffer
|
|
17
|
+
* @param key Key buffer
|
|
18
|
+
* @param ca CA buffer
|
|
19
|
+
* @param passphrase Optional passphrase for the key/cert
|
|
20
|
+
*/
|
|
21
|
+
function createAltinnHttpsAgent(cert, key, ca, passphrase) {
|
|
22
|
+
return new https_1.default.Agent({
|
|
23
|
+
cert,
|
|
24
|
+
key,
|
|
25
|
+
ca,
|
|
26
|
+
passphrase,
|
|
27
|
+
rejectUnauthorized: false,
|
|
28
|
+
secureOptions: require('crypto').constants.SSL_OP_LEGACY_SERVER_CONNECT
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Validates required Altinn config and returns the config object.
|
|
33
|
+
* @param destination The Altinn destination object
|
|
34
|
+
* @returns The validated Altinn destination config object
|
|
35
|
+
* @throws Error if any required config is missing
|
|
36
|
+
* @example
|
|
37
|
+
* const config = getValidAltinnConfig(destination);
|
|
38
|
+
* // config has properties: authEndpoint, apiKey, username, password, organizationNumbers (optional)
|
|
39
|
+
*/
|
|
40
|
+
function getValidAltinnConfig(destination) {
|
|
41
|
+
if (!destination)
|
|
42
|
+
throw new Error(`Destination not found`);
|
|
43
|
+
const config = destination.originalProperties?.destinationConfiguration;
|
|
44
|
+
const required = ["authEndpoint", "apiKey", "username", "password"];
|
|
45
|
+
for (const key of required) {
|
|
46
|
+
if (!config[key]) {
|
|
47
|
+
throw new Error(`Missing config: ${key}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return config;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Creates the request data for Altinn authentication.
|
|
54
|
+
* @param username Altinn username
|
|
55
|
+
* @param password Altinn password
|
|
56
|
+
* @returns The request data object
|
|
57
|
+
* @example
|
|
58
|
+
* const requestData = createAuthRequestData("myUsername", "myPassword");
|
|
59
|
+
* // requestData = { UserName: "myUsername", UserPassword: "myPassword" }
|
|
60
|
+
*/
|
|
61
|
+
function createAuthRequestData(username, password) {
|
|
62
|
+
return {
|
|
63
|
+
UserName: username,
|
|
64
|
+
UserPassword: password
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Fetches cases from Altinn API.
|
|
69
|
+
* @param destination Destination config
|
|
70
|
+
* @param cert Certificate buffer
|
|
71
|
+
* @param key Key buffer
|
|
72
|
+
* @param ca CA buffer
|
|
73
|
+
* @param accessToken Valid Altinn access token (cookie)
|
|
74
|
+
* @param endpoint (optional) Altinn cases endpoint (default: '/api/cases')
|
|
75
|
+
*/
|
|
76
|
+
async function fetchAltinnCases({ destination, cert, key, ca, accessToken, who, dateFrom = '1970-01-01', dateTo = '2300-01-01' }) {
|
|
77
|
+
const config = getValidAltinnConfig(destination);
|
|
78
|
+
const baseUrl = destination?.url || '';
|
|
79
|
+
const url = `${baseUrl}/${who}/Messages?ForceEIAuthentication`;
|
|
80
|
+
const httpsAgent = createAltinnHttpsAgent(cert, key, ca, destination.keyStorePassword);
|
|
81
|
+
const response = await axios_1.default.get(url, {
|
|
82
|
+
headers: {
|
|
83
|
+
'Cookie': accessToken,
|
|
84
|
+
'ApiKey': config.apiKey,
|
|
85
|
+
'Content-Type': 'Application/hal+json',
|
|
86
|
+
},
|
|
87
|
+
params: {
|
|
88
|
+
dateFrom,
|
|
89
|
+
dateTo
|
|
90
|
+
},
|
|
91
|
+
httpsAgent
|
|
92
|
+
});
|
|
93
|
+
const messages = response.data;
|
|
94
|
+
if (!Array.isArray(messages))
|
|
95
|
+
return [];
|
|
96
|
+
const sickLeaveInfos = (await Promise.all(messages.map(async (msg) => {
|
|
97
|
+
if (!msg.MessageId)
|
|
98
|
+
return null;
|
|
99
|
+
try {
|
|
100
|
+
const attachmentsUrl = `${baseUrl}/${who}/Messages/${msg.MessageId}/attachments`;
|
|
101
|
+
const attRes = await axios_1.default.get(attachmentsUrl, {
|
|
102
|
+
headers: {
|
|
103
|
+
'Cookie': accessToken,
|
|
104
|
+
'ApiKey': config.apiKey,
|
|
105
|
+
'Content-Type': 'Application/hal+json',
|
|
106
|
+
'Accept': 'application/hal+json'
|
|
107
|
+
},
|
|
108
|
+
httpsAgent
|
|
109
|
+
});
|
|
110
|
+
const attachments = attRes.data;
|
|
111
|
+
const xmlAttachmentUrl = (0, altinn_util_1.findXmlAttachmentUrl)(attachments);
|
|
112
|
+
if (xmlAttachmentUrl) {
|
|
113
|
+
try {
|
|
114
|
+
const xmlString = await (0, altinn_util_1.fetchXmlString)(xmlAttachmentUrl, accessToken, config.apiKey, httpsAgent);
|
|
115
|
+
if (xmlString) {
|
|
116
|
+
try {
|
|
117
|
+
const parsed = await (0, xml_util_1.parseXmlToJson)(xmlString);
|
|
118
|
+
return (0, altinn_util_1.mapSickLeaveInfoFromXmlJson)(parsed);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}))).filter((info) => info !== null);
|
|
135
|
+
return sickLeaveInfos;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=altinn-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"altinn-helper.js","sourceRoot":"","sources":["../../src/helpers/altinn-helper.ts"],"names":[],"mappings":";;;;;AAcA,wDASC;AAWD,oDAUC;AAWD,sDAKC;AAWD,4CA0EC;AAjJD,kDAA0B;AAC1B,kDAA0B;AAC1B,gDAAm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AAI,gBAAgB,EAAE,CAAC;gBACnB,IAAI,CAAC;oBACD,MAAM,SAAS,GAAG,MAAM,IAAA,4BAAc,EAAC,gBAAgB,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;oBACjG,IAAI,SAAS,EAAE,CAAC;wBACZ,IAAI,CAAC;4BACD,MAAM,MAAM,GAAG,MAAM,IAAA,yBAAc,EAAC,SAAS,CAAC,CAAC;4BAC/C,OAAO,IAAA,yCAA2B,EAAC,MAAM,CAAC,CAAC;wBAC/C,CAAC;wBAAC,MAAM,CAAC;4BACL,OAAO,IAAI,CAAC;wBAChB,CAAC;oBACL,CAAC;gBACL,CAAC;gBAAC,MAAM,CAAC;oBACL,OAAO,IAAI,CAAC;gBAChB,CAAC;YACL,CAAC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAgC,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACnE,OAAO,cAAc,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Destination } from "@sap-cloud-sdk/connectivity";
|
|
2
|
+
import type { EmailDestinationConfig } from "../types/mail.types";
|
|
3
|
+
/**
|
|
4
|
+
* Extracts and validates the email destination config from a Destination object.
|
|
5
|
+
* @param destination The email destination object
|
|
6
|
+
* @returns The validated email destination config object
|
|
7
|
+
* @throws Error if any required config is missing
|
|
8
|
+
* @example
|
|
9
|
+
* const config = getValidEmailConfig(destination);
|
|
10
|
+
* // config has properties: smtpHost, smtpPort, smtpUser, tokenUrl, scope, clientId, clientSecret
|
|
11
|
+
*/
|
|
12
|
+
export declare function getValidEmailConfig(destination: Destination): EmailDestinationConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Extracts the Bearer token from the destination's authTokens array.
|
|
15
|
+
* @param destination The destination object
|
|
16
|
+
* @returns The Bearer token string
|
|
17
|
+
* @throws Error if no valid auth token is found
|
|
18
|
+
* @example
|
|
19
|
+
* const token = getAuthToken(destination);
|
|
20
|
+
* // token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
|
|
21
|
+
*/
|
|
22
|
+
export declare function getAuthToken(destination: Destination): string;
|
|
23
|
+
//# sourceMappingURL=mail-helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail-helper.d.ts","sourceRoot":"","sources":["../../src/helpers/mail-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,sBAAsB,CAepF;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAM7D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getValidEmailConfig = getValidEmailConfig;
|
|
4
|
+
exports.getAuthToken = getAuthToken;
|
|
5
|
+
/**
|
|
6
|
+
* Extracts and validates the email destination config from a Destination object.
|
|
7
|
+
* @param destination The email destination object
|
|
8
|
+
* @returns The validated email destination config object
|
|
9
|
+
* @throws Error if any required config is missing
|
|
10
|
+
* @example
|
|
11
|
+
* const config = getValidEmailConfig(destination);
|
|
12
|
+
* // config has properties: smtpHost, smtpPort, smtpUser, tokenUrl, scope, clientId, clientSecret
|
|
13
|
+
*/
|
|
14
|
+
function getValidEmailConfig(destination) {
|
|
15
|
+
const destConfig = destination.originalProperties?.destinationConfiguration;
|
|
16
|
+
const config = {
|
|
17
|
+
smtpHost: destConfig["mail.smtp.host"],
|
|
18
|
+
smtpPort: Number(destConfig["mail.smtp.port"] || 587),
|
|
19
|
+
smtpUser: destConfig["mail.from"],
|
|
20
|
+
tokenUrl: destConfig["tokenServiceURL"] || destConfig["tokenServiceUrl"],
|
|
21
|
+
scope: destConfig["scope"],
|
|
22
|
+
clientId: destConfig["clientId"],
|
|
23
|
+
clientSecret: destConfig["mail.secret"]
|
|
24
|
+
};
|
|
25
|
+
if (!config.smtpHost || !config.smtpUser || !config.tokenUrl || !config.clientId || !config.clientSecret) {
|
|
26
|
+
throw new Error(`Destination '${destination.name}' is missing required mail configuration.`);
|
|
27
|
+
}
|
|
28
|
+
return config;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Extracts the Bearer token from the destination's authTokens array.
|
|
32
|
+
* @param destination The destination object
|
|
33
|
+
* @returns The Bearer token string
|
|
34
|
+
* @throws Error if no valid auth token is found
|
|
35
|
+
* @example
|
|
36
|
+
* const token = getAuthToken(destination);
|
|
37
|
+
* // token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
|
|
38
|
+
*/
|
|
39
|
+
function getAuthToken(destination) {
|
|
40
|
+
const tokens = destination.authTokens;
|
|
41
|
+
if (Array.isArray(tokens) && tokens?.length > 0 && tokens[0]?.value) {
|
|
42
|
+
return tokens[0].value;
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`Destination '${destination.name}' is missing required auth token.`);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=mail-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail-helper.js","sourceRoot":"","sources":["../../src/helpers/mail-helper.ts"],"names":[],"mappings":";;AAYA,kDAeC;AAWD,oCAMC;AAzCD;;;;;;;;GAQG;AACH,SAAgB,mBAAmB,CAAC,WAAwB;IAC3D,MAAM,UAAU,GAAG,WAAW,CAAC,kBAAkB,EAAE,wBAAwB,CAAC;IAC5E,MAAM,MAAM,GAA2B;QACtC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,IAAI,GAAG,CAAC;QACrD,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC;QACjC,QAAQ,EAAE,UAAU,CAAC,iBAAiB,CAAC,IAAI,UAAU,CAAC,iBAAiB,CAAC;QACxE,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC;QAC1B,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC;QAChC,YAAY,EAAE,UAAU,CAAC,aAAa,CAAC;KACvC,CAAC;IACF,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QAC1G,MAAM,IAAI,KAAK,CAAC,gBAAgB,WAAW,CAAC,IAAI,2CAA2C,CAAC,CAAC;IAC9F,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,YAAY,CAAC,WAAwB;IACpD,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC;IACtC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,EAAE,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;QACrE,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,KAAe,CAAC;IAClC,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,gBAAgB,WAAW,CAAC,IAAI,mCAAmC,CAAC,CAAC;AACtF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Destination } from "@sap-cloud-sdk/connectivity";
|
|
2
|
+
import type { SFDestinationConfig } from "../types/sf.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves SAML assertion from the SF destination using provided destination and config.
|
|
5
|
+
* @param destination The SF destination object
|
|
6
|
+
* @param config The SF destination config object
|
|
7
|
+
* @returns The SAML assertion string
|
|
8
|
+
* @throws Error if any required config is missing or request fails
|
|
9
|
+
*/
|
|
10
|
+
export declare function getSamlAssertionFromDestination(destination: Destination, config: SFDestinationConfig): Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Validates required SF config and returns the config object.
|
|
13
|
+
* @param destination The SF destination object
|
|
14
|
+
* @returns The validated SF destination config object
|
|
15
|
+
* @throws Error if any required config is missing
|
|
16
|
+
*/
|
|
17
|
+
export declare function getValidSfConfig(destination: Destination): SFDestinationConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Converts a string date value to a Date object or null.
|
|
20
|
+
* @param val String date value
|
|
21
|
+
* @returns Date object or null
|
|
22
|
+
* @example convertToDate("2023-10-05") => Date object; convertToDate(undefined) => null
|
|
23
|
+
*/
|
|
24
|
+
export declare const convertToDate: (val: string | undefined | null) => Date | null;
|
|
25
|
+
//# sourceMappingURL=sf-helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sf-helper.d.ts","sourceRoot":"","sources":["../../src/helpers/sf-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAsB,+BAA+B,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,mBAAmB,mBAkC1G;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,mBAAmB,CAU9E;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,GAAG,SAAS,GAAG,IAAI,KAAG,IAAI,GAAG,IAQrE,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.convertToDate = void 0;
|
|
7
|
+
exports.getSamlAssertionFromDestination = getSamlAssertionFromDestination;
|
|
8
|
+
exports.getValidSfConfig = getValidSfConfig;
|
|
9
|
+
const axios_1 = __importDefault(require("axios"));
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves SAML assertion from the SF destination using provided destination and config.
|
|
12
|
+
* @param destination The SF destination object
|
|
13
|
+
* @param config The SF destination config object
|
|
14
|
+
* @returns The SAML assertion string
|
|
15
|
+
* @throws Error if any required config is missing or request fails
|
|
16
|
+
*/
|
|
17
|
+
async function getSamlAssertionFromDestination(destination, config) {
|
|
18
|
+
try {
|
|
19
|
+
const client_id = config.clientId;
|
|
20
|
+
const user_id = config.sfUserId || config.userId;
|
|
21
|
+
const token_url = destination.tokenServiceUrl;
|
|
22
|
+
const private_key = config.cert || destination.clientSecret || config.apiKey;
|
|
23
|
+
const apiUrl = config.apiURL;
|
|
24
|
+
if (!client_id || !user_id || !token_url || !private_key || !apiUrl) {
|
|
25
|
+
throw new Error("Missing destination configs: client_id, user_id, token_url, private_key, apiUrl are required.");
|
|
26
|
+
}
|
|
27
|
+
const assertionUrl = apiUrl + "/oauth/idp";
|
|
28
|
+
const params = new URLSearchParams();
|
|
29
|
+
params.append("client_id", client_id);
|
|
30
|
+
params.append("user_id", user_id);
|
|
31
|
+
params.append("token_url", token_url);
|
|
32
|
+
params.append("private_key", private_key);
|
|
33
|
+
const assertionResponse = await axios_1.default.post(assertionUrl, params.toString(), {
|
|
34
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
35
|
+
});
|
|
36
|
+
if (!assertionResponse.data) {
|
|
37
|
+
throw new Error(`Assertion request failed: ${JSON.stringify(assertionResponse)}`);
|
|
38
|
+
}
|
|
39
|
+
return typeof assertionResponse.data === "string" ? assertionResponse.data : JSON.stringify(assertionResponse.data);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
if (err instanceof Error) {
|
|
43
|
+
throw new Error(`Assertion request failed: ${err.message}`);
|
|
44
|
+
}
|
|
45
|
+
throw new Error("Assertion request failed: Unknown error");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Validates required SF config and returns the config object.
|
|
50
|
+
* @param destination The SF destination object
|
|
51
|
+
* @returns The validated SF destination config object
|
|
52
|
+
* @throws Error if any required config is missing
|
|
53
|
+
*/
|
|
54
|
+
function getValidSfConfig(destination) {
|
|
55
|
+
if (!destination)
|
|
56
|
+
throw new Error(`Destination not found`);
|
|
57
|
+
const config = destination.originalProperties?.destinationConfiguration;
|
|
58
|
+
const required = ["companyId", "clientId", "tokenServiceURL"];
|
|
59
|
+
for (const key of required) {
|
|
60
|
+
if (!config[key]) {
|
|
61
|
+
throw new Error(`Missing config: ${key}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return config;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Converts a string date value to a Date object or null.
|
|
68
|
+
* @param val String date value
|
|
69
|
+
* @returns Date object or null
|
|
70
|
+
* @example convertToDate("2023-10-05") => Date object; convertToDate(undefined) => null
|
|
71
|
+
*/
|
|
72
|
+
const convertToDate = (val) => {
|
|
73
|
+
if (!val)
|
|
74
|
+
return null;
|
|
75
|
+
const match = /\/Date\((\d+)\)\//.exec(val);
|
|
76
|
+
if (match) {
|
|
77
|
+
return new Date(Number(match[1]));
|
|
78
|
+
}
|
|
79
|
+
const date = new Date(val);
|
|
80
|
+
return isNaN(date.getTime()) ? null : date;
|
|
81
|
+
};
|
|
82
|
+
exports.convertToDate = convertToDate;
|
|
83
|
+
//# sourceMappingURL=sf-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sf-helper.js","sourceRoot":"","sources":["../../src/helpers/sf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AM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC,CAAC;AARW,QAAA,aAAa,iBAQxB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './services/sf-service.js';
|
|
2
|
+
export * from './services/mail-service.js';
|
|
3
|
+
export * from './services/altinn-service.js';
|
|
4
|
+
export * from './helpers/altinn-helper.js';
|
|
5
|
+
export * from './helpers/mail-helper.js';
|
|
6
|
+
export * from './helpers/sf-helper.js';
|
|
7
|
+
export * from './utils/altinn-util.js';
|
|
8
|
+
export * from './utils/cache-util.js';
|
|
9
|
+
export * from './utils/mail-util.js';
|
|
10
|
+
export * from './utils/sf-util.js';
|
|
11
|
+
export * from './types/mail.types.js';
|
|
12
|
+
export * from './types/altinn.types.js';
|
|
13
|
+
export * from './types/sf.types.js';
|
|
14
|
+
export * from './template/template.js';
|
|
15
|
+
export * from './types/index.js';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./services/sf-service.js"), exports);
|
|
18
|
+
__exportStar(require("./services/mail-service.js"), exports);
|
|
19
|
+
__exportStar(require("./services/altinn-service.js"), exports);
|
|
20
|
+
__exportStar(require("./helpers/altinn-helper.js"), exports);
|
|
21
|
+
__exportStar(require("./helpers/mail-helper.js"), exports);
|
|
22
|
+
__exportStar(require("./helpers/sf-helper.js"), exports);
|
|
23
|
+
__exportStar(require("./utils/altinn-util.js"), exports);
|
|
24
|
+
__exportStar(require("./utils/cache-util.js"), exports);
|
|
25
|
+
__exportStar(require("./utils/mail-util.js"), exports);
|
|
26
|
+
__exportStar(require("./utils/sf-util.js"), exports);
|
|
27
|
+
__exportStar(require("./types/mail.types.js"), exports);
|
|
28
|
+
__exportStar(require("./types/altinn.types.js"), exports);
|
|
29
|
+
__exportStar(require("./types/sf.types.js"), exports);
|
|
30
|
+
__exportStar(require("./template/template.js"), exports);
|
|
31
|
+
__exportStar(require("./types/index.js"), exports);
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,6DAA2C;AAC3C,+DAA6C;AAC7C,6DAA2C;AAC3C,2DAAyC;AACzC,yDAAuC;AACvC,yDAAuC;AACvC,wDAAsC;AACtC,uDAAqC;AACrC,qDAAmC;AACnC,wDAAsC;AACtC,0DAAwC;AACxC,sDAAoC;AACpC,yDAAsC;AACtC,mDAAiC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AxiosResponse } from "axios";
|
|
2
|
+
import { type Destination } from "@sap-cloud-sdk/connectivity";
|
|
3
|
+
import { SickLeaveInfoSummary } from "../types/altinn.types";
|
|
4
|
+
export declare class AltinnService {
|
|
5
|
+
private destination;
|
|
6
|
+
accessToken: string;
|
|
7
|
+
private cert;
|
|
8
|
+
private key;
|
|
9
|
+
private ca;
|
|
10
|
+
private who;
|
|
11
|
+
constructor(destination: Destination, cert: Buffer, key: Buffer, ca: Buffer);
|
|
12
|
+
/** * Authenticates the user and retrieves an access token from Altinn.
|
|
13
|
+
* @returns The access token string
|
|
14
|
+
* @throws Error if authentication fails
|
|
15
|
+
* @example authenticate() => "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
|
|
16
|
+
*/
|
|
17
|
+
authenticate(): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Synchronizes sick leave information from Altinn.
|
|
20
|
+
* @param dateFrom The start date for the synchronization
|
|
21
|
+
* @param dateTo The end date for the synchronization
|
|
22
|
+
* @returns A promise that resolves to an array of sick leave information summaries
|
|
23
|
+
*/
|
|
24
|
+
syncSickLeaves(dateFrom: string, dateTo: string): Promise<SickLeaveInfoSummary[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Posts immediate leader information to Altinn.
|
|
27
|
+
* @param formData The form data to be sent
|
|
28
|
+
* @returns A promise that resolves to the response from Altinn
|
|
29
|
+
*/
|
|
30
|
+
postAltinn(formData: string, who: string): Promise<AxiosResponse>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=altinn-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"altinn-service.d.ts","sourceRoot":"","sources":["../../src/services/altinn-service.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,qBAAa,aAAa;IACxB,OAAO,CAAC,WAAW,CAAc;IAC1B,WAAW,EAAE,MAAM,CAAM;IAChC,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,GAAG,CAAqB;gBAEpB,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAO3E;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAiDrC;;;;;OAKG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAwCvF;;;;OAIG;IACG,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CA+CxE"}
|