27 lines
1.5 KiB
JavaScript
27 lines
1.5 KiB
JavaScript
import { hash } from './engine.mjs';
|
|
// Only user-consented application metadata crosses this interface; not the entire private context.
|
|
export function publicMotherPacket(applicationResponse) {
|
|
const { application, digest } = applicationResponse;
|
|
if (!application || typeof digest !== 'string' || !Array.isArray(application.evidenceRefs)) throw Error('APPLICATION_REQUIRED');
|
|
if (hash(application) !== digest) throw Error('APPLICATION_DIGEST_MISMATCH');
|
|
return {
|
|
schema: 'hololake.public-mother-recognition-request/v1', scope: 'public',
|
|
motherSystem: 'TCS-MOTHER-LPM-0001', publicPersonaBody: 'SYS-GLW-POS-0001',
|
|
governanceDomain: 'DOMAIN-ZS', applicationDigest: digest,
|
|
applicationId: application.id, candidateName: application.seedName,
|
|
evidenceRefs: [...application.evidenceRefs], privateContextIncluded: false,
|
|
desiredResponse: 'SIGNED_REVIEW_APPLICATION_FROM_ENROLLED_PUBLIC_MOTHER_KEY',
|
|
automaticFormalRegistration: false,
|
|
};
|
|
}
|
|
|
|
export async function requestPublicMotherReview(application, transport) {
|
|
if (typeof transport?.reviewPublic !== 'function') throw Error('PUBLIC_MOTHER_TRANSPORT_NOT_CONNECTED');
|
|
const packet = publicMotherPacket(application);
|
|
const response = await transport.reviewPublic(packet);
|
|
if (response?.action !== 'REVIEW_APPLICATION' || response.payload?.digest !== packet.applicationDigest) {
|
|
throw Error('MOTHER_REVIEW_NOT_BOUND_TO_APPLICATION');
|
|
}
|
|
// The engine still verifies enrolled public role, signature, decision and freshness.
|
|
return response;
|
|
}
|