fastenhealth / fasten-onprem

Fasten is an open-source, self-hosted, personal/family electronic medical record aggregator, designed to integrate with 100,000's of insurances/hospitals/clinics
GNU General Public License v3.0
1.63k stars 85 forks source link

[Bug]: js console error from oauth4webapi.js #509

Open dwradcliffe opened 3 months ago

dwradcliffe commented 3 months ago

What happened?

I'm seeing this error in the js console, coming from the included oauth4webapi library.

https://github.com/fastenhealth/fasten-onprem/blob/7d0715755051d591bc94e873a75f43d3da4ba921/frontend/angular.json#L79

SyntaxError: Unexpected token 'export' (at oauth4webapi.js:91:1)

I believe this is because this file is a module which can't be included directly without using type="module" in the script tag. But angular doesn't support this because anything that is a module should be included in the main bundle.

So, where is this being used and is it actually working?

Flavor

Docker

Version

dev

AnalogJ commented 3 months ago

Honestly my initial reaction was to say it's required for the callback redirect code in

https://github.com/fastenhealth/fasten-onprem/blob/7d0715755051d591bc94e873a75f43d3da4ba921/frontend/src/app/services/lighthouse.service.ts#L8

and

https://github.com/fastenhealth/fasten-onprem/blob/7d0715755051d591bc94e873a75f43d3da4ba921/frontend/src/app/services/auth.service.ts

Git blame says it was added pretty early in development - https://github.com/fastenhealth/fasten-onprem/commit/9c7504e7bda1cae276655bfa6631ac0775702c0a

I think I had issues calling the Oauth functions without doing the script import. It could also be related to the crypto.subtle polyfill (for users who run Fasten on a custom domain, but without a valid cert. eg. health.local or health.internal)

I never had issues with this during development however. I'm surprised that you cant compile.

dwradcliffe commented 3 months ago

Because it's imported in those places properly, I think it shouldn't be needed in the global namespace. I'll PR to remove it.