2022-08-14 13:27:41 -07:00
|
|
|
<script>
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
2022-11-27 22:03:15 -08:00
|
|
|
import { invoke } from '@tauri-apps/api/tauri';
|
|
|
|
|
2022-12-28 15:48:25 -08:00
|
|
|
import Icon from '../ui/Icon.svelte';
|
2022-12-22 19:53:14 -08:00
|
|
|
|
2022-11-27 22:03:15 -08:00
|
|
|
export let appState;
|
2022-08-14 13:27:41 -07:00
|
|
|
|
|
|
|
const dispatch = createEventDispatcher();
|
2022-11-23 17:11:44 -08:00
|
|
|
|
2022-11-27 22:03:15 -08:00
|
|
|
async function approve() {
|
2022-12-13 21:50:34 -08:00
|
|
|
let status = await invoke('get_session_status');
|
2022-12-13 16:50:44 -08:00
|
|
|
if (status === 'unlocked') {
|
2022-11-27 22:03:15 -08:00
|
|
|
dispatch('navigate', {target: 'ShowApproved'});
|
|
|
|
}
|
2022-12-13 16:50:44 -08:00
|
|
|
else if (status === 'locked') {
|
|
|
|
dispatch('navigate', {target: 'Unlock'})
|
|
|
|
}
|
2022-11-27 22:03:15 -08:00
|
|
|
else {
|
2022-12-13 16:50:44 -08:00
|
|
|
dispatch('navigate', {target: 'EnterCredentials'});
|
2022-11-27 22:03:15 -08:00
|
|
|
}
|
2022-11-23 17:11:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function deny() {
|
|
|
|
dispatch('navigate', {target: 'ShowDenied'});
|
|
|
|
}
|
2022-12-19 15:26:44 -08:00
|
|
|
|
|
|
|
function handleHotkey(event) {
|
|
|
|
if (event.shiftKey && (event.code === 'Enter' || event.code === 'NumpadEnter')) {
|
|
|
|
approve();
|
|
|
|
}
|
2022-12-21 14:49:01 -08:00
|
|
|
else if (event.code === 'Escape') {
|
|
|
|
deny();
|
|
|
|
}
|
2022-12-19 15:26:44 -08:00
|
|
|
}
|
2022-08-14 13:27:41 -07:00
|
|
|
|
2023-04-23 22:29:12 -07:00
|
|
|
var appName = null;
|
|
|
|
console.log(appName);
|
|
|
|
if (appState.currentRequest.clients.length === 1) {
|
|
|
|
let path = appState.currentRequest.clients[0].exe;
|
|
|
|
let m = path.match(/\/([^/]+?$)|\\([^\\]+?$)/);
|
|
|
|
appName = m[1] || m[2];
|
|
|
|
}
|
|
|
|
</script>
|
2022-12-19 15:26:44 -08:00
|
|
|
|
2022-08-14 13:27:41 -07:00
|
|
|
|
2023-04-23 22:29:12 -07:00
|
|
|
<svelte:window on:keydown={handleHotkey} />
|
2022-12-21 13:42:12 -08:00
|
|
|
|
2023-04-23 22:29:12 -07:00
|
|
|
<div class="flex flex-col space-y-4 p-4 m-auto max-w-max h-screen justify-center">
|
|
|
|
<!-- <div class="p-4 rounded-box border-2 border-neutral-content"> -->
|
|
|
|
<div class="space-y-1 mb-4">
|
|
|
|
<h2 class="text-xl font-bold">{appName ? `"${appName}"` : 'An appplication'} would like to access your AWS credentials.</h2>
|
|
|
|
{#each appState.currentRequest.clients as client}
|
|
|
|
<p>Path: {client ? client.exe : 'Unknown'}</p>
|
|
|
|
<p>PID: {client ? client.pid : 'Unknown'}</p>
|
|
|
|
{/each}
|
|
|
|
</div>
|
2022-12-21 13:42:12 -08:00
|
|
|
|
2023-04-23 22:29:12 -07:00
|
|
|
<div class="grid grid-cols-2">
|
|
|
|
<button class="btn btn-error justify-self-start" on:click={deny}>
|
|
|
|
Deny
|
|
|
|
|
|
|
|
<!-- <kbd class="kbd kbd-xs bg-error border-base-100">Esc</kbd> -->
|
|
|
|
<kbd class="normal-case px-1 py-0.5 rounded border border-neutral">Esc</kbd>
|
|
|
|
</button>
|
|
|
|
<button class="btn btn-success justify-self-end" on:click={approve}>
|
|
|
|
Approve
|
|
|
|
|
|
|
|
<kbd class="normal-case px-1 py-0.5 rounded border border-neutral">Shift</kbd>
|
|
|
|
<span class="mx-0.5">+</span>
|
|
|
|
<kbd class="normal-case px-1 py-0.5 rounded border border-neutral">Enter</kbd>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<!-- </div> -->
|
2022-12-21 13:42:12 -08:00
|
|
|
</div>
|