Format docs using linter and prettier.

This commit is contained in:
Spencer Ofwiti
2021-05-11 20:51:48 +03:00
parent 5228842e61
commit 208c448984
309 changed files with 11327 additions and 3307 deletions

View File

@@ -138,8 +138,8 @@
<div class="tab-pane fade tab-source-code" id="c-source">
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import {MutableKeyStore} from &#x27;@app/_pgp/pgp-key-store&#x27;;
import {LoggingService} from &#x27;@app/_services/logging.service&#x27;;
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { MutableKeyStore } from &#x27;@app/_pgp/pgp-key-store&#x27;;
import { LoggingService } from &#x27;@app/_services/logging.service&#x27;;
const openpgp &#x3D; require(&#x27;openpgp&#x27;);
@@ -147,12 +147,12 @@ interface Signable {
digest(): string;
}
type Signature &#x3D; {
engine: string
algo: string
data: string
interface Signature {
engine: string;
algo: string;
data: string;
digest: string;
};
}
interface Signer {
onsign(signature: Signature): void;
@@ -164,7 +164,6 @@ interface Signer {
}
class PGPSigner implements Signer {
engine &#x3D; &#x27;pgp&#x27;;
algo &#x3D; &#x27;sha256&#x27;;
dgst: string;
@@ -190,28 +189,35 @@ class PGPSigner implements Signer {
}
public verify(digest: string, signature: Signature): void {
openpgp.signature.readArmored(signature.data).then((sig) &#x3D;&gt; {
const opts &#x3D; {
message: openpgp.cleartext.fromText(digest),
publicKeys: this.keyStore.getTrustedKeys(),
signature: sig,
};
openpgp.verify(opts).then((v) &#x3D;&gt; {
let i &#x3D; 0;
for (i &#x3D; 0; i &lt; v.signatures.length; i++) {
const s &#x3D; v.signatures[i];
if (s.valid) {
this.onverify(s);
return;
openpgp.signature
.readArmored(signature.data)
.then((sig) &#x3D;&gt; {
const opts &#x3D; {
message: openpgp.cleartext.fromText(digest),
publicKeys: this.keyStore.getTrustedKeys(),
signature: sig,
};
openpgp.verify(opts).then((v) &#x3D;&gt; {
let i &#x3D; 0;
for (i &#x3D; 0; i &lt; v.signatures.length; i++) {
const s &#x3D; v.signatures[i];
if (s.valid) {
this.onverify(s);
return;
}
}
}
this.loggingService.sendErrorLevelMessage(&#x60;Checked ${i} signature(s) but none valid&#x60;, this, {error: &#x27;404 Not found!&#x27;});
this.loggingService.sendErrorLevelMessage(
&#x60;Checked ${i} signature(s) but none valid&#x60;,
this,
{ error: &#x27;404 Not found!&#x27; }
);
this.onverify(false);
});
})
.catch((e) &#x3D;&gt; {
this.loggingService.sendErrorLevelMessage(e.message, this, { error: e });
this.onverify(false);
});
}).catch((e) &#x3D;&gt; {
this.loggingService.sendErrorLevelMessage(e.message, this, {error: e});
this.onverify(false);
});
}
public async sign(digest: string): Promise&lt;void&gt; {
@@ -226,28 +232,26 @@ class PGPSigner implements Signer {
privateKeys: [pk],
detached: true,
};
openpgp.sign(opts).then((s) &#x3D;&gt; {
this.signature &#x3D; {
engine: this.engine,
algo: this.algo,
data: s.signature,
// TODO: fix for browser later
digest,
};
this.onsign(this.signature);
}).catch((e) &#x3D;&gt; {
this.loggingService.sendErrorLevelMessage(e.message, this, {error: e});
this.onsign(undefined);
});
openpgp
.sign(opts)
.then((s) &#x3D;&gt; {
this.signature &#x3D; {
engine: this.engine,
algo: this.algo,
data: s.signature,
// TODO: fix for browser later
digest,
};
this.onsign(this.signature);
})
.catch((e) &#x3D;&gt; {
this.loggingService.sendErrorLevelMessage(e.message, this, { error: e });
this.onsign(undefined);
});
}
}
export {
Signable,
Signature,
Signer,
PGPSigner
};
export { Signable, Signature, Signer, PGPSigner };
</code></pre>
</div>
</div>