This PR adds token authentication flow to the extension.
Changes
Added login command.
Internally it grabs pasted token and saves it in local fs.
Having token means the user is authenticated which triggers policy puller which starts fetching policies (initially and periodically).
Added logout command.
Fixes
Mostly refactored some existing parts of the code.
Future improvements
I will work on README adjustments in separate PR (or add post-review) so we can review the code already.
Keep in mind that logic related to auth (mostly store.ts), api communication (mostly api.ts) and probably git related should/will be extracted to separate core package/s.
Maybe we can use build-in authentication interface, looks a bit complex for token authentication only but maybe for later 🤔 (see examples 1, 2).
I started to feel that code got a bit too closely tangled and some utils have too much knowledge/responsibility. It seems that we may need to go more into event-driven architecture or have something for better state management (or just clean it up, what I'm planning to do).
This PR adds token authentication flow to the extension.
Changes
login
command.logout
command.Fixes
Future improvements
store.ts
), api communication (mostlyapi.ts
) and probably git related should/will be extracted to separate core package/s.Checklist