generio-sdk 1.0.95 → 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 +38 -0
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +34 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -169,6 +169,7 @@ var ExaminationDataHelpers = class {
|
|
|
169
169
|
//#endregion
|
|
170
170
|
//#region src/index.ts
|
|
171
171
|
const GENERIO_ORIGIN = "https://gener.io";
|
|
172
|
+
const AUTH_STORAGE_KEY = "generio-auth";
|
|
172
173
|
async function login(model, origin) {
|
|
173
174
|
if ((await fetch((origin ?? GENERIO_ORIGIN) + "/api/cookiesAuth/login", {
|
|
174
175
|
method: "POST",
|
|
@@ -313,6 +314,12 @@ function getGenerioRecognizeExaminationUrl(studyInstanceUId, modality, studyDesc
|
|
|
313
314
|
if (bodyPartExamined) url = url + `&bodyPartExamined=${bodyPartExamined}`;
|
|
314
315
|
return url;
|
|
315
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
|
+
}
|
|
316
323
|
async function checkAuthentication(origin) {
|
|
317
324
|
try {
|
|
318
325
|
const response = await fetch(`${origin ?? GENERIO_ORIGIN}/api/CookiesAuth/isAuthenticated`, {
|
|
@@ -339,13 +346,43 @@ async function checkAuthentication(origin) {
|
|
|
339
346
|
email: ""
|
|
340
347
|
};
|
|
341
348
|
}
|
|
349
|
+
function getAuthFromCache() {
|
|
350
|
+
try {
|
|
351
|
+
const stored = localStorage.getItem(AUTH_STORAGE_KEY);
|
|
352
|
+
if (stored) return JSON.parse(stored);
|
|
353
|
+
} catch (e) {
|
|
354
|
+
console.error("Error reading auth from localStorage:", e);
|
|
355
|
+
}
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
function saveAuthToCache(isAuthenticated, email) {
|
|
359
|
+
try {
|
|
360
|
+
localStorage.setItem(AUTH_STORAGE_KEY, JSON.stringify({
|
|
361
|
+
isAuthenticated,
|
|
362
|
+
email
|
|
363
|
+
}));
|
|
364
|
+
} catch (e) {
|
|
365
|
+
console.error("Error saving auth to localStorage:", e);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
function clearAuthFromCache() {
|
|
369
|
+
try {
|
|
370
|
+
localStorage.removeItem(AUTH_STORAGE_KEY);
|
|
371
|
+
} catch (e) {
|
|
372
|
+
console.error("Error clearing auth from localStorage:", e);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
342
375
|
|
|
343
376
|
//#endregion
|
|
377
|
+
exports.AUTH_STORAGE_KEY = AUTH_STORAGE_KEY;
|
|
344
378
|
exports.ExaminationDataHelpers = ExaminationDataHelpers;
|
|
345
379
|
exports.FormTypeEnum = FormTypeEnum;
|
|
346
380
|
exports.GENERIO_ORIGIN = GENERIO_ORIGIN;
|
|
347
381
|
exports.checkAuthentication = checkAuthentication;
|
|
382
|
+
exports.checkAuthenticationCached = checkAuthenticationCached;
|
|
383
|
+
exports.clearAuthFromCache = clearAuthFromCache;
|
|
348
384
|
exports.getAnnotationPlacements = getAnnotationPlacements;
|
|
385
|
+
exports.getAuthFromCache = getAuthFromCache;
|
|
349
386
|
exports.getExaminationMessage = getExaminationMessage;
|
|
350
387
|
exports.getExtParamValueByStudyInstanceUId = getExtParamValueByStudyInstanceUId;
|
|
351
388
|
exports.getGenerioRecognizeExaminationUrl = getGenerioRecognizeExaminationUrl;
|
|
@@ -354,6 +391,7 @@ exports.loadStudy = loadStudy;
|
|
|
354
391
|
exports.login = login;
|
|
355
392
|
exports.logout = logout;
|
|
356
393
|
exports.recognizeExamination = recognizeExamination;
|
|
394
|
+
exports.saveAuthToCache = saveAuthToCache;
|
|
357
395
|
exports.sendMeasurements = sendMeasurements;
|
|
358
396
|
exports.setExtParams = setExtParams;
|
|
359
397
|
exports.setExtParamsPostMessage = setExtParamsPostMessage;
|
package/dist/index.d.cts
CHANGED
|
@@ -301,6 +301,7 @@ declare class ExaminationDataHelpers {
|
|
|
301
301
|
//#endregion
|
|
302
302
|
//#region src/index.d.ts
|
|
303
303
|
declare const GENERIO_ORIGIN = "https://gener.io";
|
|
304
|
+
declare const AUTH_STORAGE_KEY = "generio-auth";
|
|
304
305
|
declare function login(model: LoginInputModel, origin?: string): Promise<LoginOutputModel>;
|
|
305
306
|
declare function logout(origin?: string): Promise<LogoutOutputModel>;
|
|
306
307
|
declare function recognizeExamination(model: RecognizeExaminationInputModel, origin?: string): Promise<RecognizeExaminationOutputModel>;
|
|
@@ -315,9 +316,19 @@ declare function sendMeasurements(model: SendMeasurementsInputModel, origin?: st
|
|
|
315
316
|
declare function getExaminationMessage(model: GetExaminationMessageInputModel, origin?: string): Promise<GetExaminationMessageOutputModel>;
|
|
316
317
|
declare function setupPostMessageListeners(generioReadyHandler?: (model: GenerioReadyOutputModel, event: MessageEvent) => void, origin?: string): void;
|
|
317
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
|
+
}>;
|
|
318
323
|
declare function checkAuthentication(origin?: string): Promise<{
|
|
319
324
|
isAuthenticated: boolean;
|
|
320
325
|
email: string;
|
|
321
326
|
}>;
|
|
327
|
+
declare function getAuthFromCache(): {
|
|
328
|
+
isAuthenticated: boolean;
|
|
329
|
+
email: string;
|
|
330
|
+
} | null;
|
|
331
|
+
declare function saveAuthToCache(isAuthenticated: boolean, email: string): void;
|
|
332
|
+
declare function clearAuthFromCache(): void;
|
|
322
333
|
//#endregion
|
|
323
|
-
export { 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, getAnnotationPlacements, getExaminationMessage, getExtParamValueByStudyInstanceUId, getGenerioRecognizeExaminationUrl, loadFormData, loadStudy, login, logout, recognizeExamination, sendMeasurements, setExtParams, setExtParamsPostMessage, setupPostMessageListeners, updateStudy };
|
|
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
|
@@ -301,6 +301,7 @@ declare class ExaminationDataHelpers {
|
|
|
301
301
|
//#endregion
|
|
302
302
|
//#region src/index.d.ts
|
|
303
303
|
declare const GENERIO_ORIGIN = "https://gener.io";
|
|
304
|
+
declare const AUTH_STORAGE_KEY = "generio-auth";
|
|
304
305
|
declare function login(model: LoginInputModel, origin?: string): Promise<LoginOutputModel>;
|
|
305
306
|
declare function logout(origin?: string): Promise<LogoutOutputModel>;
|
|
306
307
|
declare function recognizeExamination(model: RecognizeExaminationInputModel, origin?: string): Promise<RecognizeExaminationOutputModel>;
|
|
@@ -315,9 +316,19 @@ declare function sendMeasurements(model: SendMeasurementsInputModel, origin?: st
|
|
|
315
316
|
declare function getExaminationMessage(model: GetExaminationMessageInputModel, origin?: string): Promise<GetExaminationMessageOutputModel>;
|
|
316
317
|
declare function setupPostMessageListeners(generioReadyHandler?: (model: GenerioReadyOutputModel, event: MessageEvent) => void, origin?: string): void;
|
|
317
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
|
+
}>;
|
|
318
323
|
declare function checkAuthentication(origin?: string): Promise<{
|
|
319
324
|
isAuthenticated: boolean;
|
|
320
325
|
email: string;
|
|
321
326
|
}>;
|
|
327
|
+
declare function getAuthFromCache(): {
|
|
328
|
+
isAuthenticated: boolean;
|
|
329
|
+
email: string;
|
|
330
|
+
} | null;
|
|
331
|
+
declare function saveAuthToCache(isAuthenticated: boolean, email: string): void;
|
|
332
|
+
declare function clearAuthFromCache(): void;
|
|
322
333
|
//#endregion
|
|
323
|
-
export { 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, getAnnotationPlacements, getExaminationMessage, getExtParamValueByStudyInstanceUId, getGenerioRecognizeExaminationUrl, loadFormData, loadStudy, login, logout, recognizeExamination, sendMeasurements, setExtParams, setExtParamsPostMessage, setupPostMessageListeners, updateStudy };
|
|
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
|
@@ -145,6 +145,7 @@ var ExaminationDataHelpers = class {
|
|
|
145
145
|
//#endregion
|
|
146
146
|
//#region src/index.ts
|
|
147
147
|
const GENERIO_ORIGIN = "https://gener.io";
|
|
148
|
+
const AUTH_STORAGE_KEY = "generio-auth";
|
|
148
149
|
async function login(model, origin) {
|
|
149
150
|
if ((await fetch((origin ?? GENERIO_ORIGIN) + "/api/cookiesAuth/login", {
|
|
150
151
|
method: "POST",
|
|
@@ -289,6 +290,12 @@ function getGenerioRecognizeExaminationUrl(studyInstanceUId, modality, studyDesc
|
|
|
289
290
|
if (bodyPartExamined) url = url + `&bodyPartExamined=${bodyPartExamined}`;
|
|
290
291
|
return url;
|
|
291
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
|
+
}
|
|
292
299
|
async function checkAuthentication(origin) {
|
|
293
300
|
try {
|
|
294
301
|
const response = await fetch(`${origin ?? GENERIO_ORIGIN}/api/CookiesAuth/isAuthenticated`, {
|
|
@@ -315,6 +322,32 @@ async function checkAuthentication(origin) {
|
|
|
315
322
|
email: ""
|
|
316
323
|
};
|
|
317
324
|
}
|
|
325
|
+
function getAuthFromCache() {
|
|
326
|
+
try {
|
|
327
|
+
const stored = localStorage.getItem(AUTH_STORAGE_KEY);
|
|
328
|
+
if (stored) return JSON.parse(stored);
|
|
329
|
+
} catch (e) {
|
|
330
|
+
console.error("Error reading auth from localStorage:", e);
|
|
331
|
+
}
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
function saveAuthToCache(isAuthenticated, email) {
|
|
335
|
+
try {
|
|
336
|
+
localStorage.setItem(AUTH_STORAGE_KEY, JSON.stringify({
|
|
337
|
+
isAuthenticated,
|
|
338
|
+
email
|
|
339
|
+
}));
|
|
340
|
+
} catch (e) {
|
|
341
|
+
console.error("Error saving auth to localStorage:", e);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
function clearAuthFromCache() {
|
|
345
|
+
try {
|
|
346
|
+
localStorage.removeItem(AUTH_STORAGE_KEY);
|
|
347
|
+
} catch (e) {
|
|
348
|
+
console.error("Error clearing auth from localStorage:", e);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
318
351
|
|
|
319
352
|
//#endregion
|
|
320
|
-
export { ExaminationDataHelpers, FormTypeEnum, GENERIO_ORIGIN, checkAuthentication, getAnnotationPlacements, getExaminationMessage, getExtParamValueByStudyInstanceUId, getGenerioRecognizeExaminationUrl, loadFormData, loadStudy, login, logout, recognizeExamination, sendMeasurements, setExtParams, setExtParamsPostMessage, setupPostMessageListeners, updateStudy };
|
|
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 };
|