@icure/api 6.0.1 → 6.0.3
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-api/api/IccAccesslogApi.d.ts +3 -1
- package/icc-api/api/IccAccesslogApi.js +9 -8
- package/icc-api/api/IccAccesslogApi.js.map +1 -1
- package/icc-api/api/IccAgendaApi.d.ts +3 -1
- package/icc-api/api/IccAgendaApi.js +9 -8
- package/icc-api/api/IccAgendaApi.js.map +1 -1
- package/icc-api/api/IccAnonymousAccessApi.d.ts +3 -1
- package/icc-api/api/IccAnonymousAccessApi.js +5 -4
- package/icc-api/api/IccAnonymousAccessApi.js.map +1 -1
- package/icc-api/api/IccApplicationsettingsApi.d.ts +3 -1
- package/icc-api/api/IccApplicationsettingsApi.js +5 -4
- package/icc-api/api/IccApplicationsettingsApi.js.map +1 -1
- package/icc-api/api/IccArticleApi.d.ts +3 -1
- package/icc-api/api/IccArticleApi.js +7 -6
- package/icc-api/api/IccArticleApi.js.map +1 -1
- package/icc-api/api/IccAuthApi.d.ts +10 -0
- package/icc-api/api/IccAuthApi.js +25 -1
- package/icc-api/api/IccAuthApi.js.map +1 -1
- package/icc-api/api/IccBeefactApi.d.ts +3 -1
- package/icc-api/api/IccBeefactApi.js +3 -2
- package/icc-api/api/IccBeefactApi.js.map +1 -1
- package/icc-api/api/IccBekmehrApi.d.ts +3 -1
- package/icc-api/api/IccBekmehrApi.js +29 -28
- package/icc-api/api/IccBekmehrApi.js.map +1 -1
- package/icc-api/api/IccBemikronoApi.d.ts +3 -1
- package/icc-api/api/IccBemikronoApi.js +10 -9
- package/icc-api/api/IccBemikronoApi.js.map +1 -1
- package/icc-api/api/IccBeresultexportApi.d.ts +3 -1
- package/icc-api/api/IccBeresultexportApi.js +5 -4
- package/icc-api/api/IccBeresultexportApi.js.map +1 -1
- package/icc-api/api/IccBeresultimportApi.d.ts +3 -1
- package/icc-api/api/IccBeresultimportApi.js +5 -4
- package/icc-api/api/IccBeresultimportApi.js.map +1 -1
- package/icc-api/api/IccBesamv2Api.d.ts +3 -1
- package/icc-api/api/IccBesamv2Api.js +35 -34
- package/icc-api/api/IccBesamv2Api.js.map +1 -1
- package/icc-api/api/IccCalendarItemApi.d.ts +3 -1
- package/icc-api/api/IccCalendarItemApi.js +14 -13
- package/icc-api/api/IccCalendarItemApi.js.map +1 -1
- package/icc-api/api/IccCalendarItemTypeApi.d.ts +3 -1
- package/icc-api/api/IccCalendarItemTypeApi.js +8 -7
- package/icc-api/api/IccCalendarItemTypeApi.js.map +1 -1
- package/icc-api/api/IccClassificationApi.d.ts +3 -1
- package/icc-api/api/IccClassificationApi.js +10 -9
- package/icc-api/api/IccClassificationApi.js.map +1 -1
- package/icc-api/api/IccClassificationTemplateApi.d.ts +3 -1
- package/icc-api/api/IccClassificationTemplateApi.js +10 -9
- package/icc-api/api/IccClassificationTemplateApi.js.map +1 -1
- package/icc-api/api/IccCodeApi.d.ts +3 -1
- package/icc-api/api/IccCodeApi.js +18 -17
- package/icc-api/api/IccCodeApi.js.map +1 -1
- package/icc-api/api/IccContactApi.d.ts +3 -2
- package/icc-api/api/IccContactApi.js +30 -32
- package/icc-api/api/IccContactApi.js.map +1 -1
- package/icc-api/api/IccDeviceApi.d.ts +3 -1
- package/icc-api/api/IccDeviceApi.js +20 -19
- package/icc-api/api/IccDeviceApi.js.map +1 -1
- package/icc-api/api/IccDoctemplateApi.d.ts +3 -1
- package/icc-api/api/IccDoctemplateApi.js +15 -14
- package/icc-api/api/IccDoctemplateApi.js.map +1 -1
- package/icc-api/api/IccDocumentApi.d.ts +3 -1
- package/icc-api/api/IccDocumentApi.js +22 -21
- package/icc-api/api/IccDocumentApi.js.map +1 -1
- package/icc-api/api/IccDocumentTemplateApi.d.ts +3 -1
- package/icc-api/api/IccDocumentTemplateApi.js +15 -14
- package/icc-api/api/IccDocumentTemplateApi.js.map +1 -1
- package/icc-api/api/IccEntityrefApi.d.ts +3 -1
- package/icc-api/api/IccEntityrefApi.js +4 -3
- package/icc-api/api/IccEntityrefApi.js.map +1 -1
- package/icc-api/api/IccEntitytemplateApi.d.ts +3 -1
- package/icc-api/api/IccEntitytemplateApi.js +13 -12
- package/icc-api/api/IccEntitytemplateApi.js.map +1 -1
- package/icc-api/api/IccFormApi.d.ts +3 -1
- package/icc-api/api/IccFormApi.js +26 -25
- package/icc-api/api/IccFormApi.js.map +1 -1
- package/icc-api/api/IccFrontendmigrationApi.d.ts +3 -1
- package/icc-api/api/IccFrontendmigrationApi.js +8 -7
- package/icc-api/api/IccFrontendmigrationApi.js.map +1 -1
- package/icc-api/api/IccGroupApi.d.ts +3 -1
- package/icc-api/api/IccGroupApi.js +18 -17
- package/icc-api/api/IccGroupApi.js.map +1 -1
- package/icc-api/api/IccHcpartyApi.d.ts +3 -1
- package/icc-api/api/IccHcpartyApi.js +24 -23
- package/icc-api/api/IccHcpartyApi.js.map +1 -1
- package/icc-api/api/IccHelementApi.d.ts +3 -1
- package/icc-api/api/IccHelementApi.js +15 -14
- package/icc-api/api/IccHelementApi.js.map +1 -1
- package/icc-api/api/IccIcureApi.d.ts +3 -1
- package/icc-api/api/IccIcureApi.js +18 -17
- package/icc-api/api/IccIcureApi.js.map +1 -1
- package/icc-api/api/IccInsuranceApi.d.ts +3 -1
- package/icc-api/api/IccInsuranceApi.js +9 -8
- package/icc-api/api/IccInsuranceApi.js.map +1 -1
- package/icc-api/api/IccInvoiceApi.d.ts +3 -1
- package/icc-api/api/IccInvoiceApi.js +33 -32
- package/icc-api/api/IccInvoiceApi.js.map +1 -1
- package/icc-api/api/IccKeywordApi.d.ts +3 -1
- package/icc-api/api/IccKeywordApi.js +8 -7
- package/icc-api/api/IccKeywordApi.js.map +1 -1
- package/icc-api/api/IccMaintenanceTaskApi.d.ts +3 -1
- package/icc-api/api/IccMaintenanceTaskApi.js +7 -6
- package/icc-api/api/IccMaintenanceTaskApi.js.map +1 -1
- package/icc-api/api/IccMedexApi.d.ts +3 -1
- package/icc-api/api/IccMedexApi.js +3 -2
- package/icc-api/api/IccMedexApi.js.map +1 -1
- package/icc-api/api/IccMedicallocationApi.d.ts +3 -1
- package/icc-api/api/IccMedicallocationApi.js +7 -6
- package/icc-api/api/IccMedicallocationApi.js.map +1 -1
- package/icc-api/api/IccMessageApi.d.ts +3 -1
- package/icc-api/api/IccMessageApi.js +21 -20
- package/icc-api/api/IccMessageApi.js.map +1 -1
- package/icc-api/api/IccPatientApi.d.ts +3 -1
- package/icc-api/api/IccPatientApi.js +36 -35
- package/icc-api/api/IccPatientApi.js.map +1 -1
- package/icc-api/api/IccPermissionApi.d.ts +3 -1
- package/icc-api/api/IccPermissionApi.js +3 -2
- package/icc-api/api/IccPermissionApi.js.map +1 -1
- package/icc-api/api/IccPlaceApi.d.ts +3 -1
- package/icc-api/api/IccPlaceApi.js +7 -6
- package/icc-api/api/IccPlaceApi.js.map +1 -1
- package/icc-api/api/IccPubsubApi.d.ts +3 -1
- package/icc-api/api/IccPubsubApi.js +6 -5
- package/icc-api/api/IccPubsubApi.js.map +1 -1
- package/icc-api/api/IccReceiptApi.d.ts +3 -1
- package/icc-api/api/IccReceiptApi.js +9 -8
- package/icc-api/api/IccReceiptApi.js.map +1 -1
- package/icc-api/api/IccReplicationApi.d.ts +3 -1
- package/icc-api/api/IccReplicationApi.js +6 -5
- package/icc-api/api/IccReplicationApi.js.map +1 -1
- package/icc-api/api/IccTarificationApi.d.ts +3 -1
- package/icc-api/api/IccTarificationApi.js +10 -9
- package/icc-api/api/IccTarificationApi.js.map +1 -1
- package/icc-api/api/IccTimeTableApi.d.ts +3 -1
- package/icc-api/api/IccTimeTableApi.js +8 -7
- package/icc-api/api/IccTimeTableApi.js.map +1 -1
- package/icc-api/api/IccTmpApi.d.ts +3 -1
- package/icc-api/api/IccTmpApi.js +73 -72
- package/icc-api/api/IccTmpApi.js.map +1 -1
- package/icc-api/api/IccUserApi.d.ts +3 -1
- package/icc-api/api/IccUserApi.js +28 -27
- package/icc-api/api/IccUserApi.js.map +1 -1
- package/icc-api/api/XHR.d.ts +2 -1
- package/icc-api/api/XHR.js +45 -59
- package/icc-api/api/XHR.js.map +1 -1
- package/icc-api/model/AuthenticationResponse.d.ts +2 -0
- package/icc-api/model/AuthenticationResponse.js.map +1 -1
- package/icc-api/model/Group.d.ts +6 -0
- package/icc-api/model/Group.js.map +1 -1
- package/icc-api/model/RefreshTokenExpiredError.d.ts +3 -0
- package/icc-api/model/RefreshTokenExpiredError.js +10 -0
- package/icc-api/model/RefreshTokenExpiredError.js.map +1 -0
- package/icc-api/model/RegistrationInformation.d.ts +1 -0
- package/icc-api/model/RegistrationInformation.js.map +1 -1
- package/icc-api/model/TimeTableItem.d.ts +2 -1
- package/icc-api/model/TimeTableItem.js.map +1 -1
- package/icc-x-api/auth/AuthService.d.ts +16 -0
- package/icc-x-api/auth/AuthService.js +3 -0
- package/icc-x-api/auth/AuthService.js.map +1 -0
- package/icc-x-api/auth/AuthenticationProvider.d.ts +22 -0
- package/icc-x-api/auth/AuthenticationProvider.js +41 -0
- package/icc-x-api/auth/AuthenticationProvider.js.map +1 -0
- package/icc-x-api/auth/BasicAuthService.d.ts +12 -0
- package/icc-x-api/auth/BasicAuthService.js +27 -0
- package/icc-x-api/auth/BasicAuthService.js.map +1 -0
- package/icc-x-api/auth/EnsembleAuthService.d.ts +17 -0
- package/icc-x-api/auth/EnsembleAuthService.js +60 -0
- package/icc-x-api/auth/EnsembleAuthService.js.map +1 -0
- package/icc-x-api/auth/JwtAuthService.d.ts +19 -0
- package/icc-x-api/auth/JwtAuthService.js +97 -0
- package/icc-x-api/auth/JwtAuthService.js.map +1 -0
- package/icc-x-api/auth/NoAuthService.d.ts +8 -0
- package/icc-x-api/auth/NoAuthService.js +30 -0
- package/icc-x-api/auth/NoAuthService.js.map +1 -0
- package/icc-x-api/icc-accesslog-x-api.d.ts +2 -1
- package/icc-x-api/icc-accesslog-x-api.js +2 -2
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-bekmehr-x-api.d.ts +2 -1
- package/icc-x-api/icc-bekmehr-x-api.js +2 -2
- package/icc-x-api/icc-bekmehr-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.d.ts +2 -1
- package/icc-x-api/icc-calendar-item-x-api.js +2 -2
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-classification-x-api.d.ts +2 -1
- package/icc-x-api/icc-classification-x-api.js +2 -2
- package/icc-x-api/icc-classification-x-api.js.map +1 -1
- package/icc-x-api/icc-code-x-api.d.ts +2 -1
- package/icc-x-api/icc-code-x-api.js +2 -2
- package/icc-x-api/icc-code-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.d.ts +2 -1
- package/icc-x-api/icc-contact-x-api.js +2 -2
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-crypto-x-api.d.ts +1 -1
- package/icc-x-api/icc-crypto-x-api.js +10 -12
- package/icc-x-api/icc-crypto-x-api.js.map +1 -1
- package/icc-x-api/icc-doctemplate-x-api.d.ts +3 -1
- package/icc-x-api/icc-doctemplate-x-api.js +4 -3
- package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.d.ts +3 -1
- package/icc-x-api/icc-document-x-api.js +4 -3
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.d.ts +2 -1
- package/icc-x-api/icc-form-x-api.js +2 -2
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-hcparty-x-api.d.ts +2 -1
- package/icc-x-api/icc-hcparty-x-api.js +2 -2
- package/icc-x-api/icc-hcparty-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.d.ts +2 -1
- package/icc-x-api/icc-helement-x-api.js +2 -2
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-invoice-x-api.d.ts +2 -1
- package/icc-x-api/icc-invoice-x-api.js +2 -2
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.d.ts +2 -1
- package/icc-x-api/icc-maintenance-task-x-api.js +2 -2
- package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
- package/icc-x-api/icc-message-x-api.d.ts +2 -1
- package/icc-x-api/icc-message-x-api.js +2 -2
- package/icc-x-api/icc-message-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.d.ts +2 -1
- package/icc-x-api/icc-patient-x-api.js +2 -2
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.d.ts +2 -1
- package/icc-x-api/icc-receipt-x-api.js +2 -2
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/icc-time-table-x-api.d.ts +2 -1
- package/icc-x-api/icc-time-table-x-api.js +2 -2
- package/icc-x-api/icc-time-table-x-api.js.map +1 -1
- package/icc-x-api/icc-user-x-api.d.ts +2 -1
- package/icc-x-api/icc-user-x-api.js +2 -2
- package/icc-x-api/icc-user-x-api.js.map +1 -1
- package/icc-x-api/index.d.ts +0 -4
- package/icc-x-api/index.js +31 -34
- package/icc-x-api/index.js.map +1 -1
- package/icc-x-api/storage/KeyStorageImpl.js +3 -1
- package/icc-x-api/storage/KeyStorageImpl.js.map +1 -1
- package/icc-x-api/storage/LocalStorageImpl.d.ts +1 -1
- package/icc-x-api/storage/LocalStorageImpl.js +10 -2
- package/icc-x-api/storage/LocalStorageImpl.js.map +1 -1
- package/icc-x-api/storage/StorageFacade.d.ts +1 -1
- package/icc-x-api/storage/StorageFacade.js.map +1 -1
- package/package.json +1 -1
package/icc-api/api/XHR.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XHR.js","sourceRoot":"","sources":["../../../icc-api/api/XHR.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sDAA6C;AAE7C,IAAiB,GAAG,CA6JnB;AA7JD,WAAiB,GAAG;IAClB,MAAa,MAAM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,QAAQ,CAAC,MAAM,EAAE,CAAA;wBAC3F,OAAO,CAAC,IAAI,CAAC,cAAc,KAAK,CAAC,MAAM,MAAM,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;wBAC1E,MAAM,IAAI,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;qBACpF;oBACD,MAAM,EAAE,GAAG,mBAAmB,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,YAAY,CAAA;oBACtF,OAAO,CACL,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC;wBAC/B,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE;wBACjB,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;4BAC5D,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE;4BACjB,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAC3B,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;iBAChD;YACH,CAAC;SAAA,CAAC,CAAA;IACN,CAAC;IA3Fe,eAAW,cA2F1B,CAAA;AACH,CAAC,EA7JgB,GAAG,GAAH,WAAG,KAAH,WAAG,QA6JnB","sourcesContent":["import { ua2b64 } from '../model/ModelHelper'\n\nexport namespace XHR {\n export class Header {\n header: string\n data: string\n\n constructor(header: string, data: string) {\n this.header = header\n this.data = data\n }\n }\n\n export class Data {\n statusCode: number\n contentType: string\n body: JSON | Array<JSON> | any //stream bytes|json|array<json>\n\n constructor(status: number, contentType: string, body: JSON | Array<JSON> | any) {\n this.statusCode = status\n this.contentType = contentType\n this.body = body\n }\n }\n\n export class XHRError extends Error {\n statusCode: number\n errorCode: string\n headers: Headers\n message: string\n url: string\n\n constructor(url: string, message: string, status: number, errorCode: string, headers: Headers) {\n super(message)\n this.url = url\n this.statusCode = status\n this.message = message\n this.errorCode = errorCode\n this.headers = headers\n }\n }\n\n function fetchWithTimeout(\n url: string,\n init: RequestInit,\n timeout = 10000,\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ): Promise<Response> {\n return new Promise((resolve, reject) => {\n // Set timeout timer\n let timer = setTimeout(() => reject({ message: 'Request timed out', status: 'Request timed out' }), timeout)\n fetchImpl(url, init)\n .then((response) => {\n clearTimeout(timer)\n resolve(response)\n })\n .catch((err) => {\n clearTimeout(timer)\n reject(err)\n })\n })\n }\n\n export function sendCommand(\n method: string,\n url: string,\n headers: Array<Header> | null,\n data: string | any = '',\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch,\n contentTypeOverride?: 'application/json' | 'text/plain' | 'application/octet-stream',\n forceAuthentication = false\n ): Promise<Data> {\n const forceSendAuthorization = forceAuthentication || headers?.find((it) => it.header?.toLowerCase() === 'force-authentication')?.data === 'true'\n const contentType = headers && headers.find((it) => (it.header ? it.header.toLowerCase() === 'content-type' : false))\n const clientTimeout = headers && headers.find((it) => (it.header ? it.header.toUpperCase() === 'X-CLIENT-SIDE-TIMEOUT' : false))\n const timeout = clientTimeout ? Number(clientTimeout.data) : 600000\n return fetchWithTimeout(\n url,\n Object.assign(\n {\n method: method,\n credentials: 'include' as RequestCredentials,\n headers: (headers ?? [])\n .filter(\n (h) =>\n (forceSendAuthorization || h.header.toLowerCase() !== 'authorization') &&\n (h.header?.toLowerCase() !== 'content-type' || h.data !== 'multipart/form-data') &&\n h.header?.toUpperCase() !== 'X-CLIENT-SIDE-TIMEOUT' &&\n h.header?.toLowerCase() !== 'force-authentication'\n )\n .reduce(\n (acc: { [key: string]: string }, h) => {\n acc[h.header] = h.data\n return acc\n },\n { 'X-Requested-With': 'XMLHttpRequest' }\n ),\n },\n method === 'POST' || method === 'PUT'\n ? {\n body:\n !contentType || contentType.data === 'application/json'\n ? JSON.stringify(data, (k, v) => {\n return v instanceof ArrayBuffer || v instanceof Uint8Array ? ua2b64(v) : v\n })\n : data,\n }\n : {}\n ),\n timeout,\n fetchImpl\n )\n .catch(async (e) => {\n if (!forceSendAuthorization) {\n //Might be due to a 401\n return {\n status: 401,\n statusText: e.message,\n arrayBuffer: () => Promise.resolve(new ArrayBuffer(0)),\n json: () => Promise.resolve({}),\n text: () => Promise.resolve(''),\n headers: new Headers(),\n }\n } else {\n throw e\n }\n })\n .then(async function (response) {\n if (response.status === 401 && !forceSendAuthorization) {\n return sendCommand(method, url, headers, data, fetchImpl, contentTypeOverride, true)\n } else {\n if (response.status >= 400) {\n const error: {\n error: string\n message: string\n status: number\n } = { error: response.statusText, message: await response.text(), status: response.status }\n console.warn(`XHR Error: ${error.status} - ${error.error}`, error.message)\n throw new XHRError(url, error.message, error.status, error.error, response.headers)\n }\n const ct = contentTypeOverride || response.headers.get('content-type') || 'text/plain'\n return (\n ct.startsWith('application/json')\n ? response.json()\n : ct.startsWith('application/xml') || ct.startsWith('text/')\n ? response.text()\n : response.arrayBuffer()\n ).then((d) => new Data(response.status, ct, d))\n }\n })\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"XHR.js","sourceRoot":"","sources":["../../../icc-api/api/XHR.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sDAA6C;AAC7C,sEAAkE;AAGlE,IAAiB,GAAG,CA6InB;AA7ID,WAAiB,GAAG;IAClB,MAAa,MAAM;QAIjB,YAAY,MAAc,EAAE,IAAY;YACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;YACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAA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,CAAC,WAAW,EAAE,CAC3B,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;qBAChD;gBACH,CAAC;aAAA,CAAC,CAAA;QACJ,CAAC;KAAA;IA3EqB,eAAW,cA2EhC,CAAA;AACH,CAAC,EA7IgB,GAAG,GAAH,WAAG,KAAH,WAAG,QA6InB","sourcesContent":["import { ua2b64 } from '../model/ModelHelper'\nimport { NoAuthService } from '../../icc-x-api/auth/NoAuthService'\nimport { AuthService } from '../../icc-x-api/auth/AuthService'\n\nexport namespace XHR {\n export class Header {\n header: string\n data: string\n\n constructor(header: string, data: string) {\n this.header = header\n this.data = data\n }\n }\n\n export class Data {\n statusCode: number\n contentType: string\n body: JSON | Array<JSON> | any //stream bytes|json|array<json>\n\n constructor(status: number, contentType: string, body: JSON | Array<JSON> | any) {\n this.statusCode = status\n this.contentType = contentType\n this.body = body\n }\n }\n\n export class XHRError extends Error {\n statusCode: number\n errorCode: string\n headers: Headers\n message: string\n url: string\n\n constructor(url: string, message: string, status: number, errorCode: string, headers: Headers) {\n super(message)\n this.url = url\n this.statusCode = status\n this.message = message\n this.errorCode = errorCode\n this.headers = headers\n }\n }\n\n function fetchWithTimeout(\n url: string,\n init: RequestInit,\n timeout = 10000,\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ): Promise<Response> {\n return new Promise((resolve, reject) => {\n // Set timeout timer\n let timer = setTimeout(() => reject({ message: 'Request timed out', status: 'Request timed out' }), timeout)\n fetchImpl(url, init)\n .then((response) => {\n clearTimeout(timer)\n resolve(response)\n })\n .catch((err) => {\n clearTimeout(timer)\n reject(err)\n })\n })\n }\n\n export async function sendCommand(\n method: string,\n url: string,\n headers: Array<Header> | null,\n data: string | any = '',\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch,\n contentTypeOverride?: 'application/json' | 'text/plain' | 'application/octet-stream',\n headerProvider: AuthService = new NoAuthService()\n ): Promise<Data> {\n const authHeaders = await headerProvider.getAuthHeaders()\n const contentType = headers && headers.find((it) => (it.header ? it.header.toLowerCase() === 'content-type' : false))\n const clientTimeout = headers && headers.find((it) => (it.header ? it.header.toUpperCase() === 'X-CLIENT-SIDE-TIMEOUT' : false))\n const timeout = clientTimeout ? Number(clientTimeout.data) : 600000\n return fetchWithTimeout(\n url,\n Object.assign(\n {\n method: method,\n credentials: 'include' as RequestCredentials,\n headers: (headers ?? [])\n .concat(authHeaders)\n .filter(\n (h) =>\n (h.header?.toLowerCase() !== 'content-type' || h.data !== 'multipart/form-data') &&\n h.header?.toUpperCase() !== 'X-CLIENT-SIDE-TIMEOUT' &&\n h.header?.toLowerCase() !== 'force-authentication'\n )\n .reduce(\n (acc: { [key: string]: string }, h) => {\n acc[h.header] = h.data\n return acc\n },\n { 'X-Requested-With': 'XMLHttpRequest' }\n ),\n },\n method === 'POST' || method === 'PUT'\n ? {\n body:\n !contentType || contentType.data === 'application/json'\n ? JSON.stringify(data, (k, v) => {\n return v instanceof ArrayBuffer || v instanceof Uint8Array ? ua2b64(v) : v\n })\n : data,\n }\n : {}\n ),\n timeout,\n fetchImpl\n ).then(async function (response) {\n if (response.status === 401) {\n headerProvider.invalidateHeader(new XHRError(url, await response.text(), response.status, response.statusText, response.headers))\n return sendCommand(method, url, headers, data, fetchImpl, contentTypeOverride, headerProvider)\n } else if (response.status >= 400) {\n const error: {\n error: string\n message: string\n status: number\n } = { error: response.statusText, message: await response.text(), status: response.status }\n console.warn(`XHR Error: ${error.status} - ${error.error}`, error.message)\n throw new XHRError(url, error.message, error.status, error.error, response.headers)\n } else {\n const ct = contentTypeOverride || response.headers.get('content-type') || 'text/plain'\n return (\n ct.startsWith('application/json')\n ? response.json()\n : ct.startsWith('application/xml') || ct.startsWith('text/')\n ? response.text()\n : response.arrayBuffer()\n ).then((d) => new Data(response.status, ct, d))\n }\n })\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthenticationResponse.js","sourceRoot":"","sources":["../../../icc-api/model/AuthenticationResponse.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,MAAa,sBAAsB;IACjC,YAAY,IAAgB;QAC1B,MAAM,CAAC,MAAM,CAAC,IAA8B,EAAE,IAAI,CAAC,CAAA;IACrD,CAAC;
|
|
1
|
+
{"version":3,"file":"AuthenticationResponse.js","sourceRoot":"","sources":["../../../icc-api/model/AuthenticationResponse.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,MAAa,sBAAsB;IACjC,YAAY,IAAgB;QAC1B,MAAM,CAAC,MAAM,CAAC,IAA8B,EAAE,IAAI,CAAC,CAAA;IACrD,CAAC;CAWF;AAdD,wDAcC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\n\nexport class AuthenticationResponse {\n constructor(json: JSON | any) {\n Object.assign(this as AuthenticationResponse, json)\n }\n\n groupId?: string\n userId?: string\n dataOwnerId?: string\n healthcarePartyId?: string\n reason?: string\n successful?: boolean\n username?: string\n token?: string\n refreshToken?: string\n}\n"]}
|
package/icc-api/model/Group.d.ts
CHANGED
|
@@ -52,5 +52,11 @@ export declare class Group {
|
|
|
52
52
|
* Extra properties for the user. Those properties are typed (see class Property)
|
|
53
53
|
*/
|
|
54
54
|
properties?: Array<PropertyStub>;
|
|
55
|
+
/**
|
|
56
|
+
* List of entities that have to be collected from a shared database. Only Code and tarification can be set at this point.
|
|
57
|
+
*/
|
|
58
|
+
sharedEntities?: {
|
|
59
|
+
[key: string]: string;
|
|
60
|
+
};
|
|
55
61
|
superGroup?: string;
|
|
56
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Group.js","sourceRoot":"","sources":["../../../icc-api/model/Group.ts"],"names":[],"mappings":";;;AAcA;;GAEG;AACH,MAAa,KAAK;IAChB,YAAY,IAAgB;QAC1B,MAAM,CAAC,MAAM,CAAC,IAAa,EAAE,IAAI,CAAC,CAAA;IACpC,CAAC;
|
|
1
|
+
{"version":3,"file":"Group.js","sourceRoot":"","sources":["../../../icc-api/model/Group.ts"],"names":[],"mappings":";;;AAcA;;GAEG;AACH,MAAa,KAAK;IAChB,YAAY,IAAgB;QAC1B,MAAM,CAAC,MAAM,CAAC,IAAa,EAAE,IAAI,CAAC,CAAA;IACpC,CAAC;CA2CF;AA9CD,sBA8CC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { CodeStub } from './CodeStub'\nimport { PropertyStub } from './PropertyStub'\n\n/**\n * This entity represents a group\n */\nexport class Group {\n constructor(json: JSON | any) {\n Object.assign(this as Group, json)\n }\n\n /**\n * The id of the group. We encourage using either a v4 UUID or a HL7 Id.\n */\n id?: string\n /**\n * The revision of the group in the database, used for conflict management / optimistic locking.\n */\n rev?: string\n /**\n * hard delete (unix epoch in ms) timestamp of the object. Filled automatically when deletePatient is called.\n */\n deletionDate?: number\n /**\n * A tag is an item from a codification system that qualifies an entity as being member of a certain class, whatever the value it might have taken. If the tag qualifies the content of a field, it means that whatever the content of the field, the tag will always apply. For example, the label of a field is qualified using a tag. LOINC is a codification system typically used for tags.\n */\n tags?: Array<CodeStub>\n /**\n * Username for the group\n */\n name?: string\n /**\n * Password for the group access\n */\n password?: string\n /**\n * List of servers accessible to the group\n */\n servers?: Array<string>\n /**\n * Whether the group has a super admin permission, originally set to no access.\n */\n superAdmin?: boolean\n /**\n * Extra properties for the user. Those properties are typed (see class Property)\n */\n properties?: Array<PropertyStub>\n /**\n * List of entities that have to be collected from a shared database. Only Code and tarification can be set at this point.\n */\n sharedEntities?: { [key: string]: string }\n superGroup?: string\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RefreshTokenExpiredError = void 0;
|
|
4
|
+
class RefreshTokenExpiredError extends Error {
|
|
5
|
+
constructor() {
|
|
6
|
+
super('The refresh JWT expired, you must login again');
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.RefreshTokenExpiredError = RefreshTokenExpiredError;
|
|
10
|
+
//# sourceMappingURL=RefreshTokenExpiredError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RefreshTokenExpiredError.js","sourceRoot":"","sources":["../../../icc-api/model/RefreshTokenExpiredError.ts"],"names":[],"mappings":";;;AAAA,MAAa,wBAAyB,SAAQ,KAAK;IACjD;QACE,KAAK,CAAC,+CAA+C,CAAC,CAAA;IACxD,CAAC;CACF;AAJD,4DAIC","sourcesContent":["export class RefreshTokenExpiredError extends Error {\n constructor() {\n super('The refresh JWT expired, you must login again')\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegistrationInformation.js","sourceRoot":"","sources":["../../../icc-api/model/RegistrationInformation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,MAAa,uBAAuB;IAClC,YAAY,IAAgB;QAC1B,MAAM,CAAC,MAAM,CAAC,IAA+B,EAAE,IAAI,CAAC,CAAA;IACtD,CAAC;
|
|
1
|
+
{"version":3,"file":"RegistrationInformation.js","sourceRoot":"","sources":["../../../icc-api/model/RegistrationInformation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,MAAa,uBAAuB;IAClC,YAAY,IAAgB;QAC1B,MAAM,CAAC,MAAM,CAAC,IAA+B,EAAE,IAAI,CAAC,CAAA;IACtD,CAAC;CAOF;AAVD,0DAUC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\n\nexport class RegistrationInformation {\n constructor(json: JSON | any) {\n Object.assign(this as RegistrationInformation, json)\n }\n\n firstName?: string\n lastName?: string\n emailAddress?: string\n userOptions?: string\n userRoles?: Array<string>\n}\n"]}
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
import { TimeTableHour } from './TimeTableHour';
|
|
13
13
|
export declare class TimeTableItem {
|
|
14
14
|
constructor(json: JSON | any);
|
|
15
|
+
rrule?: string;
|
|
15
16
|
days?: Array<string>;
|
|
16
|
-
hours?: Array<TimeTableHour>;
|
|
17
17
|
recurrenceTypes?: Array<string>;
|
|
18
|
+
hours?: Array<TimeTableHour>;
|
|
18
19
|
calendarItemTypeId?: string;
|
|
19
20
|
homeVisit?: boolean;
|
|
20
21
|
placeId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeTableItem.js","sourceRoot":"","sources":["../../../icc-api/model/TimeTableItem.ts"],"names":[],"mappings":";;;AAaA,MAAa,aAAa;IACxB,YAAY,IAAgB;QAC1B,MAAM,CAAC,MAAM,CAAC,IAAqB,EAAE,IAAI,CAAC,CAAA;IAC5C,CAAC;
|
|
1
|
+
{"version":3,"file":"TimeTableItem.js","sourceRoot":"","sources":["../../../icc-api/model/TimeTableItem.ts"],"names":[],"mappings":";;;AAaA,MAAa,aAAa;IACxB,YAAY,IAAgB;QAC1B,MAAM,CAAC,MAAM,CAAC,IAAqB,EAAE,IAAI,CAAC,CAAA;IAC5C,CAAC;CAYF;AAfD,sCAeC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { TimeTableHour } from './TimeTableHour'\n\nexport class TimeTableItem {\n constructor(json: JSON | any) {\n Object.assign(this as TimeTableItem, json)\n }\n\n rrule?: string\n days?: Array<string>\n recurrenceTypes?: Array<string>\n hours?: Array<TimeTableHour>\n calendarItemTypeId?: string\n homeVisit?: boolean\n placeId?: string\n publicTimeTableItem?: boolean\n acceptsNewPatient?: boolean\n unavailable?: boolean\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { XHR } from '../../icc-api/api/XHR';
|
|
2
|
+
import Header = XHR.Header;
|
|
3
|
+
export interface AuthService {
|
|
4
|
+
/**
|
|
5
|
+
* This method returns the headers needed to authenticate the user.
|
|
6
|
+
* It can throw an error if is not possible to get the headers.
|
|
7
|
+
* @return an array of headers for authentication.
|
|
8
|
+
*/
|
|
9
|
+
getAuthHeaders(): Promise<Array<Header>>;
|
|
10
|
+
/**
|
|
11
|
+
* If the headers are invalidated, you can set the error to throw
|
|
12
|
+
* the next time the headers are requested.
|
|
13
|
+
* @param error the error to throw
|
|
14
|
+
*/
|
|
15
|
+
invalidateHeader(error: Error): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthService.js","sourceRoot":"","sources":["../../../icc-x-api/auth/AuthService.ts"],"names":[],"mappings":"","sourcesContent":["import { XHR } from '../../icc-api/api/XHR'\nimport Header = XHR.Header\n\nexport interface AuthService {\n /**\n * This method returns the headers needed to authenticate the user.\n * It can throw an error if is not possible to get the headers.\n * @return an array of headers for authentication.\n */\n getAuthHeaders(): Promise<Array<Header>>\n\n /**\n * If the headers are invalidated, you can set the error to throw\n * the next time the headers are requested.\n * @param error the error to throw\n */\n invalidateHeader(error: Error): void\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AuthService } from './AuthService';
|
|
2
|
+
import { IccAuthApi } from '../../icc-api';
|
|
3
|
+
export interface AuthenticationProvider {
|
|
4
|
+
getAuthService(): AuthService;
|
|
5
|
+
}
|
|
6
|
+
export declare class EnsembleAuthenticationProvider implements AuthenticationProvider {
|
|
7
|
+
private authApi;
|
|
8
|
+
private username;
|
|
9
|
+
private password;
|
|
10
|
+
private jwtTimeout;
|
|
11
|
+
private readonly basicAuth;
|
|
12
|
+
private jwtAuth;
|
|
13
|
+
private suspensionEnd;
|
|
14
|
+
constructor(authApi: IccAuthApi, username: string, password: string, jwtTimeout?: number);
|
|
15
|
+
getAuthService(): AuthService;
|
|
16
|
+
}
|
|
17
|
+
export declare class BasicAuthenticationProvider implements AuthenticationProvider {
|
|
18
|
+
private username;
|
|
19
|
+
private password;
|
|
20
|
+
constructor(username: string, password: string);
|
|
21
|
+
getAuthService(): AuthService;
|
|
22
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BasicAuthenticationProvider = exports.EnsembleAuthenticationProvider = void 0;
|
|
4
|
+
const EnsembleAuthService_1 = require("./EnsembleAuthService");
|
|
5
|
+
const JwtAuthService_1 = require("./JwtAuthService");
|
|
6
|
+
const NoAuthService_1 = require("./NoAuthService");
|
|
7
|
+
const BasicAuthService_1 = require("./BasicAuthService");
|
|
8
|
+
class EnsembleAuthenticationProvider {
|
|
9
|
+
constructor(authApi, username, password, jwtTimeout = 3600) {
|
|
10
|
+
this.authApi = authApi;
|
|
11
|
+
this.username = username;
|
|
12
|
+
this.password = password;
|
|
13
|
+
this.jwtTimeout = jwtTimeout;
|
|
14
|
+
this.jwtAuth = new JwtAuthService_1.JwtAuthService(this.authApi, this.username, this.password);
|
|
15
|
+
this.basicAuth = new BasicAuthService_1.BasicAuthService(this.username, this.password);
|
|
16
|
+
}
|
|
17
|
+
getAuthService() {
|
|
18
|
+
// If the jwtAuth is in an error state, it instantiates a new one,
|
|
19
|
+
// but it will not use it until the suspension ends
|
|
20
|
+
if (this.jwtAuth.isInErrorState()) {
|
|
21
|
+
console.warn('Error state in JWT, I will skip it');
|
|
22
|
+
this.jwtAuth = new JwtAuthService_1.JwtAuthService(this.authApi, this.username, this.password);
|
|
23
|
+
this.suspensionEnd = new Date(new Date().getTime() + this.jwtTimeout * 1000);
|
|
24
|
+
}
|
|
25
|
+
return !!this.suspensionEnd && new Date() <= this.suspensionEnd
|
|
26
|
+
? new EnsembleAuthService_1.EnsembleAuthService(null, new NoAuthService_1.NoAuthService(), this.basicAuth)
|
|
27
|
+
: new EnsembleAuthService_1.EnsembleAuthService(this.jwtAuth, new NoAuthService_1.NoAuthService(), this.basicAuth);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.EnsembleAuthenticationProvider = EnsembleAuthenticationProvider;
|
|
31
|
+
class BasicAuthenticationProvider {
|
|
32
|
+
constructor(username, password) {
|
|
33
|
+
this.username = username;
|
|
34
|
+
this.password = password;
|
|
35
|
+
}
|
|
36
|
+
getAuthService() {
|
|
37
|
+
return new BasicAuthService_1.BasicAuthService(this.username, this.password);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.BasicAuthenticationProvider = BasicAuthenticationProvider;
|
|
41
|
+
//# sourceMappingURL=AuthenticationProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthenticationProvider.js","sourceRoot":"","sources":["../../../icc-x-api/auth/AuthenticationProvider.ts"],"names":[],"mappings":";;;AAEA,+DAA2D;AAC3D,qDAAiD;AACjD,mDAA+C;AAC/C,yDAAqD;AAMrD,MAAa,8BAA8B;IAKzC,YAAoB,OAAmB,EAAU,QAAgB,EAAU,QAA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QAAQ,CAAQ;QAAU,aAAQ,GAAR,QAAQ,CAAQ;IAAG,CAAC;IAElE,cAAc;QACZ,OAAO,IAAI,mCAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC3D,CAAC;CACF;AAND,kEAMC","sourcesContent":["import { AuthService } from './AuthService'\nimport { IccAuthApi } from '../../icc-api'\nimport { EnsembleAuthService } from './EnsembleAuthService'\nimport { JwtAuthService } from './JwtAuthService'\nimport { NoAuthService } from './NoAuthService'\nimport { BasicAuthService } from './BasicAuthService'\n\nexport interface AuthenticationProvider {\n getAuthService(): AuthService\n}\n\nexport class EnsembleAuthenticationProvider implements AuthenticationProvider {\n private readonly basicAuth: BasicAuthService\n private jwtAuth: JwtAuthService\n private suspensionEnd: Date | undefined\n\n constructor(private authApi: IccAuthApi, private username: string, private password: string, private jwtTimeout: number = 3600) {\n this.jwtAuth = new JwtAuthService(this.authApi, this.username, this.password)\n this.basicAuth = new BasicAuthService(this.username, this.password)\n }\n\n getAuthService(): AuthService {\n // If the jwtAuth is in an error state, it instantiates a new one,\n // but it will not use it until the suspension ends\n if (this.jwtAuth.isInErrorState()) {\n console.warn('Error state in JWT, I will skip it')\n this.jwtAuth = new JwtAuthService(this.authApi, this.username, this.password)\n this.suspensionEnd = new Date(new Date().getTime() + this.jwtTimeout * 1000)\n }\n\n return !!this.suspensionEnd && new Date() <= this.suspensionEnd\n ? new EnsembleAuthService(null, new NoAuthService(), this.basicAuth)\n : new EnsembleAuthService(this.jwtAuth, new NoAuthService(), this.basicAuth)\n }\n}\n\nexport class BasicAuthenticationProvider implements AuthenticationProvider {\n constructor(private username: string, private password: string) {}\n\n getAuthService(): AuthService {\n return new BasicAuthService(this.username, this.password)\n }\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AuthService } from './AuthService';
|
|
2
|
+
import { XHR } from '../../icc-api/api/XHR';
|
|
3
|
+
import Header = XHR.Header;
|
|
4
|
+
export declare class BasicAuthService implements AuthService {
|
|
5
|
+
private username;
|
|
6
|
+
private password;
|
|
7
|
+
private error;
|
|
8
|
+
constructor(username: string, password: string);
|
|
9
|
+
getAuthHeaders(): Promise<Array<Header>>;
|
|
10
|
+
private _base64Encode;
|
|
11
|
+
invalidateHeader(error: Error): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BasicAuthService = void 0;
|
|
4
|
+
const XHR_1 = require("../../icc-api/api/XHR");
|
|
5
|
+
var Header = XHR_1.XHR.Header;
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
class BasicAuthService {
|
|
8
|
+
constructor(username, password) {
|
|
9
|
+
this.username = username;
|
|
10
|
+
this.password = password;
|
|
11
|
+
this.error = null;
|
|
12
|
+
}
|
|
13
|
+
getAuthHeaders() {
|
|
14
|
+
if (!!this.error) {
|
|
15
|
+
throw this.error;
|
|
16
|
+
}
|
|
17
|
+
return Promise.resolve([new Header('Authorization', `Basic ${this._base64Encode(`${this.username}:${this.password}`)}`)]);
|
|
18
|
+
}
|
|
19
|
+
_base64Encode(decodedString) {
|
|
20
|
+
return (0, utils_1.b2a)(decodedString);
|
|
21
|
+
}
|
|
22
|
+
invalidateHeader(error) {
|
|
23
|
+
this.error = error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.BasicAuthService = BasicAuthService;
|
|
27
|
+
//# sourceMappingURL=BasicAuthService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasicAuthService.js","sourceRoot":"","sources":["../../../icc-x-api/auth/BasicAuthService.ts"],"names":[],"mappings":";;;AACA,+CAA2C;AAC3C,IAAO,MAAM,GAAG,SAAG,CAAC,MAAM,CAAA;AAC1B,oCAA8B;AAE9B,MAAa,gBAAgB;IAG3B,YAAoB,QAAgB,EAAU,QAAgB;QAA1C,aAAQ,GAAR,QAAQ,CAAQ;QAAU,aAAQ,GAAR,QAAQ,CAAQ;QAFtD,UAAK,GAAiB,IAAI,CAAA;IAE+B,CAAC;IAElE,cAAc;QACZ,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE;YAChB,MAAM,IAAI,CAAC,KAAK,CAAA;SACjB;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC,eAAe,EAAE,SAAS,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC3H,CAAC;IAEO,aAAa,CAAC,aAAqB;QACzC,OAAO,IAAA,WAAG,EAAC,aAAa,CAAC,CAAA;IAC3B,CAAC;IAED,gBAAgB,CAAC,KAAY;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CACF;AAnBD,4CAmBC","sourcesContent":["import { AuthService } from './AuthService'\nimport { XHR } from '../../icc-api/api/XHR'\nimport Header = XHR.Header\nimport { b2a } from '../utils'\n\nexport class BasicAuthService implements AuthService {\n private error: Error | null = null\n\n constructor(private username: string, private password: string) {}\n\n getAuthHeaders(): Promise<Array<Header>> {\n if (!!this.error) {\n throw this.error\n }\n return Promise.resolve([new Header('Authorization', `Basic ${this._base64Encode(`${this.username}:${this.password}`)}`)])\n }\n\n private _base64Encode(decodedString: string): string {\n return b2a(decodedString)\n }\n\n invalidateHeader(error: Error): void {\n this.error = error\n }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AuthService } from './AuthService';
|
|
2
|
+
import { XHR } from '../../icc-api/api/XHR';
|
|
3
|
+
import { JwtAuthService } from './JwtAuthService';
|
|
4
|
+
import { NoAuthService } from './NoAuthService';
|
|
5
|
+
import { BasicAuthService } from './BasicAuthService';
|
|
6
|
+
import Header = XHR.Header;
|
|
7
|
+
export declare class EnsembleAuthService implements AuthService {
|
|
8
|
+
private readonly jwtAuth;
|
|
9
|
+
private readonly sessionAuth;
|
|
10
|
+
private readonly basicAuth;
|
|
11
|
+
private currentState;
|
|
12
|
+
private error;
|
|
13
|
+
private stateMap;
|
|
14
|
+
constructor(jwtAuth: JwtAuthService | null, sessionAuth: NoAuthService, basicAuth: BasicAuthService);
|
|
15
|
+
getAuthHeaders(): Promise<Array<Header>>;
|
|
16
|
+
invalidateHeader(error: Error): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.EnsembleAuthService = void 0;
|
|
13
|
+
class EnsembleAuthService {
|
|
14
|
+
constructor(jwtAuth, sessionAuth, basicAuth) {
|
|
15
|
+
this.jwtAuth = jwtAuth;
|
|
16
|
+
this.sessionAuth = sessionAuth;
|
|
17
|
+
this.basicAuth = basicAuth;
|
|
18
|
+
this.error = null;
|
|
19
|
+
this.stateMap = {
|
|
20
|
+
start: { state: null, next: 'jwt' },
|
|
21
|
+
jwt: { state: this.jwtAuth, next: 'session' },
|
|
22
|
+
session: { state: this.sessionAuth, next: 'basic' },
|
|
23
|
+
basic: { state: this.basicAuth, next: null },
|
|
24
|
+
};
|
|
25
|
+
this.currentState = 'start';
|
|
26
|
+
}
|
|
27
|
+
getAuthHeaders() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
this.currentState = !!this.currentState ? this.stateMap[this.currentState].next : this.currentState;
|
|
30
|
+
if (!!this.currentState) {
|
|
31
|
+
// If I have a state I return the headers, otherwise I return empty headers
|
|
32
|
+
// And delegate the responsibility of handling the error to the next call
|
|
33
|
+
return !!this.stateMap[this.currentState].state
|
|
34
|
+
? this.stateMap[this.currentState].state.getAuthHeaders().catch((e) => {
|
|
35
|
+
// If I get an error, it is also responsibility of the next call, but I give a warning
|
|
36
|
+
console.warn(e.message);
|
|
37
|
+
this.error = e;
|
|
38
|
+
return [];
|
|
39
|
+
})
|
|
40
|
+
: Promise.resolve([]);
|
|
41
|
+
}
|
|
42
|
+
else if (!!this.error) {
|
|
43
|
+
// If I have no more states, I throw the last error or a default one
|
|
44
|
+
throw this.error;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
throw new Error('Cannot authenticate');
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
invalidateHeader(error) {
|
|
52
|
+
var _a;
|
|
53
|
+
this.error = error;
|
|
54
|
+
if (!!this.currentState) {
|
|
55
|
+
(_a = this.stateMap[this.currentState].state) === null || _a === void 0 ? void 0 : _a.invalidateHeader(error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.EnsembleAuthService = EnsembleAuthService;
|
|
60
|
+
//# sourceMappingURL=EnsembleAuthService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnsembleAuthService.js","sourceRoot":"","sources":["../../../icc-x-api/auth/EnsembleAuthService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAOA,MAAa,mBAAmB;IAK9B,YACmB,OAA8B,EAC9B,WAA0B,EAC1B,SAA2B;QAF3B,YAAO,GAAP,OAAO,CAAuB;QAC9B,gBAAW,GAAX,WAAW,CAAe;QAC1B,cAAS,GAAT,SAAS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AAC,KAAK,EAAE;gBACvB,oEAAoE;gBACpE,MAAM,IAAI,CAAC,KAAK,CAAA;aACjB;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;aACvC;QACH,CAAC;KAAA;IAED,gBAAgB,CAAC,KAAY;;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE;YACvB,MAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,KAAK,0CAAE,gBAAgB,CAAC,KAAK,CAAC,CAAA;SAChE;IACH,CAAC;CACF;AA/CD,kDA+CC","sourcesContent":["import { AuthService } from './AuthService'\nimport { XHR } from '../../icc-api/api/XHR'\nimport { JwtAuthService } from './JwtAuthService'\nimport { NoAuthService } from './NoAuthService'\nimport { BasicAuthService } from './BasicAuthService'\nimport Header = XHR.Header\n\nexport class EnsembleAuthService implements AuthService {\n private currentState: string | null\n private error: Error | null = null\n private stateMap: { [key: string]: { state: AuthService | null; next: string | null } }\n\n constructor(\n private readonly jwtAuth: JwtAuthService | null,\n private readonly sessionAuth: NoAuthService,\n private readonly basicAuth: BasicAuthService\n ) {\n this.stateMap = {\n start: { state: null, next: 'jwt' },\n jwt: { state: this.jwtAuth, next: 'session' },\n session: { state: this.sessionAuth, next: 'basic' },\n basic: { state: this.basicAuth, next: null },\n }\n this.currentState = 'start'\n }\n\n async getAuthHeaders(): Promise<Array<Header>> {\n this.currentState = !!this.currentState ? this.stateMap[this.currentState].next : this.currentState\n\n if (!!this.currentState) {\n // If I have a state I return the headers, otherwise I return empty headers\n // And delegate the responsibility of handling the error to the next call\n return !!this.stateMap[this.currentState].state\n ? this.stateMap[this.currentState].state!.getAuthHeaders().catch((e) => {\n // If I get an error, it is also responsibility of the next call, but I give a warning\n console.warn(e.message)\n this.error = e\n return []\n })\n : Promise.resolve([])\n } else if (!!this.error) {\n // If I have no more states, I throw the last error or a default one\n throw this.error\n } else {\n throw new Error('Cannot authenticate')\n }\n }\n\n invalidateHeader(error: Error): void {\n this.error = error\n if (!!this.currentState) {\n this.stateMap[this.currentState].state?.invalidateHeader(error)\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AuthService } from './AuthService';
|
|
2
|
+
import { XHR } from '../../icc-api/api/XHR';
|
|
3
|
+
import { IccAuthApi } from '../../icc-api';
|
|
4
|
+
import Header = XHR.Header;
|
|
5
|
+
export declare class JwtAuthService implements AuthService {
|
|
6
|
+
private authApi;
|
|
7
|
+
private username;
|
|
8
|
+
private password;
|
|
9
|
+
private _error;
|
|
10
|
+
private _currentPromise;
|
|
11
|
+
constructor(authApi: IccAuthApi, username: string, password: string);
|
|
12
|
+
getAuthHeaders(): Promise<Array<Header>>;
|
|
13
|
+
private _refreshAuthJwt;
|
|
14
|
+
private _loginAndGetTokens;
|
|
15
|
+
private _isJwtExpired;
|
|
16
|
+
private _base64Decode;
|
|
17
|
+
invalidateHeader(error: Error): void;
|
|
18
|
+
isInErrorState(): boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.JwtAuthService = void 0;
|
|
13
|
+
const XHR_1 = require("../../icc-api/api/XHR");
|
|
14
|
+
const LoginCredentials_1 = require("../../icc-api/model/LoginCredentials");
|
|
15
|
+
const utils_1 = require("../utils");
|
|
16
|
+
class JwtAuthService {
|
|
17
|
+
constructor(authApi, username, password) {
|
|
18
|
+
this.authApi = authApi;
|
|
19
|
+
this.username = username;
|
|
20
|
+
this.password = password;
|
|
21
|
+
this._error = null;
|
|
22
|
+
this._currentPromise = Promise.resolve({});
|
|
23
|
+
}
|
|
24
|
+
getAuthHeaders() {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
return this._currentPromise
|
|
27
|
+
.then(({ authJwt, refreshJwt }) => {
|
|
28
|
+
if (!authJwt || this._isJwtExpired(authJwt)) {
|
|
29
|
+
// If it does not have the JWT, tries to get it
|
|
30
|
+
// If the JWT is expired, tries to refresh it
|
|
31
|
+
this._currentPromise = this._refreshAuthJwt(refreshJwt).then((updatedTokens) => {
|
|
32
|
+
// If here the token is null,
|
|
33
|
+
// it goes in a suspension status
|
|
34
|
+
if (!updatedTokens.authJwt) {
|
|
35
|
+
throw new Error('Your iCure back-end version does not support JWT authentication');
|
|
36
|
+
}
|
|
37
|
+
return updatedTokens;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else if (!!this._error) {
|
|
41
|
+
throw this._error;
|
|
42
|
+
}
|
|
43
|
+
return this._currentPromise;
|
|
44
|
+
})
|
|
45
|
+
.then(({ authJwt }) => {
|
|
46
|
+
return [new XHR_1.XHR.Header('Authorization', `Bearer ${authJwt}`)];
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
_refreshAuthJwt(refreshJwt) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
// If I do not have a refresh JWT or the refresh JWT is expired,
|
|
53
|
+
// I have to log in again
|
|
54
|
+
if (!refreshJwt || this._isJwtExpired(refreshJwt)) {
|
|
55
|
+
return this._loginAndGetTokens();
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return this.authApi.refreshAuthenticationJWT(refreshJwt).then((refreshResponse) => ({
|
|
59
|
+
authJwt: refreshResponse.token,
|
|
60
|
+
refreshJwt: refreshJwt,
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
_loginAndGetTokens() {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
return this.authApi
|
|
68
|
+
.login(new LoginCredentials_1.LoginCredentials({
|
|
69
|
+
username: this.username,
|
|
70
|
+
password: this.password,
|
|
71
|
+
}))
|
|
72
|
+
.then((authResponse) => ({
|
|
73
|
+
authJwt: authResponse.token,
|
|
74
|
+
refreshJwt: authResponse.refreshToken,
|
|
75
|
+
}));
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
_isJwtExpired(jwt) {
|
|
79
|
+
const parts = jwt.split('.');
|
|
80
|
+
if (parts.length !== 3) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const payload = this._base64Decode(parts[1]);
|
|
84
|
+
return 'exp' in payload && payload['exp'] > new Date().getTime();
|
|
85
|
+
}
|
|
86
|
+
_base64Decode(encodedString) {
|
|
87
|
+
return JSON.parse((0, utils_1.a2b)(encodedString));
|
|
88
|
+
}
|
|
89
|
+
invalidateHeader(error) {
|
|
90
|
+
this._error = error;
|
|
91
|
+
}
|
|
92
|
+
isInErrorState() {
|
|
93
|
+
return !!this._error;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.JwtAuthService = JwtAuthService;
|
|
97
|
+
//# sourceMappingURL=JwtAuthService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JwtAuthService.js","sourceRoot":"","sources":["../../../icc-x-api/auth/JwtAuthService.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+CAA2C;AAE3C,2EAAuE;AAEvE,oCAA8B;AAE9B,MAAa,cAAc;IAIzB,YAAoB,OAAmB,EAA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CAAC,IAAI,CAAC,MAAM,CAAA;IACtB,CAAC;CACF;AAhFD,wCAgFC","sourcesContent":["import { AuthService } from './AuthService'\nimport { XHR } from '../../icc-api/api/XHR'\nimport { IccAuthApi } from '../../icc-api'\nimport { LoginCredentials } from '../../icc-api/model/LoginCredentials'\nimport Header = XHR.Header\nimport { a2b } from '../utils'\n\nexport class JwtAuthService implements AuthService {\n private _error: Error | null = null\n private _currentPromise: Promise<{ authJwt?: string; refreshJwt?: string }> = Promise.resolve({})\n\n constructor(private authApi: IccAuthApi, private username: string, private password: string) {}\n\n async getAuthHeaders(): Promise<Array<Header>> {\n return this._currentPromise\n .then(({ authJwt, refreshJwt }) => {\n if (!authJwt || this._isJwtExpired(authJwt)) {\n // If it does not have the JWT, tries to get it\n // If the JWT is expired, tries to refresh it\n\n this._currentPromise = this._refreshAuthJwt(refreshJwt).then((updatedTokens) => {\n // If here the token is null,\n // it goes in a suspension status\n if (!updatedTokens.authJwt) {\n throw new Error('Your iCure back-end version does not support JWT authentication')\n }\n\n return updatedTokens\n })\n } else if (!!this._error) {\n throw this._error\n }\n\n return this._currentPromise\n })\n .then(({ authJwt }) => {\n return [new XHR.Header('Authorization', `Bearer ${authJwt}`)]\n })\n }\n\n private async _refreshAuthJwt(refreshJwt: string | undefined): Promise<{ authJwt?: string; refreshJwt?: string }> {\n // If I do not have a refresh JWT or the refresh JWT is expired,\n // I have to log in again\n if (!refreshJwt || this._isJwtExpired(refreshJwt)) {\n return this._loginAndGetTokens()\n } else {\n return this.authApi.refreshAuthenticationJWT(refreshJwt).then((refreshResponse) => ({\n authJwt: refreshResponse.token,\n refreshJwt: refreshJwt,\n }))\n }\n }\n\n private async _loginAndGetTokens(): Promise<{ authJwt?: string; refreshJwt?: string }> {\n return this.authApi\n .login(\n new LoginCredentials({\n username: this.username,\n password: this.password,\n })\n )\n .then((authResponse) => ({\n authJwt: authResponse.token,\n refreshJwt: authResponse.refreshToken,\n }))\n }\n\n private _isJwtExpired(jwt: string): boolean {\n const parts = jwt.split('.')\n if (parts.length !== 3) {\n return false\n }\n const payload = this._base64Decode(parts[1])\n return 'exp' in payload && payload['exp'] > new Date().getTime()\n }\n\n private _base64Decode(encodedString: string): any {\n return JSON.parse(a2b(encodedString))\n }\n\n invalidateHeader(error: Error): void {\n this._error = error\n }\n\n isInErrorState(): boolean {\n return !!this._error\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AuthService } from './AuthService';
|
|
2
|
+
import { XHR } from '../../icc-api/api/XHR';
|
|
3
|
+
import Header = XHR.Header;
|
|
4
|
+
export declare class NoAuthService implements AuthService {
|
|
5
|
+
private error;
|
|
6
|
+
getAuthHeaders(): Promise<Array<Header>>;
|
|
7
|
+
invalidateHeader(error: Error): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.NoAuthService = void 0;
|
|
13
|
+
class NoAuthService {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.error = null;
|
|
16
|
+
}
|
|
17
|
+
getAuthHeaders() {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
if (!!this.error) {
|
|
20
|
+
throw this.error;
|
|
21
|
+
}
|
|
22
|
+
return Promise.resolve([]);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
invalidateHeader(error) {
|
|
26
|
+
this.error = error;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.NoAuthService = NoAuthService;
|
|
30
|
+
//# sourceMappingURL=NoAuthService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoAuthService.js","sourceRoot":"","sources":["../../../icc-x-api/auth/NoAuthService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,MAAa,aAAa;IAA1B;QACU,UAAK,GAAiB,IAAI,CAAA;IAYpC,CAAC;IAVO,cAAc;;YAClB,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE;gBAChB,MAAM,IAAI,CAAC,KAAK,CAAA;aACjB;YACD,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAC5B,CAAC;KAAA;IAED,gBAAgB,CAAC,KAAY;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CACF;AAbD,sCAaC","sourcesContent":["import { AuthService } from './AuthService'\nimport { XHR } from '../../icc-api/api/XHR'\nimport Header = XHR.Header\n\nexport class NoAuthService implements AuthService {\n private error: Error | null = null\n\n async getAuthHeaders(): Promise<Array<Header>> {\n if (!!this.error) {\n throw this.error\n }\n return Promise.resolve([])\n }\n\n invalidateHeader(error: Error): void {\n this.error = error\n }\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import { IccCryptoXApi } from './icc-crypto-x-api';
|
|
|
3
3
|
import * as models from '../icc-api/model/models';
|
|
4
4
|
import { AccessLog, PaginatedListAccessLog } from '../icc-api/model/models';
|
|
5
5
|
import { IccDataOwnerXApi } from './icc-data-owner-x-api';
|
|
6
|
+
import { AuthenticationProvider } from './auth/AuthenticationProvider';
|
|
6
7
|
export interface AccessLogWithPatientId extends AccessLog {
|
|
7
8
|
patientId: string;
|
|
8
9
|
}
|
|
@@ -12,7 +13,7 @@ export declare class IccAccesslogXApi extends IccAccesslogApi {
|
|
|
12
13
|
dataOwnerApi: IccDataOwnerXApi;
|
|
13
14
|
constructor(host: string, headers: {
|
|
14
15
|
[key: string]: string;
|
|
15
|
-
}, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
16
|
+
}, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, authenticationProvider: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
16
17
|
newInstance(user: models.User, patient: models.Patient, h: any): Promise<any>;
|
|
17
18
|
/**
|
|
18
19
|
* 1. Check whether there is a delegation with 'hcpartyId' or not.
|
|
@@ -14,12 +14,12 @@ const icc_api_1 = require("../icc-api");
|
|
|
14
14
|
const _ = require("lodash");
|
|
15
15
|
const utils_1 = require("./utils");
|
|
16
16
|
class IccAccesslogXApi extends icc_api_1.IccAccesslogApi {
|
|
17
|
-
constructor(host, headers, crypto, dataOwnerApi, fetchImpl = typeof window !== 'undefined'
|
|
17
|
+
constructor(host, headers, crypto, dataOwnerApi, authenticationProvider, fetchImpl = typeof window !== 'undefined'
|
|
18
18
|
? window.fetch
|
|
19
19
|
: typeof self !== 'undefined'
|
|
20
20
|
? self.fetch
|
|
21
21
|
: fetch) {
|
|
22
|
-
super(host, headers, fetchImpl);
|
|
22
|
+
super(host, headers, authenticationProvider, fetchImpl);
|
|
23
23
|
this.cryptedKeys = ['detail', 'objectId'];
|
|
24
24
|
this.crypto = crypto;
|
|
25
25
|
this.dataOwnerApi = dataOwnerApi;
|