From 8d539a348bc889659d5b46599d1bbe601a302189 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sun, 21 Mar 2021 09:30:05 +0000 Subject: [PATCH] chore(release): 1.1.3 [skip ci] ## [1.1.3](https://github.com/InOG-projects/IRIS-library-js/compare/v1.1.2...v1.1.3) (2021-03-21) ### Bug Fixes * generate ts declaration file for typings ([4e390a3](https://github.com/InOG-projects/IRIS-library-js/commit/4e390a3c4545d9790d04656e244523f35a205274)) --- dist/index.d.ts | 2 + dist/index.js | 5 + dist/index.js.map | 1 + dist/index.test.d.ts | 1 + dist/index.test.js | 93 +++++++++++++++++++ dist/index.test.js.map | 1 + dist/lib/Iris.d.ts | 12 +++ dist/lib/Iris.js | 55 +++++++++++ dist/lib/Iris.js.map | 1 + dist/lib/crypto.d.ts | 5 + dist/lib/crypto.js | 19 ++++ dist/lib/crypto.js.map | 1 + dist/lib/index.d.ts | 2 + dist/lib/index.js | 5 + dist/lib/index.js.map | 1 + dist/lib/util.d.ts | 2 + dist/lib/util.js | 19 ++++ dist/lib/util.js.map | 1 + dist/types/IrisCode.d.ts | 2 + dist/types/IrisCode.js | 3 + dist/types/IrisCode.js.map | 1 + dist/types/IrisCodeKeyMap.d.ts | 4 + dist/types/IrisCodeKeyMap.js | 3 + dist/types/IrisCodeKeyMap.js.map | 1 + dist/types/IrisContactsEvents.d.ts | 68 ++++++++++++++ dist/types/IrisContactsEvents.js | 18 ++++ dist/types/IrisContactsEvents.js.map | 1 + dist/types/IrisDataRequest.d.ts | 3 + dist/types/IrisDataRequest.js | 3 + dist/types/IrisDataRequest.js.map | 1 + dist/types/IrisOptions.d.ts | 3 + dist/types/IrisOptions.js | 3 + dist/types/IrisOptions.js.map | 1 + dist/types/IrisUserInfo.d.ts | 5 + dist/types/IrisUserInfo.js | 3 + dist/types/IrisUserInfo.js.map | 1 + .../dto/IrisContactsEventsSubmissionDTO.d.ts | 7 ++ .../dto/IrisContactsEventsSubmissionDTO.js | 3 + .../IrisContactsEventsSubmissionDTO.js.map | 1 + dist/types/dto/IrisDataRequestDTO.d.ts | 8 ++ dist/types/dto/IrisDataRequestDTO.js | 3 + dist/types/dto/IrisDataRequestDTO.js.map | 1 + docs/CHANGELOG.md | 7 ++ package.json | 2 +- 44 files changed, 381 insertions(+), 1 deletion(-) create mode 100644 dist/index.d.ts create mode 100644 dist/index.js create mode 100644 dist/index.js.map create mode 100644 dist/index.test.d.ts create mode 100644 dist/index.test.js create mode 100644 dist/index.test.js.map create mode 100644 dist/lib/Iris.d.ts create mode 100644 dist/lib/Iris.js create mode 100644 dist/lib/Iris.js.map create mode 100644 dist/lib/crypto.d.ts create mode 100644 dist/lib/crypto.js create mode 100644 dist/lib/crypto.js.map create mode 100644 dist/lib/index.d.ts create mode 100644 dist/lib/index.js create mode 100644 dist/lib/index.js.map create mode 100644 dist/lib/util.d.ts create mode 100644 dist/lib/util.js create mode 100644 dist/lib/util.js.map create mode 100644 dist/types/IrisCode.d.ts create mode 100644 dist/types/IrisCode.js create mode 100644 dist/types/IrisCode.js.map create mode 100644 dist/types/IrisCodeKeyMap.d.ts create mode 100644 dist/types/IrisCodeKeyMap.js create mode 100644 dist/types/IrisCodeKeyMap.js.map create mode 100644 dist/types/IrisContactsEvents.d.ts create mode 100644 dist/types/IrisContactsEvents.js create mode 100644 dist/types/IrisContactsEvents.js.map create mode 100644 dist/types/IrisDataRequest.d.ts create mode 100644 dist/types/IrisDataRequest.js create mode 100644 dist/types/IrisDataRequest.js.map create mode 100644 dist/types/IrisOptions.d.ts create mode 100644 dist/types/IrisOptions.js create mode 100644 dist/types/IrisOptions.js.map create mode 100644 dist/types/IrisUserInfo.d.ts create mode 100644 dist/types/IrisUserInfo.js create mode 100644 dist/types/IrisUserInfo.js.map create mode 100644 dist/types/dto/IrisContactsEventsSubmissionDTO.d.ts create mode 100644 dist/types/dto/IrisContactsEventsSubmissionDTO.js create mode 100644 dist/types/dto/IrisContactsEventsSubmissionDTO.js.map create mode 100644 dist/types/dto/IrisDataRequestDTO.d.ts create mode 100644 dist/types/dto/IrisDataRequestDTO.js create mode 100644 dist/types/dto/IrisDataRequestDTO.js.map diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..468a1f5 --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,2 @@ +import Iris from './lib/'; +export default Iris; diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..da244d2 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const lib_1 = require("./lib/"); +exports.default = lib_1.default; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 0000000..2917c34 --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,gCAA0B;AAC1B,kBAAe,aAAI,CAAC"} \ No newline at end of file diff --git a/dist/index.test.d.ts b/dist/index.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/index.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/index.test.js b/dist/index.test.js new file mode 100644 index 0000000..894a4fe --- /dev/null +++ b/dist/index.test.js @@ -0,0 +1,93 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const axios_1 = require("axios"); +const crypto = require("crypto"); +const _1 = require("."); +jest.mock('axios'); +const mockedAxios = axios_1.default; +describe('index', () => { + let privateKey; + let publicKey; + let dataRequest; + const submission = { + contacts: { + contactPersons: [], + dataProvider: { + firstName: 'Hans', + lastName: 'Müller', + }, + }, + events: { + events: [], + dataProvider: { + firstName: 'Hans', + lastName: 'Müller', + }, + }, + }; + beforeAll((done) => { + mockedAxios.create.mockImplementation(() => { + return mockedAxios; + }); + crypto.generateKeyPair('rsa', { + modulusLength: 4096, + publicKeyEncoding: { + type: 'spki', + format: 'pem', + }, + privateKeyEncoding: { + type: 'pkcs8', + format: 'pem', + cipher: 'aes-256-cbc', + passphrase: 'top secret', + }, + }, (err, pub, priv) => { + publicKey = pub; + privateKey = priv; + dataRequest = { + healthDepartment: 'Test Health Department', + keyOfHealthDepartment: publicKey, + keyReferenz: 'random-string-keyref', + start: '2011-10-05T14:48:00.000Z', + end: '2021-10-05T14:48:00.000Z', + }; + done(err); + }); + }); + it('provides the Iris class', () => { + expect(new _1.default({})).toBeDefined(); + }); + it('can retrieve a data request and send a corresponding data submission', async () => { + mockedAxios.get.mockResolvedValue({ status: 200, data: dataRequest }); + const iris = new _1.default({}); + const dataRequestResult = await iris.getDataRequest('12345-abcde'); + expect(dataRequestResult).toEqual({ + healthDepartment: 'Test Health Department', + start: '2011-10-05T14:48:00.000Z', + end: '2021-10-05T14:48:00.000Z', + }); + expect(mockedAxios.get).toHaveBeenCalledWith('/data-requests/12345-abcde'); + mockedAxios.post.mockResolvedValue({ status: 200, data: { success: true } }); + await iris.sendContactsEvents('12345-abcde', submission, { + firstName: 'Hans', + lastName: 'Müller', + birthDate: '1963-01-05T14:48:00.000Z', + }); + expect(mockedAxios.post).toHaveBeenCalledWith('/data-submissions/12345-abcde/contacts_events', { + checkCode: [expect.any(String), expect.any(String)], + secret: expect.any(String), + keyReferenz: 'random-string-keyref', + encryptedData: expect.any(String), + nonce: expect.any(String), + }); + const submittedData = mockedAxios.post.mock.calls[0][1]; + expect(submittedData.checkCode[0]).toEqual(crypto.createHash('md5').update('hansmller').digest('base64')); + expect(submittedData.checkCode[1]).toEqual(crypto.createHash('md5').update('19630105').digest('base64')); + const symmetricKey = crypto.privateDecrypt({ key: privateKey, passphrase: 'top secret' }, Buffer.from(submittedData.secret, 'base64')); + const decipher = crypto.createDecipheriv('AES-256-CBC', symmetricKey, Buffer.from(submittedData.nonce, 'base64')); + let receivedPlaintext = decipher.update(submittedData.encryptedData, 'base64', 'utf8'); + receivedPlaintext += decipher.final(); + expect(JSON.parse(receivedPlaintext)).toEqual(submission); + }); +}); +//# sourceMappingURL=index.test.js.map \ No newline at end of file diff --git a/dist/index.test.js.map b/dist/index.test.js.map new file mode 100644 index 0000000..ae4eb6b --- /dev/null +++ b/dist/index.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":";;AAAA,iCAA0B;AAC1B,iCAAiC;AAEjC,wBAAqB;AAIrB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACnB,MAAM,WAAW,GAAG,eAAkC,CAAC;AAEvD,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,IAAI,UAAkB,CAAC;IACvB,IAAI,SAAiB,CAAC;IACtB,IAAI,WAA+B,CAAC;IACpC,MAAM,UAAU,GAAuB;QACrC,QAAQ,EAAE;YACR,cAAc,EAAE,EAAE;YAClB,YAAY,EAAE;gBACZ,SAAS,EAAE,MAAM;gBACjB,QAAQ,EAAE,QAAQ;aACnB;SACF;QACD,MAAM,EAAE;YACN,MAAM,EAAE,EAAE;YACV,YAAY,EAAE;gBACZ,SAAS,EAAE,MAAM;gBACjB,QAAQ,EAAE,QAAQ;aACnB;SACF;KACF,CAAC;IACF,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;QACjB,WAAW,CAAC,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE;YACzC,OAAO,WAAW,CAAC;QACrB,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,eAAe,CACpB,KAAK,EACL;YACE,aAAa,EAAE,IAAI;YACnB,iBAAiB,EAAE;gBACjB,IAAI,EAAE,MAAM;gBACZ,MAAM,EAAE,KAAK;aACd;YACD,kBAAkB,EAAE;gBAClB,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE,aAAa;gBACrB,UAAU,EAAE,YAAY;aACzB;SACF,EACD,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;YACjB,SAAS,GAAG,GAAG,CAAC;YAChB,UAAU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AAI,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACvF,iBAAiB,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/lib/Iris.d.ts b/dist/lib/Iris.d.ts new file mode 100644 index 0000000..e6f2ee7 --- /dev/null +++ b/dist/lib/Iris.d.ts @@ -0,0 +1,12 @@ +import IrisOptions from '../types/IrisOptions'; +import IrisCode from '../types/IrisCode'; +import IrisDataRequest from '../types/IrisDataRequest'; +import IrisContactsEvents from '../types/IrisContactsEvents'; +import IrisUserInfo from '../types/IrisUserInfo'; +export default class Iris { + private axiosInstance; + private codeKeyMap; + constructor(options: Partial); + getDataRequest(code: IrisCode): Promise; + sendContactsEvents(code: IrisCode, data: IrisContactsEvents, user: IrisUserInfo): Promise; +} diff --git a/dist/lib/Iris.js b/dist/lib/Iris.js new file mode 100644 index 0000000..ab2a0ac --- /dev/null +++ b/dist/lib/Iris.js @@ -0,0 +1,55 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const axios_1 = require("axios"); +const crypto_1 = require("./crypto"); +const util_1 = require("./util"); +const defaultOptions = { + baseUrl: '', +}; +class Iris { + constructor(options) { + this.codeKeyMap = new Map(); + const opts = Object.assign(defaultOptions, options); + this.axiosInstance = axios_1.default.create({ + baseURL: opts.baseUrl, + }); + } + async getDataRequest(code) { + const response = await this.axiosInstance.get(`/data-requests/${code}`); + if (response.status !== 200) { + console.error('IRIS Gateway responded the following data', response.data); + throw new Error(`Request failed with status Code ${response.status}`); + } + const dataRequest = response.data; + this.codeKeyMap.set(code, { + keyOfHealthDepartment: dataRequest.keyOfHealthDepartment, + keyReferenz: dataRequest.keyReferenz, + }); + return { + healthDepartment: dataRequest.healthDepartment, + start: dataRequest.start, + end: dataRequest.end, + requestDetails: dataRequest.requestDetails, + }; + } + async sendContactsEvents(code, data, user) { + if (!this.codeKeyMap.has(code)) { + throw new Error("Code could not be found in key map. Did you perform 'getDataRequest' before?"); + } + const keys = this.codeKeyMap.get(code); + const { dataToTransport, keyToTransport, nonce } = crypto_1.encryptData(keys.keyOfHealthDepartment, data); + const response = await this.axiosInstance.post(`/data-submissions/${code}/contacts_events`, { + checkCode: [util_1.getNameCheckHash(user.firstName, user.lastName), util_1.getBirthDateCheckHash(user.birthDate)].filter(c => !!c), + secret: keyToTransport, + keyReferenz: keys.keyReferenz, + encryptedData: dataToTransport, + nonce + }); + if (response.status !== 200) { + console.error('IRIS Gateway responded the following data', response.data); + throw new Error(`Request failed with status Code ${response.status}`); + } + } +} +exports.default = Iris; +//# sourceMappingURL=Iris.js.map \ No newline at end of file diff --git a/dist/lib/Iris.js.map b/dist/lib/Iris.js.map new file mode 100644 index 0000000..d81208e --- /dev/null +++ b/dist/lib/Iris.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Iris.js","sourceRoot":"","sources":["../../src/lib/Iris.ts"],"names":[],"mappings":";;AAAA,iCAA6C;AAE7C,qCAAuC;AACvC,iCAAiE;AAWjE,MAAM,cAAc,GAAgB;IAClC,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF,MAAqB,IAAI;IAIvB,YAAY,OAA6B;QACvC,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAgB,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QACjE,IAAI,CAAC,aAAa,GAAG,eAAK,CAAC,MAAM,CAAC;YAChC,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,IAAc;QACjC,MAAM,QAAQ,GAAG,MAAM,IA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,EAAE,4BAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YACtH,MAAM,EAAE,cAAc;YACtB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,aAAa,EAAE,eAAe;YAC9B,KAAK;SAC6B,CAAC,CAAC;QACtC,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;YAC3B,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC1E,MAAM,IAAI,KAAK,CAAC,mCAAmC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;SACvE;IACH,CAAC;CACF;AAjDD,uBAiDC"} \ No newline at end of file diff --git a/dist/lib/crypto.d.ts b/dist/lib/crypto.d.ts new file mode 100644 index 0000000..9dc7796 --- /dev/null +++ b/dist/lib/crypto.d.ts @@ -0,0 +1,5 @@ +export declare function encryptData(keyOfHealthDepartment: string, data: any): { + dataToTransport: string; + keyToTransport: string; + nonce: string; +}; diff --git a/dist/lib/crypto.js b/dist/lib/crypto.js new file mode 100644 index 0000000..e00eb22 --- /dev/null +++ b/dist/lib/crypto.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.encryptData = void 0; +const crypto = require("crypto"); +function encryptData(keyOfHealthDepartment, data) { + const nonce = crypto.randomBytes(16); + const key = crypto.randomBytes(32); + const cipher = crypto.createCipheriv('AES-256-CBC', key, nonce); + const dataString = JSON.stringify(data); + const encryptedData = Buffer.concat([cipher.update(dataString, 'utf8'), cipher.final()]); + const encryptedKey = crypto.publicEncrypt({ key: keyOfHealthDepartment }, key); + return { + dataToTransport: encryptedData.toString('base64'), + keyToTransport: encryptedKey.toString('base64'), + nonce: nonce.toString('base64'), + }; +} +exports.encryptData = encryptData; +//# sourceMappingURL=crypto.js.map \ No newline at end of file diff --git a/dist/lib/crypto.js.map b/dist/lib/crypto.js.map new file mode 100644 index 0000000..767dc06 --- /dev/null +++ b/dist/lib/crypto.js.map @@ -0,0 +1 @@ +{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/lib/crypto.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAEjC,SAAgB,WAAW,CACzB,qBAA6B,EAC7B,IAAI;IAEJ,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACzF,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,EAAE,GAAG,EAAE,qBAAqB,EAAE,EAAE,GAAG,CAAC,CAAC;IAC/E,OAAO;QACL,eAAe,EAAE,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACjD,cAAc,EAAE,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC/C,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC;KAChC,CAAC;AACJ,CAAC;AAfD,kCAeC"} \ No newline at end of file diff --git a/dist/lib/index.d.ts b/dist/lib/index.d.ts new file mode 100644 index 0000000..f71bd90 --- /dev/null +++ b/dist/lib/index.d.ts @@ -0,0 +1,2 @@ +import Iris from './Iris'; +export default Iris; diff --git a/dist/lib/index.js b/dist/lib/index.js new file mode 100644 index 0000000..d72925e --- /dev/null +++ b/dist/lib/index.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Iris_1 = require("./Iris"); +exports.default = Iris_1.default; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/lib/index.js.map b/dist/lib/index.js.map new file mode 100644 index 0000000..6a57ad8 --- /dev/null +++ b/dist/lib/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;AAAA,iCAA0B;AAC1B,kBAAe,cAAI,CAAC"} \ No newline at end of file diff --git a/dist/lib/util.d.ts b/dist/lib/util.d.ts new file mode 100644 index 0000000..76db3eb --- /dev/null +++ b/dist/lib/util.d.ts @@ -0,0 +1,2 @@ +export declare function getNameCheckHash(firstName: string, lastName: string): string; +export declare function getBirthDateCheckHash(birthDate?: string): string | undefined; diff --git a/dist/lib/util.js b/dist/lib/util.js new file mode 100644 index 0000000..c4139af --- /dev/null +++ b/dist/lib/util.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getBirthDateCheckHash = exports.getNameCheckHash = void 0; +const crypto = require("crypto"); +function getNameCheckHash(firstName, lastName) { + const str = `${firstName.trim()}${lastName.trim()}`.toLowerCase().replace(/\W/g, ''); + return crypto.createHash('md5').update(str).digest('base64'); +} +exports.getNameCheckHash = getNameCheckHash; +function getBirthDateCheckHash(birthDate) { + if (!birthDate) { + return undefined; + } + const date = new Date(birthDate); + const str = `${date.getFullYear()}${(date.getMonth() + 1).toString().padStart(2, '0')}${date.getDate().toString().padStart(2, '0')}`; + return crypto.createHash('md5').update(str).digest('base64'); +} +exports.getBirthDateCheckHash = getBirthDateCheckHash; +//# sourceMappingURL=util.js.map \ No newline at end of file diff --git a/dist/lib/util.js.map b/dist/lib/util.js.map new file mode 100644 index 0000000..5ffbdc7 --- /dev/null +++ b/dist/lib/util.js.map @@ -0,0 +1 @@ +{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/lib/util.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAEjC,SAAgB,gBAAgB,CAAC,SAAiB,EAAE,QAAgB;IAClE,MAAM,GAAG,GAAG,GAAG,SAAS,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACrF,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC/D,CAAC;AAHD,4CAGC;AACD,SAAgB,qBAAqB,CAAC,SAAkB;IACtD,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAA;IACpI,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC/D,CAAC;AAPD,sDAOC"} \ No newline at end of file diff --git a/dist/types/IrisCode.d.ts b/dist/types/IrisCode.d.ts new file mode 100644 index 0000000..15c0047 --- /dev/null +++ b/dist/types/IrisCode.d.ts @@ -0,0 +1,2 @@ +declare type IrisCode = string; +export default IrisCode; diff --git a/dist/types/IrisCode.js b/dist/types/IrisCode.js new file mode 100644 index 0000000..e94ea63 --- /dev/null +++ b/dist/types/IrisCode.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=IrisCode.js.map \ No newline at end of file diff --git a/dist/types/IrisCode.js.map b/dist/types/IrisCode.js.map new file mode 100644 index 0000000..a73ee5d --- /dev/null +++ b/dist/types/IrisCode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IrisCode.js","sourceRoot":"","sources":["../../src/types/IrisCode.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/types/IrisCodeKeyMap.d.ts b/dist/types/IrisCodeKeyMap.d.ts new file mode 100644 index 0000000..1860130 --- /dev/null +++ b/dist/types/IrisCodeKeyMap.d.ts @@ -0,0 +1,4 @@ +import IrisDataRequestDTO from './dto/IrisDataRequestDTO'; +import IrisCode from './IrisCode'; +declare type IrisCodeKeyMap = Map>; +export default IrisCodeKeyMap; diff --git a/dist/types/IrisCodeKeyMap.js b/dist/types/IrisCodeKeyMap.js new file mode 100644 index 0000000..45663b7 --- /dev/null +++ b/dist/types/IrisCodeKeyMap.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=IrisCodeKeyMap.js.map \ No newline at end of file diff --git a/dist/types/IrisCodeKeyMap.js.map b/dist/types/IrisCodeKeyMap.js.map new file mode 100644 index 0000000..cc3acdf --- /dev/null +++ b/dist/types/IrisCodeKeyMap.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IrisCodeKeyMap.js","sourceRoot":"","sources":["../../src/types/IrisCodeKeyMap.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/types/IrisContactsEvents.d.ts b/dist/types/IrisContactsEvents.d.ts new file mode 100644 index 0000000..a5dfe68 --- /dev/null +++ b/dist/types/IrisContactsEvents.d.ts @@ -0,0 +1,68 @@ +interface DataProvider { + firstName?: string; + lastName?: string; + dateOfBirth?: string; +} +declare enum Sex { + MALE = "MALE", + FEMALE = "FEMALE", + OTHER = "OTHER", + UNKNOWN = "UNKNOWN" +} +interface Address { + street: string; + houseNumber: string; + zipCode: string; + city: string; +} +declare enum ContactCategory { + HIGH_RISK = "HIGH_RISK", + HIGH_RISK_MED = "HIGH_RISK_MED", + MEDIUM_RISK_MED = "MEDIUM_RISK_MED", + LOW_RISK = "LOW_RISK", + NO_RISK = "NO_RISK" +} +interface ContactPerson { + firstName: string; + lastName: string; + dateOfBirth?: string; + sex?: Sex; + email?: string; + phone?: string; + mobilPhone?: string; + address?: Address; + workPlace?: { + name?: string; + pointOfContact?: string; + phone?: string; + address?: Address; + }; + contactInformation?: { + date?: string; + contactCategory?: ContactCategory; + basicConditions?: string; + }; +} +interface Event { + name?: string; + phone?: string; + address?: Address; + additionalInformation?: string; +} +interface ContactPersonList { + contactPersons: Array; + dataProvider?: DataProvider; + startDate?: string; + endDate?: string; +} +interface EventList { + events: Array; + dataProvider?: DataProvider; + startDate?: string; + endDate?: string; +} +export default interface IrisContactsEvents { + contacts: ContactPersonList; + events: EventList; +} +export {}; diff --git a/dist/types/IrisContactsEvents.js b/dist/types/IrisContactsEvents.js new file mode 100644 index 0000000..f08a542 --- /dev/null +++ b/dist/types/IrisContactsEvents.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Sex; +(function (Sex) { + Sex["MALE"] = "MALE"; + Sex["FEMALE"] = "FEMALE"; + Sex["OTHER"] = "OTHER"; + Sex["UNKNOWN"] = "UNKNOWN"; +})(Sex || (Sex = {})); +var ContactCategory; +(function (ContactCategory) { + ContactCategory["HIGH_RISK"] = "HIGH_RISK"; + ContactCategory["HIGH_RISK_MED"] = "HIGH_RISK_MED"; + ContactCategory["MEDIUM_RISK_MED"] = "MEDIUM_RISK_MED"; + ContactCategory["LOW_RISK"] = "LOW_RISK"; + ContactCategory["NO_RISK"] = "NO_RISK"; +})(ContactCategory || (ContactCategory = {})); +//# sourceMappingURL=IrisContactsEvents.js.map \ No newline at end of file diff --git a/dist/types/IrisContactsEvents.js.map b/dist/types/IrisContactsEvents.js.map new file mode 100644 index 0000000..da239b8 --- /dev/null +++ b/dist/types/IrisContactsEvents.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IrisContactsEvents.js","sourceRoot":"","sources":["../../src/types/IrisContactsEvents.ts"],"names":[],"mappings":";;AAKA,IAAK,GAKJ;AALD,WAAK,GAAG;IACN,oBAAa,CAAA;IACb,wBAAiB,CAAA;IACjB,sBAAe,CAAA;IACf,0BAAmB,CAAA;AACrB,CAAC,EALI,GAAG,KAAH,GAAG,QAKP;AAQD,IAAK,eAMJ;AAND,WAAK,eAAe;IAClB,0CAAuB,CAAA;IACvB,kDAA+B,CAAA;IAC/B,sDAAmC,CAAA;IACnC,wCAAqB,CAAA;IACrB,sCAAmB,CAAA;AACrB,CAAC,EANI,eAAe,KAAf,eAAe,QAMnB"} \ No newline at end of file diff --git a/dist/types/IrisDataRequest.d.ts b/dist/types/IrisDataRequest.d.ts new file mode 100644 index 0000000..eaa5c27 --- /dev/null +++ b/dist/types/IrisDataRequest.d.ts @@ -0,0 +1,3 @@ +import IrisDataRequestDTO from './dto/IrisDataRequestDTO'; +declare type IrisDataRequest = Pick; +export default IrisDataRequest; diff --git a/dist/types/IrisDataRequest.js b/dist/types/IrisDataRequest.js new file mode 100644 index 0000000..99908ff --- /dev/null +++ b/dist/types/IrisDataRequest.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=IrisDataRequest.js.map \ No newline at end of file diff --git a/dist/types/IrisDataRequest.js.map b/dist/types/IrisDataRequest.js.map new file mode 100644 index 0000000..6cd564e --- /dev/null +++ b/dist/types/IrisDataRequest.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IrisDataRequest.js","sourceRoot":"","sources":["../../src/types/IrisDataRequest.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/types/IrisOptions.d.ts b/dist/types/IrisOptions.d.ts new file mode 100644 index 0000000..f98be9d --- /dev/null +++ b/dist/types/IrisOptions.d.ts @@ -0,0 +1,3 @@ +export default interface IrisOptions { + baseUrl: string; +} diff --git a/dist/types/IrisOptions.js b/dist/types/IrisOptions.js new file mode 100644 index 0000000..df1ea91 --- /dev/null +++ b/dist/types/IrisOptions.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=IrisOptions.js.map \ No newline at end of file diff --git a/dist/types/IrisOptions.js.map b/dist/types/IrisOptions.js.map new file mode 100644 index 0000000..101b5ce --- /dev/null +++ b/dist/types/IrisOptions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IrisOptions.js","sourceRoot":"","sources":["../../src/types/IrisOptions.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/types/IrisUserInfo.d.ts b/dist/types/IrisUserInfo.d.ts new file mode 100644 index 0000000..e40999e --- /dev/null +++ b/dist/types/IrisUserInfo.d.ts @@ -0,0 +1,5 @@ +export default interface IrisUserInfo { + firstName: string; + lastName: string; + birthDate?: string; +} diff --git a/dist/types/IrisUserInfo.js b/dist/types/IrisUserInfo.js new file mode 100644 index 0000000..c3a345d --- /dev/null +++ b/dist/types/IrisUserInfo.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=IrisUserInfo.js.map \ No newline at end of file diff --git a/dist/types/IrisUserInfo.js.map b/dist/types/IrisUserInfo.js.map new file mode 100644 index 0000000..0e595e1 --- /dev/null +++ b/dist/types/IrisUserInfo.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IrisUserInfo.js","sourceRoot":"","sources":["../../src/types/IrisUserInfo.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/types/dto/IrisContactsEventsSubmissionDTO.d.ts b/dist/types/dto/IrisContactsEventsSubmissionDTO.d.ts new file mode 100644 index 0000000..16e0b18 --- /dev/null +++ b/dist/types/dto/IrisContactsEventsSubmissionDTO.d.ts @@ -0,0 +1,7 @@ +export default interface IrisContactsEventsSubmissionDTO { + checkCode: Array; + secret: string; + keyReferenz: string; + encryptedData: string; + nonce: string; +} diff --git a/dist/types/dto/IrisContactsEventsSubmissionDTO.js b/dist/types/dto/IrisContactsEventsSubmissionDTO.js new file mode 100644 index 0000000..14a93d6 --- /dev/null +++ b/dist/types/dto/IrisContactsEventsSubmissionDTO.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=IrisContactsEventsSubmissionDTO.js.map \ No newline at end of file diff --git a/dist/types/dto/IrisContactsEventsSubmissionDTO.js.map b/dist/types/dto/IrisContactsEventsSubmissionDTO.js.map new file mode 100644 index 0000000..4413d7d --- /dev/null +++ b/dist/types/dto/IrisContactsEventsSubmissionDTO.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IrisContactsEventsSubmissionDTO.js","sourceRoot":"","sources":["../../../src/types/dto/IrisContactsEventsSubmissionDTO.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/types/dto/IrisDataRequestDTO.d.ts b/dist/types/dto/IrisDataRequestDTO.d.ts new file mode 100644 index 0000000..4f0e0ca --- /dev/null +++ b/dist/types/dto/IrisDataRequestDTO.d.ts @@ -0,0 +1,8 @@ +export default interface IrisDataRequestDTO { + healthDepartment: string; + keyOfHealthDepartment: string; + keyReferenz: string; + start?: string; + end?: string; + requestDetails?: string; +} diff --git a/dist/types/dto/IrisDataRequestDTO.js b/dist/types/dto/IrisDataRequestDTO.js new file mode 100644 index 0000000..4e6c68d --- /dev/null +++ b/dist/types/dto/IrisDataRequestDTO.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=IrisDataRequestDTO.js.map \ No newline at end of file diff --git a/dist/types/dto/IrisDataRequestDTO.js.map b/dist/types/dto/IrisDataRequestDTO.js.map new file mode 100644 index 0000000..d9efc1e --- /dev/null +++ b/dist/types/dto/IrisDataRequestDTO.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IrisDataRequestDTO.js","sourceRoot":"","sources":["../../../src/types/dto/IrisDataRequestDTO.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ba5f875..ed73029 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.1.3](https://github.com/InOG-projects/IRIS-library-js/compare/v1.1.2...v1.1.3) (2021-03-21) + + +### Bug Fixes + +* generate ts declaration file for typings ([4e390a3](https://github.com/InOG-projects/IRIS-library-js/commit/4e390a3c4545d9790d04656e244523f35a205274)) + ## [1.1.2](https://github.com/InOG-projects/IRIS-library-js/compare/v1.1.1...v1.1.2) (2021-03-21) diff --git a/package.json b/package.json index ddbe689..0efc35f 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "type": "git", "url": "https://github.com/InOG-projects/IRIS-library-js.git" }, - "version": "1.1.2", + "version": "1.1.3", "dependencies": { "axios": "^0.21.1" },