51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
|
|
/**
|
||
|
|
* Consumer-strict smoke for `@shade/sdk`.
|
||
|
|
*
|
||
|
|
* Exercises the high-level `createShade()` flow + the V3.x opt-in
|
||
|
|
* surfaces (KT, WebRTC, fingerprint gates). Compiles under DOM-lib +
|
||
|
|
* exactOptionalPropertyTypes to flag any private-type leaks like the
|
||
|
|
* `Promise<unknown>` on `fetchLatestSTH` that 4.0.0 shipped.
|
||
|
|
*/
|
||
|
|
import {
|
||
|
|
createShade,
|
||
|
|
type Shade,
|
||
|
|
type ShadeConfig,
|
||
|
|
type ShadeWebRtcConfig,
|
||
|
|
} from '@shade/sdk';
|
||
|
|
|
||
|
|
declare const factory: ShadeWebRtcConfig['factory'];
|
||
|
|
|
||
|
|
async function smoke(): Promise<void> {
|
||
|
|
const config: ShadeConfig = {
|
||
|
|
prekeyServer: 'https://shade.example.com',
|
||
|
|
storage: 'memory',
|
||
|
|
address: 'alice@example.com',
|
||
|
|
keyTransparency: {
|
||
|
|
mode: 'observe-strict',
|
||
|
|
logPublicKey: new Uint8Array(32),
|
||
|
|
},
|
||
|
|
};
|
||
|
|
const shade: Shade = await createShade(config);
|
||
|
|
|
||
|
|
const env = await shade.send('bob', 'hi');
|
||
|
|
void env;
|
||
|
|
|
||
|
|
shade.onMessage(async (from: string, plaintext: string) => {
|
||
|
|
void from;
|
||
|
|
void plaintext;
|
||
|
|
});
|
||
|
|
|
||
|
|
await shade.beforeFirstLargeFile(10 * 1024 * 1024, async (ctx) => {
|
||
|
|
void ctx.peerAddress;
|
||
|
|
void ctx.fingerprint;
|
||
|
|
void ctx.gate;
|
||
|
|
return true;
|
||
|
|
});
|
||
|
|
|
||
|
|
shade.configureWebRTC({ factory });
|
||
|
|
|
||
|
|
void (await shade.fingerprint);
|
||
|
|
}
|
||
|
|
|
||
|
|
void smoke;
|