generio-sdk 1.0.96 → 1.0.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +13 -6
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +10 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -314,6 +314,12 @@ function getGenerioRecognizeExaminationUrl(studyInstanceUId, modality, studyDesc
|
|
|
314
314
|
if (bodyPartExamined) url = url + `&bodyPartExamined=${bodyPartExamined}`;
|
|
315
315
|
return url;
|
|
316
316
|
}
|
|
317
|
+
async function checkAuthenticationCached(origin) {
|
|
318
|
+
const cachedAuth = getAuthFromCache();
|
|
319
|
+
const auth = cachedAuth || await checkAuthentication(origin);
|
|
320
|
+
if (!cachedAuth && auth.isAuthenticated) saveAuthToCache(auth.isAuthenticated, auth.email);
|
|
321
|
+
return auth;
|
|
322
|
+
}
|
|
317
323
|
async function checkAuthentication(origin) {
|
|
318
324
|
try {
|
|
319
325
|
const response = await fetch(`${origin ?? GENERIO_ORIGIN}/api/CookiesAuth/isAuthenticated`, {
|
|
@@ -340,7 +346,7 @@ async function checkAuthentication(origin) {
|
|
|
340
346
|
email: ""
|
|
341
347
|
};
|
|
342
348
|
}
|
|
343
|
-
function
|
|
349
|
+
function getAuthFromCache() {
|
|
344
350
|
try {
|
|
345
351
|
const stored = localStorage.getItem(AUTH_STORAGE_KEY);
|
|
346
352
|
if (stored) return JSON.parse(stored);
|
|
@@ -349,7 +355,7 @@ function getAuthFromStorage() {
|
|
|
349
355
|
}
|
|
350
356
|
return null;
|
|
351
357
|
}
|
|
352
|
-
function
|
|
358
|
+
function saveAuthToCache(isAuthenticated, email) {
|
|
353
359
|
try {
|
|
354
360
|
localStorage.setItem(AUTH_STORAGE_KEY, JSON.stringify({
|
|
355
361
|
isAuthenticated,
|
|
@@ -359,7 +365,7 @@ function saveAuthToStorage(isAuthenticated, email) {
|
|
|
359
365
|
console.error("Error saving auth to localStorage:", e);
|
|
360
366
|
}
|
|
361
367
|
}
|
|
362
|
-
function
|
|
368
|
+
function clearAuthFromCache() {
|
|
363
369
|
try {
|
|
364
370
|
localStorage.removeItem(AUTH_STORAGE_KEY);
|
|
365
371
|
} catch (e) {
|
|
@@ -373,9 +379,10 @@ exports.ExaminationDataHelpers = ExaminationDataHelpers;
|
|
|
373
379
|
exports.FormTypeEnum = FormTypeEnum;
|
|
374
380
|
exports.GENERIO_ORIGIN = GENERIO_ORIGIN;
|
|
375
381
|
exports.checkAuthentication = checkAuthentication;
|
|
376
|
-
exports.
|
|
382
|
+
exports.checkAuthenticationCached = checkAuthenticationCached;
|
|
383
|
+
exports.clearAuthFromCache = clearAuthFromCache;
|
|
377
384
|
exports.getAnnotationPlacements = getAnnotationPlacements;
|
|
378
|
-
exports.
|
|
385
|
+
exports.getAuthFromCache = getAuthFromCache;
|
|
379
386
|
exports.getExaminationMessage = getExaminationMessage;
|
|
380
387
|
exports.getExtParamValueByStudyInstanceUId = getExtParamValueByStudyInstanceUId;
|
|
381
388
|
exports.getGenerioRecognizeExaminationUrl = getGenerioRecognizeExaminationUrl;
|
|
@@ -384,7 +391,7 @@ exports.loadStudy = loadStudy;
|
|
|
384
391
|
exports.login = login;
|
|
385
392
|
exports.logout = logout;
|
|
386
393
|
exports.recognizeExamination = recognizeExamination;
|
|
387
|
-
exports.
|
|
394
|
+
exports.saveAuthToCache = saveAuthToCache;
|
|
388
395
|
exports.sendMeasurements = sendMeasurements;
|
|
389
396
|
exports.setExtParams = setExtParams;
|
|
390
397
|
exports.setExtParamsPostMessage = setExtParamsPostMessage;
|
package/dist/index.d.cts
CHANGED
|
@@ -316,15 +316,19 @@ declare function sendMeasurements(model: SendMeasurementsInputModel, origin?: st
|
|
|
316
316
|
declare function getExaminationMessage(model: GetExaminationMessageInputModel, origin?: string): Promise<GetExaminationMessageOutputModel>;
|
|
317
317
|
declare function setupPostMessageListeners(generioReadyHandler?: (model: GenerioReadyOutputModel, event: MessageEvent) => void, origin?: string): void;
|
|
318
318
|
declare function getGenerioRecognizeExaminationUrl(studyInstanceUId: string, modality: string, studyDescription?: string, bodyPartExamined?: string, origin?: string): string;
|
|
319
|
+
declare function checkAuthenticationCached(origin?: string): Promise<{
|
|
320
|
+
isAuthenticated: boolean;
|
|
321
|
+
email: string;
|
|
322
|
+
}>;
|
|
319
323
|
declare function checkAuthentication(origin?: string): Promise<{
|
|
320
324
|
isAuthenticated: boolean;
|
|
321
325
|
email: string;
|
|
322
326
|
}>;
|
|
323
|
-
declare function
|
|
327
|
+
declare function getAuthFromCache(): {
|
|
324
328
|
isAuthenticated: boolean;
|
|
325
329
|
email: string;
|
|
326
330
|
} | null;
|
|
327
|
-
declare function
|
|
328
|
-
declare function
|
|
331
|
+
declare function saveAuthToCache(isAuthenticated: boolean, email: string): void;
|
|
332
|
+
declare function clearAuthFromCache(): void;
|
|
329
333
|
//#endregion
|
|
330
|
-
export { AUTH_STORAGE_KEY, AnnotationPlacement, type AppendDiagnoseFormHandlebarsModel, type Column, type ElementColumn, type ElementRow, type ElementSubRow, ExaminationDataHelpers, type FindingGeneratorFormHandlebarsModel, FormElementStateInputModel, FormElementStateViewModel, FormTypeEnum, GENERIO_ORIGIN, GenerioReadyOutputModel, GetAnnotationPlacementsInputModel, GetAnnotationPlacementsOutputModel, GetExaminationMessageInputModel, GetExaminationMessageOutputModel, GetExtParamValueByStudyInstanceUIdInputModel, GetExtParamValueByStudyInstanceUIdOutputModel, KeyValueModel, LoadFormDataOutputModel, LoadStudyViewModel, LoginInputModel, LoginOutputModel, LogoutOutputModel, MeasurementModel, type OriginDataItem, type OriginDetail, type OriginElementDetail, RecognizeExaminationInputModel, RecognizeExaminationOutputModel, SendMeasurementsInputModel, SendMeasurementsOutputModel, SetExtParamsInputModel, SetExtParamsOutputModel, UpdateStudyInputModel, UpdateStudyOutputModel, checkAuthentication,
|
|
334
|
+
export { AUTH_STORAGE_KEY, AnnotationPlacement, type AppendDiagnoseFormHandlebarsModel, type Column, type ElementColumn, type ElementRow, type ElementSubRow, ExaminationDataHelpers, type FindingGeneratorFormHandlebarsModel, FormElementStateInputModel, FormElementStateViewModel, FormTypeEnum, GENERIO_ORIGIN, GenerioReadyOutputModel, GetAnnotationPlacementsInputModel, GetAnnotationPlacementsOutputModel, GetExaminationMessageInputModel, GetExaminationMessageOutputModel, GetExtParamValueByStudyInstanceUIdInputModel, GetExtParamValueByStudyInstanceUIdOutputModel, KeyValueModel, LoadFormDataOutputModel, LoadStudyViewModel, LoginInputModel, LoginOutputModel, LogoutOutputModel, MeasurementModel, type OriginDataItem, type OriginDetail, type OriginElementDetail, RecognizeExaminationInputModel, RecognizeExaminationOutputModel, SendMeasurementsInputModel, SendMeasurementsOutputModel, SetExtParamsInputModel, SetExtParamsOutputModel, UpdateStudyInputModel, UpdateStudyOutputModel, checkAuthentication, checkAuthenticationCached, clearAuthFromCache, getAnnotationPlacements, getAuthFromCache, getExaminationMessage, getExtParamValueByStudyInstanceUId, getGenerioRecognizeExaminationUrl, loadFormData, loadStudy, login, logout, recognizeExamination, saveAuthToCache, sendMeasurements, setExtParams, setExtParamsPostMessage, setupPostMessageListeners, updateStudy };
|
package/dist/index.d.ts
CHANGED
|
@@ -316,15 +316,19 @@ declare function sendMeasurements(model: SendMeasurementsInputModel, origin?: st
|
|
|
316
316
|
declare function getExaminationMessage(model: GetExaminationMessageInputModel, origin?: string): Promise<GetExaminationMessageOutputModel>;
|
|
317
317
|
declare function setupPostMessageListeners(generioReadyHandler?: (model: GenerioReadyOutputModel, event: MessageEvent) => void, origin?: string): void;
|
|
318
318
|
declare function getGenerioRecognizeExaminationUrl(studyInstanceUId: string, modality: string, studyDescription?: string, bodyPartExamined?: string, origin?: string): string;
|
|
319
|
+
declare function checkAuthenticationCached(origin?: string): Promise<{
|
|
320
|
+
isAuthenticated: boolean;
|
|
321
|
+
email: string;
|
|
322
|
+
}>;
|
|
319
323
|
declare function checkAuthentication(origin?: string): Promise<{
|
|
320
324
|
isAuthenticated: boolean;
|
|
321
325
|
email: string;
|
|
322
326
|
}>;
|
|
323
|
-
declare function
|
|
327
|
+
declare function getAuthFromCache(): {
|
|
324
328
|
isAuthenticated: boolean;
|
|
325
329
|
email: string;
|
|
326
330
|
} | null;
|
|
327
|
-
declare function
|
|
328
|
-
declare function
|
|
331
|
+
declare function saveAuthToCache(isAuthenticated: boolean, email: string): void;
|
|
332
|
+
declare function clearAuthFromCache(): void;
|
|
329
333
|
//#endregion
|
|
330
|
-
export { AUTH_STORAGE_KEY, AnnotationPlacement, type AppendDiagnoseFormHandlebarsModel, type Column, type ElementColumn, type ElementRow, type ElementSubRow, ExaminationDataHelpers, type FindingGeneratorFormHandlebarsModel, FormElementStateInputModel, FormElementStateViewModel, FormTypeEnum, GENERIO_ORIGIN, GenerioReadyOutputModel, GetAnnotationPlacementsInputModel, GetAnnotationPlacementsOutputModel, GetExaminationMessageInputModel, GetExaminationMessageOutputModel, GetExtParamValueByStudyInstanceUIdInputModel, GetExtParamValueByStudyInstanceUIdOutputModel, KeyValueModel, LoadFormDataOutputModel, LoadStudyViewModel, LoginInputModel, LoginOutputModel, LogoutOutputModel, MeasurementModel, type OriginDataItem, type OriginDetail, type OriginElementDetail, RecognizeExaminationInputModel, RecognizeExaminationOutputModel, SendMeasurementsInputModel, SendMeasurementsOutputModel, SetExtParamsInputModel, SetExtParamsOutputModel, UpdateStudyInputModel, UpdateStudyOutputModel, checkAuthentication,
|
|
334
|
+
export { AUTH_STORAGE_KEY, AnnotationPlacement, type AppendDiagnoseFormHandlebarsModel, type Column, type ElementColumn, type ElementRow, type ElementSubRow, ExaminationDataHelpers, type FindingGeneratorFormHandlebarsModel, FormElementStateInputModel, FormElementStateViewModel, FormTypeEnum, GENERIO_ORIGIN, GenerioReadyOutputModel, GetAnnotationPlacementsInputModel, GetAnnotationPlacementsOutputModel, GetExaminationMessageInputModel, GetExaminationMessageOutputModel, GetExtParamValueByStudyInstanceUIdInputModel, GetExtParamValueByStudyInstanceUIdOutputModel, KeyValueModel, LoadFormDataOutputModel, LoadStudyViewModel, LoginInputModel, LoginOutputModel, LogoutOutputModel, MeasurementModel, type OriginDataItem, type OriginDetail, type OriginElementDetail, RecognizeExaminationInputModel, RecognizeExaminationOutputModel, SendMeasurementsInputModel, SendMeasurementsOutputModel, SetExtParamsInputModel, SetExtParamsOutputModel, UpdateStudyInputModel, UpdateStudyOutputModel, checkAuthentication, checkAuthenticationCached, clearAuthFromCache, getAnnotationPlacements, getAuthFromCache, getExaminationMessage, getExtParamValueByStudyInstanceUId, getGenerioRecognizeExaminationUrl, loadFormData, loadStudy, login, logout, recognizeExamination, saveAuthToCache, sendMeasurements, setExtParams, setExtParamsPostMessage, setupPostMessageListeners, updateStudy };
|
package/dist/index.js
CHANGED
|
@@ -290,6 +290,12 @@ function getGenerioRecognizeExaminationUrl(studyInstanceUId, modality, studyDesc
|
|
|
290
290
|
if (bodyPartExamined) url = url + `&bodyPartExamined=${bodyPartExamined}`;
|
|
291
291
|
return url;
|
|
292
292
|
}
|
|
293
|
+
async function checkAuthenticationCached(origin) {
|
|
294
|
+
const cachedAuth = getAuthFromCache();
|
|
295
|
+
const auth = cachedAuth || await checkAuthentication(origin);
|
|
296
|
+
if (!cachedAuth && auth.isAuthenticated) saveAuthToCache(auth.isAuthenticated, auth.email);
|
|
297
|
+
return auth;
|
|
298
|
+
}
|
|
293
299
|
async function checkAuthentication(origin) {
|
|
294
300
|
try {
|
|
295
301
|
const response = await fetch(`${origin ?? GENERIO_ORIGIN}/api/CookiesAuth/isAuthenticated`, {
|
|
@@ -316,7 +322,7 @@ async function checkAuthentication(origin) {
|
|
|
316
322
|
email: ""
|
|
317
323
|
};
|
|
318
324
|
}
|
|
319
|
-
function
|
|
325
|
+
function getAuthFromCache() {
|
|
320
326
|
try {
|
|
321
327
|
const stored = localStorage.getItem(AUTH_STORAGE_KEY);
|
|
322
328
|
if (stored) return JSON.parse(stored);
|
|
@@ -325,7 +331,7 @@ function getAuthFromStorage() {
|
|
|
325
331
|
}
|
|
326
332
|
return null;
|
|
327
333
|
}
|
|
328
|
-
function
|
|
334
|
+
function saveAuthToCache(isAuthenticated, email) {
|
|
329
335
|
try {
|
|
330
336
|
localStorage.setItem(AUTH_STORAGE_KEY, JSON.stringify({
|
|
331
337
|
isAuthenticated,
|
|
@@ -335,7 +341,7 @@ function saveAuthToStorage(isAuthenticated, email) {
|
|
|
335
341
|
console.error("Error saving auth to localStorage:", e);
|
|
336
342
|
}
|
|
337
343
|
}
|
|
338
|
-
function
|
|
344
|
+
function clearAuthFromCache() {
|
|
339
345
|
try {
|
|
340
346
|
localStorage.removeItem(AUTH_STORAGE_KEY);
|
|
341
347
|
} catch (e) {
|
|
@@ -344,4 +350,4 @@ function clearAuthFromStorage() {
|
|
|
344
350
|
}
|
|
345
351
|
|
|
346
352
|
//#endregion
|
|
347
|
-
export { AUTH_STORAGE_KEY, ExaminationDataHelpers, FormTypeEnum, GENERIO_ORIGIN, checkAuthentication,
|
|
353
|
+
export { AUTH_STORAGE_KEY, ExaminationDataHelpers, FormTypeEnum, GENERIO_ORIGIN, checkAuthentication, checkAuthenticationCached, clearAuthFromCache, getAnnotationPlacements, getAuthFromCache, getExaminationMessage, getExtParamValueByStudyInstanceUId, getGenerioRecognizeExaminationUrl, loadFormData, loadStudy, login, logout, recognizeExamination, saveAuthToCache, sendMeasurements, setExtParams, setExtParamsPostMessage, setupPostMessageListeners, updateStudy };
|