103 lines
3.9 KiB
Svelte
103 lines
3.9 KiB
Svelte
|
<script>
|
||
|
import { getKeys, getKey, Key } from '../lib/key';
|
||
|
import { user } from '../stores/user';
|
||
|
import { ToastsStore } from '../stores/toasts';
|
||
|
|
||
|
let keysP = getKeys();
|
||
|
|
||
|
let mykey = "";
|
||
|
let holdSubmit = false;
|
||
|
|
||
|
async function submitPGPKey() {
|
||
|
holdSubmit = true;
|
||
|
let key = new Key({ type: 'pgp', key: mykey });
|
||
|
key.save().then(() => {
|
||
|
keysP = getKeys();
|
||
|
holdSubmit = false;
|
||
|
mykey = "";
|
||
|
ToastsStore.addToast({
|
||
|
msg: "Votre nouvelle clef a bien été enregistrée.",
|
||
|
color: "success",
|
||
|
title: "Clef PGP",
|
||
|
});
|
||
|
}, (error) => {
|
||
|
submitInProgress = false;
|
||
|
ToastsStore.addErrorToast({
|
||
|
msg: "Une erreur s'est produite durant l'envoi de votre clef : " + error + "\nVeuillez réessayer dans quelques instants.",
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<h2>Ma clef PGP</h2>
|
||
|
|
||
|
<p class="lead">
|
||
|
Vos rendus doivent être signés avec votre clef PGP.
|
||
|
</p>
|
||
|
|
||
|
{#await keysP}
|
||
|
Veuillez patienter
|
||
|
{:then keys}
|
||
|
{#if keys && keys.length > 0}
|
||
|
<p>
|
||
|
Vous avez actuellement enregistré {#if keys.length > 1}les clefs publiques suivantes{:else}la clef publique suivante{/if} :
|
||
|
</p>
|
||
|
{#each keys as keyid}
|
||
|
{#await getKey(keyid)}
|
||
|
Veuillez patienter
|
||
|
{:then key}
|
||
|
<div class="alert alert-dark d-flex justify-content-between">
|
||
|
<div class="d-flex">
|
||
|
<div class="d-flex flex-column justify-content-center me-3">
|
||
|
<i class="bi bi-key-fill display-4"></i>
|
||
|
<div class="text-center badge bg-light" style="font-variant: small-caps;">
|
||
|
{key.type}
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
Adresse électronique : <strong class="badge bg-secondary">{key.infos.email}</strong><br>
|
||
|
Nom : <strong>{key.infos.identity}</strong> {#if key.infos.comment}<span class="fst-italic">({key.infos.identity})</span>{/if}<br>
|
||
|
Key ID : <strong>{key.infos.keyid}</strong><br>
|
||
|
Date de la signature : <strong>{key.infos.creation}</strong><br>
|
||
|
Clef expirée : <span class="badge" class:bg-danger={key.infos.sigexpired} class:bg-info={!key.infos.sigexpired}>{key.infos.sigexpired?"oui":"non"}</span>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="d-flex flex-column justify-content-center">
|
||
|
<button
|
||
|
type="button"
|
||
|
class="btn btn-outline-danger float-end"
|
||
|
on:click={() => key.delete().then(() => { keysP = getKeys(); })}
|
||
|
>
|
||
|
Supprimer la clef
|
||
|
</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
{/await}
|
||
|
{/each}
|
||
|
{:else}
|
||
|
<p>
|
||
|
Afin de pouvoir les vérifier, veuillez envoyer votre clef publique dans le formulaire ci-dessous.
|
||
|
Utilisez la commande <code>gpg --export --armor {#if $user}{$user.email}{:else}login_x@epita.fr{/if}</code> :
|
||
|
</p>
|
||
|
|
||
|
<form class="container" on:submit|preventDefault={submitPGPKey}>
|
||
|
<textarea
|
||
|
class="form-control"
|
||
|
rows="10"
|
||
|
bind:value={mykey}
|
||
|
placeholder="-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||
|
|
||
|
QmllbiBzw7tyIHF1ZSBjJ2VzdCB1bmUgY2hhw65uZSBxdWkgdmV1dCBkaXJlIHF1
|
||
|
ZWxxdWUgY2hvc2UK ...
|
||
|
-----END PGP PUBLIC KEY BLOCK-----"
|
||
|
></textarea>
|
||
|
<button
|
||
|
type="submit"
|
||
|
class="mt-2 btn btn-primary"
|
||
|
>
|
||
|
Enregistrer cette clef PGP
|
||
|
</button>
|
||
|
</form>
|
||
|
{/if}
|
||
|
{/await}
|