43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
|
|
/**
|
||
|
|
* Consumer-strict smoke for `@shade/key-transparency`.
|
||
|
|
*
|
||
|
|
* The package was the source of the 4 noUnusedLocals + the IndexProofWire
|
||
|
|
* privacy bug in 4.0.0. This smoke imports every public type and
|
||
|
|
* exercises the witness-fetcher contract that the SDK plugs into.
|
||
|
|
*/
|
||
|
|
import {
|
||
|
|
LightWitness,
|
||
|
|
type SignedTreeHead,
|
||
|
|
type STHWire,
|
||
|
|
type WitnessFetcher,
|
||
|
|
} from '@shade/key-transparency';
|
||
|
|
|
||
|
|
declare const crypto: import('@shade/core').CryptoProvider;
|
||
|
|
declare const logPublicKey: Uint8Array;
|
||
|
|
|
||
|
|
async function smoke(): Promise<void> {
|
||
|
|
const fetcher: WitnessFetcher = {
|
||
|
|
async fetchLatestSTH(): Promise<STHWire> {
|
||
|
|
const res = await fetch('https://shade.example.com/v1/kt/sth');
|
||
|
|
return (await res.json()) as STHWire;
|
||
|
|
},
|
||
|
|
async fetchConsistencyProof(
|
||
|
|
from: number,
|
||
|
|
to: number,
|
||
|
|
): Promise<{ proof: string[] }> {
|
||
|
|
const res = await fetch(
|
||
|
|
`https://shade.example.com/v1/kt/consistency?from=${from}&to=${to}`,
|
||
|
|
);
|
||
|
|
return (await res.json()) as { proof: string[] };
|
||
|
|
},
|
||
|
|
};
|
||
|
|
const witness = new LightWitness({ crypto, logPublicKey, fetcher });
|
||
|
|
void witness;
|
||
|
|
}
|
||
|
|
|
||
|
|
void smoke;
|
||
|
|
|
||
|
|
// Verify the type is reachable with no `any` leak.
|
||
|
|
declare const sth: SignedTreeHead;
|
||
|
|
void sth.treeSize;
|