@icure/api 5.0.31 → 5.0.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/icc-x-api/icc-crypto-x-api.d.ts +7 -12
- package/icc-x-api/icc-crypto-x-api.js +25 -33
- package/icc-x-api/icc-crypto-x-api.js.map +1 -1
- package/icc-x-api/index.d.ts +4 -0
- package/icc-x-api/index.js +5 -1
- package/icc-x-api/index.js.map +1 -1
- package/icc-x-api/storage/KeyStorageFacade.d.ts +37 -0
- package/icc-x-api/storage/KeyStorageFacade.js +3 -0
- package/icc-x-api/storage/KeyStorageFacade.js.map +1 -0
- package/icc-x-api/storage/KeyStorageImpl.d.ts +17 -0
- package/icc-x-api/storage/KeyStorageImpl.js +34 -0
- package/icc-x-api/storage/KeyStorageImpl.js.map +1 -0
- package/icc-x-api/storage/LocalStorageImpl.d.ts +10 -0
- package/icc-x-api/storage/LocalStorageImpl.js +25 -0
- package/icc-x-api/storage/LocalStorageImpl.js.map +1 -0
- package/icc-x-api/storage/StorageFacade.d.ts +19 -0
- package/icc-x-api/storage/StorageFacade.js +3 -0
- package/icc-x-api/storage/StorageFacade.js.map +1 -0
- package/package.json +1 -1
package/icc-x-api/index.d.ts
CHANGED
|
@@ -37,6 +37,10 @@ export * from './icc-user-x-api';
|
|
|
37
37
|
export * from './icc-time-table-x-api';
|
|
38
38
|
export * from './icc-receipt-x-api';
|
|
39
39
|
export * from './utils';
|
|
40
|
+
export { KeyStorageFacade } from './storage/KeyStorageFacade';
|
|
41
|
+
export { LocalStorageImpl } from './storage/LocalStorageImpl';
|
|
42
|
+
export { StorageFacade } from './storage/StorageFacade';
|
|
43
|
+
export { KeyStorageImpl } from './storage/KeyStorageImpl';
|
|
40
44
|
export declare const apiHeaders: (username: string, password: string, forceBasic?: boolean) => {
|
|
41
45
|
Authorization: string;
|
|
42
46
|
'force-authentication': string;
|
package/icc-x-api/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Api = exports.apiHeaders = void 0;
|
|
26
|
+
exports.Api = exports.apiHeaders = exports.KeyStorageImpl = exports.LocalStorageImpl = void 0;
|
|
27
27
|
const icc_api_1 = require("../icc-api");
|
|
28
28
|
const icc_user_x_api_1 = require("./icc-user-x-api");
|
|
29
29
|
const icc_crypto_x_api_1 = require("./icc-crypto-x-api");
|
|
@@ -64,6 +64,10 @@ __exportStar(require("./icc-user-x-api"), exports);
|
|
|
64
64
|
__exportStar(require("./icc-time-table-x-api"), exports);
|
|
65
65
|
__exportStar(require("./icc-receipt-x-api"), exports);
|
|
66
66
|
__exportStar(require("./utils"), exports);
|
|
67
|
+
var LocalStorageImpl_1 = require("./storage/LocalStorageImpl");
|
|
68
|
+
Object.defineProperty(exports, "LocalStorageImpl", { enumerable: true, get: function () { return LocalStorageImpl_1.LocalStorageImpl; } });
|
|
69
|
+
var KeyStorageImpl_1 = require("./storage/KeyStorageImpl");
|
|
70
|
+
Object.defineProperty(exports, "KeyStorageImpl", { enumerable: true, get: function () { return KeyStorageImpl_1.KeyStorageImpl; } });
|
|
67
71
|
const apiHeaders = function (username, password, forceBasic = false) {
|
|
68
72
|
return {
|
|
69
73
|
Authorization: `Basic ${typeof btoa !== 'undefined' ? btoa(`${username}:${password}`) : Buffer.from(`${username}:${password}`).toString('base64')}`,
|
package/icc-x-api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../icc-x-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAqI;AACrI,qDAA8C;AAC9C,yDAAkD;AAClD,2DAAoD;AACpD,2DAAoD;AACpD,6DAAsD;AACtD,2DAAoD;AACpD,qDAA8C;AAC9C,6DAAsD;AACtD,yEAAkE;A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,kBAAkB;YAClB,UAAU;YACV,SAAS;YACT,eAAe;YACf,iBAAiB;YACjB,YAAY;YACZ,QAAQ;YACR,kBAAkB;YAClB,YAAY;SACb,CAAA;IACH,CAAC;CAAA,CAAA;AA9FY,QAAA,GAAG,OA8Ff","sourcesContent":["import { IccAgendaApi, IccAuthApi, IccEntityrefApi, IccGroupApi, IccInsuranceApi, IccPatientApi, IccPermissionApi } from '../icc-api'\nimport { IccUserXApi } from './icc-user-x-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccContactXApi } from './icc-contact-x-api'\nimport { IccInvoiceXApi } from './icc-invoice-x-api'\nimport { IccDocumentXApi } from './icc-document-x-api'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { IccFormXApi } from './icc-form-x-api'\nimport { IccHelementXApi } from './icc-helement-x-api'\nimport { IccClassificationXApi } from './icc-classification-x-api'\nimport { IccCalendarItemXApi } from './icc-calendar-item-x-api'\nimport { IccPatientXApi } from './icc-patient-x-api'\nimport { IccMessageXApi } from './icc-message-x-api'\nimport { IccReceiptXApi } from './icc-receipt-x-api'\nimport { IccAccesslogXApi } from './icc-accesslog-x-api'\nimport { IccTimeTableXApi } from './icc-time-table-x-api'\nimport { IccDeviceApi } from '../icc-api/api/IccDeviceApi'\nimport { IccCodeXApi } from './icc-code-x-api'\nimport { IccMaintenanceTaskXApi } from './icc-maintenance-task-x-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { retry } from './utils'\n\nexport * from './icc-accesslog-x-api'\nexport * from './icc-bekmehr-x-api'\nexport * from './icc-calendar-item-x-api'\nexport * from './icc-classification-x-api'\nexport * from './icc-code-x-api'\nexport * from './icc-contact-x-api'\nexport * from './icc-crypto-x-api'\nexport * from './icc-doctemplate-x-api'\nexport * from './icc-document-x-api'\nexport * from './icc-form-x-api'\nexport * from './icc-hcparty-x-api'\nexport * from './icc-helement-x-api'\nexport * from './icc-invoice-x-api'\nexport * from './icc-message-x-api'\nexport * from './icc-patient-x-api'\nexport * from './icc-user-x-api'\nexport * from './icc-time-table-x-api'\nexport * from './icc-receipt-x-api'\nexport * from './utils'\n\nexport const apiHeaders = function (username: string, password: string, forceBasic = false) {\n return {\n Authorization: `Basic ${\n typeof btoa !== 'undefined' ? btoa(`${username}:${password}`) : Buffer.from(`${username}:${password}`).toString('base64')\n }`,\n 'force-authentication': forceBasic ? 'true' : 'false',\n }\n}\n\nexport interface Apis {\n authApi: IccAuthApi\n codeApi: IccCodeXApi\n entityReferenceApi: IccEntityrefApi\n userApi: IccUserXApi\n permissionApi: IccPermissionApi\n healthcarePartyApi: IccHcpartyXApi\n deviceApi: IccDeviceApi\n cryptoApi: IccCryptoXApi\n accessLogApi: IccAccesslogXApi\n agendaApi: IccAgendaApi\n contactApi: IccContactXApi\n formApi: IccFormXApi\n groupApi: IccGroupApi\n invoiceApi: IccInvoiceXApi\n insuranceApi: IccInsuranceApi\n documentApi: IccDocumentXApi\n healthcareElementApi: IccHelementXApi\n classificationApi: IccClassificationXApi\n calendarItemApi: IccCalendarItemXApi\n receiptApi: IccReceiptXApi\n timetableApi: IccTimeTableXApi\n patientApi: IccPatientXApi\n messageApi: IccMessageXApi\n maintenanceTaskApi: IccMaintenanceTaskXApi\n dataOwnerApi: IccDataOwnerXApi\n}\n\nexport const Api = async function (\n host: string,\n username: string,\n password: string,\n crypto: Crypto = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : ({} as Crypto),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch,\n forceBasic = false,\n autoLogin = true\n): Promise<Apis> {\n const headers = apiHeaders(username, password, forceBasic)\n const authApi = new IccAuthApi(host, headers, fetchImpl)\n const codeApi = new IccCodeXApi(host, headers, fetchImpl)\n const entityReferenceApi = new IccEntityrefApi(host, headers, fetchImpl)\n const userApi = new IccUserXApi(host, headers, fetchImpl)\n const permissionApi = new IccPermissionApi(host, headers, fetchImpl)\n const healthcarePartyApi = new IccHcpartyXApi(host, headers, fetchImpl)\n const deviceApi = new IccDeviceApi(host, headers, fetchImpl)\n const cryptoApi = new IccCryptoXApi(host, headers, healthcarePartyApi, new IccPatientApi(host, headers, fetchImpl), deviceApi, crypto)\n const dataOwnerApi = new IccDataOwnerXApi(cryptoApi, new IccPatientApi(host, headers, fetchImpl))\n const accessLogApi = new IccAccesslogXApi(host, headers, cryptoApi, dataOwnerApi, fetchImpl)\n const agendaApi = new IccAgendaApi(host, headers, fetchImpl)\n const contactApi = new IccContactXApi(host, headers, cryptoApi, dataOwnerApi, fetchImpl)\n const formApi = new IccFormXApi(host, headers, cryptoApi, dataOwnerApi, fetchImpl)\n const groupApi = new IccGroupApi(host, headers)\n const invoiceApi = new IccInvoiceXApi(host, headers, cryptoApi, entityReferenceApi, dataOwnerApi, fetchImpl)\n const insuranceApi = new IccInsuranceApi(host, headers, fetchImpl)\n const documentApi = new IccDocumentXApi(host, headers, cryptoApi, authApi, dataOwnerApi, fetchImpl)\n const healthcareElementApi = new IccHelementXApi(host, headers, cryptoApi, dataOwnerApi, ['descr', 'note'], fetchImpl)\n const classificationApi = new IccClassificationXApi(host, headers, cryptoApi, dataOwnerApi, fetchImpl)\n const calendarItemApi = new IccCalendarItemXApi(host, headers, cryptoApi, dataOwnerApi, ['details', 'title', 'patientId'], fetchImpl)\n const receiptApi = new IccReceiptXApi(host, headers, cryptoApi, dataOwnerApi, fetchImpl)\n const timetableApi = new IccTimeTableXApi(host, headers, cryptoApi, dataOwnerApi, fetchImpl)\n const patientApi = new IccPatientXApi(\n host,\n headers,\n cryptoApi,\n contactApi,\n formApi,\n healthcareElementApi,\n invoiceApi,\n documentApi,\n healthcarePartyApi,\n classificationApi,\n dataOwnerApi,\n calendarItemApi,\n ['note'],\n fetchImpl\n )\n const messageApi = new IccMessageXApi(host, headers, cryptoApi, dataOwnerApi, fetchImpl)\n const maintenanceTaskApi = new IccMaintenanceTaskXApi(host, headers, cryptoApi, healthcarePartyApi, dataOwnerApi, ['properties'], fetchImpl)\n\n if (autoLogin) {\n if (username != undefined && password != undefined) {\n try {\n await retry(() => authApi.login({ username, password }), 3, 1000, 1.5)\n } catch (e) {\n console.error('Incorrect user and password used to instantiate Api, or network problem', e)\n }\n }\n } else {\n console.info('Auto login skipped')\n }\n\n return {\n cryptoApi,\n authApi,\n codeApi,\n userApi,\n permissionApi,\n patientApi,\n healthcarePartyApi,\n deviceApi,\n accessLogApi,\n contactApi,\n healthcareElementApi,\n documentApi,\n formApi,\n invoiceApi,\n insuranceApi,\n messageApi,\n entityReferenceApi,\n receiptApi,\n agendaApi,\n calendarItemApi,\n classificationApi,\n timetableApi,\n groupApi,\n maintenanceTaskApi,\n dataOwnerApi,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../icc-x-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAqI;AACrI,qDAA8C;AAC9C,yDAAkD;AAClD,2DAAoD;AACpD,2DAAoD;AACpD,6DAAsD;AACtD,2DAAoD;AACpD,qDAA8C;AAC9C,6DAAsD;AACtD,yEAAkE;AAClE,uEAA+D;AAC/D,2DAAoD;AACpD,2DAAoD;AACpD,2DAAoD;AACpD,+DAAwD;AACxD,iEAAyD;AACzD,8DAA0D;AAC1D,qDAA8C;AAC9C,6EAAqE;AACrE,iEAAyD;AACzD,mCAA+B;AAE/B,wDAAqC;AACrC,sDAAmC;AACnC,4DAAyC;AACzC,6DAA0C;AAC1C,mDAAgC;AAChC,sDAAmC;AACnC,qDAAkC;AAClC,0DAAuC;AACvC,uDAAoC;AACpC,mDAAgC;AAChC,sDAAmC;AACnC,uDAAoC;AACpC,sDAAmC;AACnC,sDAAmC;AACnC,sDAAmC;AACnC,mDAAgC;AAChC,yDAAsC;AACtC,sDAAmC;AACnC,0CAAuB;AAEvB,+DAA6D;AAApD,oHAAA,gBAAgB,OAA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E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,CAAC,CAAA;QACxF,MAAM,kBAAkB,GAAG,IAAI,mDAAsB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,YAAY,EAAE,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC,CAAA;QAE5I,IAAI,SAAS,EAAE;YACb,IAAI,QAAQ,IAAI,SAAS,IAAI,QAAQ,IAAI,SAAS,EAAE;gBAClD,IAAI;oBACF,MAAM,IAAA,aAAK,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;iBACvE;gBAAC,OAAO,CAAC,EAAE;oBACV,OAAO,CAAC,KAAK,CAAC,yEAAyE,EAAE,CAAC,CAAC,CAAA;iBAC5F;aACF;SACF;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;SACnC;QAED,OAAO;YACL,SAAS;YACT,OAAO;YACP,OAAO;YACP,OAAO;YACP,aAAa;YACb,UAAU;YACV,kBAAkB;YAClB,SAAS;YACT,YAAY;YACZ,UAAU;YACV,oBAAoB;YACpB,WAAW;YACX,OAAO;YACP,UAAU;YACV,YAAY;YACZ,UAAU;YACV,kBAAkB;YAClB,UAAU;YACV,SAAS;YACT,eAAe;YACf,iBAAiB;YACjB,YAAY;YACZ,QAAQ;YACR,kBAAkB;YAClB,YAAY;SACb,CAAA;IACH,CAAC;CAAA,CAAA;AA9FY,QAAA,GAAG,OA8Ff","sourcesContent":["import { IccAgendaApi, IccAuthApi, IccEntityrefApi, IccGroupApi, IccInsuranceApi, IccPatientApi, IccPermissionApi } from '../icc-api'\nimport { IccUserXApi } from './icc-user-x-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccContactXApi } from './icc-contact-x-api'\nimport { IccInvoiceXApi } from './icc-invoice-x-api'\nimport { IccDocumentXApi } from './icc-document-x-api'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { IccFormXApi } from './icc-form-x-api'\nimport { IccHelementXApi } from './icc-helement-x-api'\nimport { IccClassificationXApi } from './icc-classification-x-api'\nimport { IccCalendarItemXApi } from './icc-calendar-item-x-api'\nimport { IccPatientXApi } from './icc-patient-x-api'\nimport { IccMessageXApi } from './icc-message-x-api'\nimport { IccReceiptXApi } from './icc-receipt-x-api'\nimport { IccAccesslogXApi } from './icc-accesslog-x-api'\nimport { IccTimeTableXApi } from './icc-time-table-x-api'\nimport { IccDeviceApi } from '../icc-api/api/IccDeviceApi'\nimport { IccCodeXApi } from './icc-code-x-api'\nimport { IccMaintenanceTaskXApi } from './icc-maintenance-task-x-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { retry } from './utils'\n\nexport * from './icc-accesslog-x-api'\nexport * from './icc-bekmehr-x-api'\nexport * from './icc-calendar-item-x-api'\nexport * from './icc-classification-x-api'\nexport * from './icc-code-x-api'\nexport * from './icc-contact-x-api'\nexport * from './icc-crypto-x-api'\nexport * from './icc-doctemplate-x-api'\nexport * from './icc-document-x-api'\nexport * from './icc-form-x-api'\nexport * from './icc-hcparty-x-api'\nexport * from './icc-helement-x-api'\nexport * from './icc-invoice-x-api'\nexport * from './icc-message-x-api'\nexport * from './icc-patient-x-api'\nexport * from './icc-user-x-api'\nexport * from './icc-time-table-x-api'\nexport * from './icc-receipt-x-api'\nexport * from './utils'\nexport { KeyStorageFacade } from './storage/KeyStorageFacade'\nexport { LocalStorageImpl } from './storage/LocalStorageImpl'\nexport { StorageFacade } from './storage/StorageFacade'\nexport { KeyStorageImpl } from './storage/KeyStorageImpl'\n\nexport const apiHeaders = function (username: string, password: string, forceBasic = false) {\n return {\n Authorization: `Basic ${\n typeof btoa !== 'undefined' ? btoa(`${username}:${password}`) : Buffer.from(`${username}:${password}`).toString('base64')\n }`,\n 'force-authentication': forceBasic ? 'true' : 'false',\n }\n}\n\nexport interface Apis {\n authApi: IccAuthApi\n codeApi: IccCodeXApi\n entityReferenceApi: IccEntityrefApi\n userApi: IccUserXApi\n permissionApi: IccPermissionApi\n healthcarePartyApi: IccHcpartyXApi\n deviceApi: IccDeviceApi\n cryptoApi: IccCryptoXApi\n accessLogApi: IccAccesslogXApi\n agendaApi: IccAgendaApi\n contactApi: IccContactXApi\n formApi: IccFormXApi\n groupApi: IccGroupApi\n invoiceApi: IccInvoiceXApi\n insuranceApi: IccInsuranceApi\n documentApi: IccDocumentXApi\n healthcareElementApi: IccHelementXApi\n classificationApi: IccClassificationXApi\n calendarItemApi: IccCalendarItemXApi\n receiptApi: IccReceiptXApi\n timetableApi: IccTimeTableXApi\n patientApi: IccPatientXApi\n messageApi: IccMessageXApi\n maintenanceTaskApi: IccMaintenanceTaskXApi\n dataOwnerApi: IccDataOwnerXApi\n}\n\nexport const Api = async function (\n host: string,\n username: string,\n password: string,\n crypto: Crypto = typeof window !== 'undefined' ? window.crypto : typeof self !== 'undefined' ? self.crypto : ({} as Crypto),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch,\n forceBasic = false,\n autoLogin = true\n): Promise<Apis> {\n const headers = apiHeaders(username, password, forceBasic)\n const authApi = new IccAuthApi(host, headers, fetchImpl)\n const codeApi = new IccCodeXApi(host, headers, fetchImpl)\n const entityReferenceApi = new IccEntityrefApi(host, headers, fetchImpl)\n const userApi = new IccUserXApi(host, headers, fetchImpl)\n const permissionApi = new IccPermissionApi(host, headers, fetchImpl)\n const healthcarePartyApi = new IccHcpartyXApi(host, headers, fetchImpl)\n const deviceApi = new IccDeviceApi(host, headers, fetchImpl)\n const cryptoApi = new IccCryptoXApi(host, headers, healthcarePartyApi, new IccPatientApi(host, headers, fetchImpl), deviceApi, crypto)\n const dataOwnerApi = new IccDataOwnerXApi(cryptoApi, new IccPatientApi(host, headers, fetchImpl))\n const accessLogApi = new IccAccesslogXApi(host, headers, cryptoApi, dataOwnerApi, fetchImpl)\n const agendaApi = new IccAgendaApi(host, headers, fetchImpl)\n const contactApi = new IccContactXApi(host, headers, cryptoApi, dataOwnerApi, fetchImpl)\n const formApi = new IccFormXApi(host, headers, cryptoApi, dataOwnerApi, fetchImpl)\n const groupApi = new IccGroupApi(host, headers)\n const invoiceApi = new IccInvoiceXApi(host, headers, cryptoApi, entityReferenceApi, dataOwnerApi, fetchImpl)\n const insuranceApi = new IccInsuranceApi(host, headers, fetchImpl)\n const documentApi = new IccDocumentXApi(host, headers, cryptoApi, authApi, dataOwnerApi, fetchImpl)\n const healthcareElementApi = new IccHelementXApi(host, headers, cryptoApi, dataOwnerApi, ['descr', 'note'], fetchImpl)\n const classificationApi = new IccClassificationXApi(host, headers, cryptoApi, dataOwnerApi, fetchImpl)\n const calendarItemApi = new IccCalendarItemXApi(host, headers, cryptoApi, dataOwnerApi, ['details', 'title', 'patientId'], fetchImpl)\n const receiptApi = new IccReceiptXApi(host, headers, cryptoApi, dataOwnerApi, fetchImpl)\n const timetableApi = new IccTimeTableXApi(host, headers, cryptoApi, dataOwnerApi, fetchImpl)\n const patientApi = new IccPatientXApi(\n host,\n headers,\n cryptoApi,\n contactApi,\n formApi,\n healthcareElementApi,\n invoiceApi,\n documentApi,\n healthcarePartyApi,\n classificationApi,\n dataOwnerApi,\n calendarItemApi,\n ['note'],\n fetchImpl\n )\n const messageApi = new IccMessageXApi(host, headers, cryptoApi, dataOwnerApi, fetchImpl)\n const maintenanceTaskApi = new IccMaintenanceTaskXApi(host, headers, cryptoApi, healthcarePartyApi, dataOwnerApi, ['properties'], fetchImpl)\n\n if (autoLogin) {\n if (username != undefined && password != undefined) {\n try {\n await retry(() => authApi.login({ username, password }), 3, 1000, 1.5)\n } catch (e) {\n console.error('Incorrect user and password used to instantiate Api, or network problem', e)\n }\n }\n } else {\n console.info('Auto login skipped')\n }\n\n return {\n cryptoApi,\n authApi,\n codeApi,\n userApi,\n permissionApi,\n patientApi,\n healthcarePartyApi,\n deviceApi,\n accessLogApi,\n contactApi,\n healthcareElementApi,\n documentApi,\n formApi,\n invoiceApi,\n insuranceApi,\n messageApi,\n entityReferenceApi,\n receiptApi,\n agendaApi,\n calendarItemApi,\n classificationApi,\n timetableApi,\n groupApi,\n maintenanceTaskApi,\n dataOwnerApi,\n }\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface KeyStorageFacade {
|
|
2
|
+
/**
|
|
3
|
+
* Returns the publicKey of the provided key from the storage
|
|
4
|
+
* @param key Key of the value to retrieve
|
|
5
|
+
* @return The publicKey associated to the provided key or undefined if not found.
|
|
6
|
+
*/
|
|
7
|
+
getPublicKey(key: string): JsonWebKey | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the privateKey of the provided key from the storage
|
|
10
|
+
* @param key Key of the value to retrieve
|
|
11
|
+
* @return The privateKey associated to the provided key or undefined if not found.
|
|
12
|
+
*/
|
|
13
|
+
getPrivateKey(key: string): JsonWebKey | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Get the keyPair associated to the provided key
|
|
16
|
+
* @param key Key of the value to retrieve
|
|
17
|
+
* @return The keyPair associated to the provided key or undefined if not found.
|
|
18
|
+
*/
|
|
19
|
+
getKeypair(key: string): {
|
|
20
|
+
publicKey: JsonWebKey;
|
|
21
|
+
privateKey: JsonWebKey;
|
|
22
|
+
} | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Delete the keyPair associated to the provided key
|
|
25
|
+
* @param key Key of the value to delete
|
|
26
|
+
*/
|
|
27
|
+
deleteKeypair(key: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Stores the given keyPair under the given key in the storage.
|
|
30
|
+
* @param key The id of the entry in storage
|
|
31
|
+
* @param keyPair should be JWK
|
|
32
|
+
*/
|
|
33
|
+
storeKeyPair(key: string, keyPair: {
|
|
34
|
+
publicKey: JsonWebKey;
|
|
35
|
+
privateKey: JsonWebKey;
|
|
36
|
+
}): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyStorageFacade.js","sourceRoot":"","sources":["../../../icc-x-api/storage/KeyStorageFacade.ts"],"names":[],"mappings":"","sourcesContent":["export interface KeyStorageFacade {\n /**\n * Returns the publicKey of the provided key from the storage\n * @param key Key of the value to retrieve\n * @return The publicKey associated to the provided key or undefined if not found.\n */\n getPublicKey(key: string): JsonWebKey | undefined\n\n /**\n * Returns the privateKey of the provided key from the storage\n * @param key Key of the value to retrieve\n * @return The privateKey associated to the provided key or undefined if not found.\n */\n getPrivateKey(key: string): JsonWebKey | undefined\n\n /**\n * Get the keyPair associated to the provided key\n * @param key Key of the value to retrieve\n * @return The keyPair associated to the provided key or undefined if not found.\n */\n getKeypair(key: string): { publicKey: JsonWebKey; privateKey: JsonWebKey } | undefined\n\n /**\n * Delete the keyPair associated to the provided key\n * @param key Key of the value to delete\n */\n deleteKeypair(key: string): void\n\n /**\n * Stores the given keyPair under the given key in the storage.\n * @param key The id of the entry in storage\n * @param keyPair should be JWK\n */\n storeKeyPair(key: string, keyPair: { publicKey: JsonWebKey; privateKey: JsonWebKey }): void\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StorageFacade } from './StorageFacade';
|
|
2
|
+
import { KeyStorageFacade } from './KeyStorageFacade';
|
|
3
|
+
export declare class KeyStorageImpl implements KeyStorageFacade {
|
|
4
|
+
private readonly _storage;
|
|
5
|
+
constructor(storage: StorageFacade<string>);
|
|
6
|
+
deleteKeypair(key: string): void;
|
|
7
|
+
getKeypair(key: string): {
|
|
8
|
+
publicKey: JsonWebKey;
|
|
9
|
+
privateKey: JsonWebKey;
|
|
10
|
+
} | undefined;
|
|
11
|
+
getPrivateKey(key: string): JsonWebKey | undefined;
|
|
12
|
+
getPublicKey(key: string): JsonWebKey | undefined;
|
|
13
|
+
storeKeyPair(key: string, keyPair: {
|
|
14
|
+
publicKey: JsonWebKey;
|
|
15
|
+
privateKey: JsonWebKey;
|
|
16
|
+
}): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KeyStorageImpl = void 0;
|
|
4
|
+
class KeyStorageImpl {
|
|
5
|
+
constructor(storage) {
|
|
6
|
+
this._storage = storage;
|
|
7
|
+
}
|
|
8
|
+
deleteKeypair(key) {
|
|
9
|
+
return this._storage.deleteItem(key);
|
|
10
|
+
}
|
|
11
|
+
getKeypair(key) {
|
|
12
|
+
var _a;
|
|
13
|
+
const keyPair = JSON.parse((_a = this._storage.getItem(key)) !== null && _a !== void 0 ? _a : '');
|
|
14
|
+
return keyPair.hasOwnProperty('publicKey') && keyPair.hasOwnProperty('privateKey')
|
|
15
|
+
? {
|
|
16
|
+
publicKey: keyPair.publicKey,
|
|
17
|
+
privateKey: keyPair.privateKey,
|
|
18
|
+
}
|
|
19
|
+
: undefined;
|
|
20
|
+
}
|
|
21
|
+
getPrivateKey(key) {
|
|
22
|
+
var _a;
|
|
23
|
+
return (_a = this.getKeypair(key)) === null || _a === void 0 ? void 0 : _a.privateKey;
|
|
24
|
+
}
|
|
25
|
+
getPublicKey(key) {
|
|
26
|
+
var _a;
|
|
27
|
+
return (_a = this.getKeypair(key)) === null || _a === void 0 ? void 0 : _a.publicKey;
|
|
28
|
+
}
|
|
29
|
+
storeKeyPair(key, keyPair) {
|
|
30
|
+
return this._storage.setItem(key, JSON.stringify(keyPair));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.KeyStorageImpl = KeyStorageImpl;
|
|
34
|
+
//# sourceMappingURL=KeyStorageImpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyStorageImpl.js","sourceRoot":"","sources":["../../../icc-x-api/storage/KeyStorageImpl.ts"],"names":[],"mappings":";;;AAIA,MAAa,cAAc;IAGzB,YAAY,OAA8B;QACxC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;IACzB,CAAC;IAED,aAAa,CAAC,GAAW;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IACtC,CAAC;IAED,UAAU,CAAC,GAAW;;QACpB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC,CAAA;QAC5D,OAAO,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC;YAChF,CAAC,CAAC;gBACE,SAAS,EAAE,OAAO,CAAC,SAAuB;gBAC1C,UAAU,EAAE,OAAO,CAAC,UAAwB;aAC7C;YACH,CAAC,CAAC,SAAS,CAAA;IACf,CAAC;IAED,aAAa,CAAC,GAAW;;QACvB,OAAO,MAAA,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,0CAAE,UAAU,CAAA;IACzC,CAAC;IAED,YAAY,CAAC,GAAW;;QACtB,OAAO,MAAA,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,0CAAE,SAAS,CAAA;IACxC,CAAC;IAED,YAAY,CAAC,GAAW,EAAE,OAA0D;QAClF,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IAC5D,CAAC;CACF;AAhCD,wCAgCC","sourcesContent":["import { StorageFacade } from './StorageFacade'\nimport { KeyStorageFacade } from './KeyStorageFacade'\nimport { b2a } from '../../icc-api/model/ModelHelper'\n\nexport class KeyStorageImpl implements KeyStorageFacade {\n private readonly _storage: StorageFacade<string>\n\n constructor(storage: StorageFacade<string>) {\n this._storage = storage\n }\n\n deleteKeypair(key: string): void {\n return this._storage.deleteItem(key)\n }\n\n getKeypair(key: string): { publicKey: JsonWebKey; privateKey: JsonWebKey } | undefined {\n const keyPair = JSON.parse(this._storage.getItem(key) ?? '')\n return keyPair.hasOwnProperty('publicKey') && keyPair.hasOwnProperty('privateKey')\n ? {\n publicKey: keyPair.publicKey as JsonWebKey,\n privateKey: keyPair.privateKey as JsonWebKey,\n }\n : undefined\n }\n\n getPrivateKey(key: string): JsonWebKey | undefined {\n return this.getKeypair(key)?.privateKey\n }\n\n getPublicKey(key: string): JsonWebKey | undefined {\n return this.getKeypair(key)?.publicKey\n }\n\n storeKeyPair(key: string, keyPair: { publicKey: JsonWebKey; privateKey: JsonWebKey }): void {\n return this._storage.setItem(key, JSON.stringify(keyPair))\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StorageFacade } from './StorageFacade';
|
|
2
|
+
export declare class LocalStorageImpl implements StorageFacade<string> {
|
|
3
|
+
getItem(key: string): string | undefined;
|
|
4
|
+
deleteItem(key: string): void;
|
|
5
|
+
setItem(key: string, valueToStore: string): void;
|
|
6
|
+
storeKeyPair(key: string, keyPair: {
|
|
7
|
+
publicKey: any;
|
|
8
|
+
privateKey: any;
|
|
9
|
+
}): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalStorageImpl = void 0;
|
|
4
|
+
class LocalStorageImpl {
|
|
5
|
+
getItem(key) {
|
|
6
|
+
var _a;
|
|
7
|
+
return (_a = localStorage.getItem(key)) !== null && _a !== void 0 ? _a : undefined;
|
|
8
|
+
}
|
|
9
|
+
deleteItem(key) {
|
|
10
|
+
return localStorage.removeItem(key);
|
|
11
|
+
}
|
|
12
|
+
setItem(key, valueToStore) {
|
|
13
|
+
return localStorage.setItem(key, valueToStore);
|
|
14
|
+
}
|
|
15
|
+
storeKeyPair(key, keyPair) {
|
|
16
|
+
if (typeof Storage === 'undefined') {
|
|
17
|
+
console.error('Your browser does not support HTML5 Browser Local Storage !');
|
|
18
|
+
throw 'Your browser does not support HTML5 Browser Local Storage !';
|
|
19
|
+
}
|
|
20
|
+
//TODO: encryption
|
|
21
|
+
this.setItem(key, JSON.stringify(keyPair));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.LocalStorageImpl = LocalStorageImpl;
|
|
25
|
+
//# sourceMappingURL=LocalStorageImpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalStorageImpl.js","sourceRoot":"","sources":["../../../icc-x-api/storage/LocalStorageImpl.ts"],"names":[],"mappings":";;;AAEA,MAAa,gBAAgB;IAC3B,OAAO,CAAC,GAAW;;QACjB,OAAO,MAAA,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAI,SAAS,CAAA;IAC/C,CAAC;IAED,UAAU,CAAC,GAAW;QACpB,OAAO,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IACrC,CAAC;IAED,OAAO,CAAC,GAAW,EAAE,YAAoB;QACvC,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;IAChD,CAAC;IAED,YAAY,CAAC,GAAW,EAAE,OAA4C;QACpE,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;YAClC,OAAO,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAA;YAC5E,MAAM,6DAA6D,CAAA;SACpE;QACD,kBAAkB;QAClB,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IAC5C,CAAC;CACF;AArBD,4CAqBC","sourcesContent":["import { StorageFacade } from './StorageFacade'\n\nexport class LocalStorageImpl implements StorageFacade<string> {\n getItem(key: string): string | undefined {\n return localStorage.getItem(key) ?? undefined\n }\n\n deleteItem(key: string): void {\n return localStorage.removeItem(key)\n }\n\n setItem(key: string, valueToStore: string): void {\n return localStorage.setItem(key, valueToStore)\n }\n\n storeKeyPair(key: string, keyPair: { publicKey: any; privateKey: any }): void {\n if (typeof Storage === 'undefined') {\n console.error('Your browser does not support HTML5 Browser Local Storage !')\n throw 'Your browser does not support HTML5 Browser Local Storage !'\n }\n //TODO: encryption\n this.setItem(key, JSON.stringify(keyPair))\n }\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface StorageFacade<T> {
|
|
2
|
+
/**
|
|
3
|
+
* Returns the value of the provided key from the storage
|
|
4
|
+
* @param key Key of the value to retrieve
|
|
5
|
+
* @return The value associated to the provided key or null if not found.
|
|
6
|
+
*/
|
|
7
|
+
getItem(key: string): T | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Set an item in the storage for the given key
|
|
10
|
+
* @param key Key of the value to set
|
|
11
|
+
* @param valueToStore
|
|
12
|
+
*/
|
|
13
|
+
setItem(key: string, valueToStore: T): void;
|
|
14
|
+
/**
|
|
15
|
+
* Removes the item with the given key from the storage.
|
|
16
|
+
* @param key The key of the item to remove.
|
|
17
|
+
*/
|
|
18
|
+
deleteItem(key: string): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageFacade.js","sourceRoot":"","sources":["../../../icc-x-api/storage/StorageFacade.ts"],"names":[],"mappings":"","sourcesContent":["export interface StorageFacade<T> {\n /**\n * Returns the value of the provided key from the storage\n * @param key Key of the value to retrieve\n * @return The value associated to the provided key or null if not found.\n */\n getItem(key: string): T | undefined\n\n /**\n * Set an item in the storage for the given key\n * @param key Key of the value to set\n * @param valueToStore\n */\n setItem(key: string, valueToStore: T): void\n\n /**\n * Removes the item with the given key from the storage.\n * @param key The key of the item to remove.\n */\n deleteItem(key: string): void\n}\n"]}
|