30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
/** Read-only identity; importing this module neither resolves nor loads executable artifacts. */
|
|
import {
|
|
paperHostIdentitySchema,
|
|
type PaperHostIdentity,
|
|
} from '@stock-bot/stock-config/paper-deployments';
|
|
import { canonicalStrategyJson } from '@stock-bot/stock-config/strategy';
|
|
import { bundledHostUrl, readBuildArtifacts, verifyBundledHost } from './artifacts';
|
|
|
|
export const paperHostUrl = () => bundledHostUrl('paper-host');
|
|
export async function readPaperHostIdentity(): Promise<PaperHostIdentity> {
|
|
const { executableSha256, ...common } = await readBuildArtifacts('paper-host');
|
|
return paperHostIdentitySchema.parse({
|
|
version: 'paper-host/v1',
|
|
hostSha256: executableSha256,
|
|
...common,
|
|
});
|
|
}
|
|
export async function verifyPaperHostBuild(
|
|
expected: PaperHostIdentity,
|
|
actualUrl: string
|
|
): Promise<PaperHostIdentity> {
|
|
verifyBundledHost('paper-host', actualUrl);
|
|
const actual = await readPaperHostIdentity();
|
|
if (
|
|
canonicalStrategyJson(actual) !== canonicalStrategyJson(paperHostIdentitySchema.parse(expected))
|
|
) {
|
|
throw new Error('Paper host/native/runtime build identity mismatch');
|
|
}
|
|
return actual;
|
|
}
|