Fix/proving machine endpoint type (#538)

* store endpoint type in proving machine

* yarn nice
This commit is contained in:
turnoffthiscomputer
2025-04-28 11:57:37 -04:00
committed by GitHub
parent bb1540e007
commit af44cd8750

View File

@@ -123,6 +123,7 @@ interface ProvingState {
circuitType: provingMachineCircuitType | null;
error_code: string | null;
reason: string | null;
endpointType: EndpointType | null;
init: (circuitType: 'dsc' | 'disclose' | 'register') => Promise<void>;
startFetchingData: () => Promise<void>;
validatingDocument: () => Promise<void>;
@@ -238,6 +239,7 @@ export const useProvingStore = create<ProvingState>((set, get) => {
selfApp: null,
error_code: null,
reason: null,
endpointType: null,
_handleWebSocketMessage: async (event: MessageEvent) => {
if (!actor) {
console.error('Cannot process message: State machine not initialized.');
@@ -282,25 +284,15 @@ export const useProvingStore = create<ProvingState>((set, get) => {
}). Using received UUID.`,
);
}
const { passportData } = get();
if (!statusUuid) {
const endpointType = get().endpointType;
if (!endpointType) {
console.error(
'Cannot start Socket.IO listener: UUID missing from state or response.',
'Cannot start Socket.IO listener: endpointType not set.',
);
actor!.send({ type: 'PROVE_ERROR' });
return;
}
if (!passportData) {
console.error(
'Cannot start Socket.IO listener: passportData missing from state.',
);
actor!.send({ type: 'PROVE_ERROR' });
return;
}
const socketEndpointType =
passportData.documentType === 'passport' ? 'celo' : 'staging_celo';
get()._startSocketIOStatusListener(statusUuid, socketEndpointType);
get()._startSocketIOStatusListener(statusUuid, endpointType);
} else if (result.error) {
console.error('Received error from TEE:', result.error);
actor!.send({ type: 'PROVE_ERROR' });
@@ -461,6 +453,8 @@ export const useProvingStore = create<ProvingState>((set, get) => {
userConfirmed: false,
passportData: null,
secret: null,
circuitType,
endpointType: null,
});
actor = createActor(provingMachine);
@@ -683,6 +677,7 @@ export const useProvingStore = create<ProvingState>((set, get) => {
serverPublicKey: null,
sharedKey: null,
uuid: null,
endpointType: null,
});
},
@@ -734,6 +729,9 @@ export const useProvingStore = create<ProvingState>((set, get) => {
JSON.stringify(payload),
forgeKey,
);
// Persist endpointType for later Socket.IO connection
set({ endpointType: endpointType as EndpointType });
return {
jsonrpc: '2.0',
method: 'openpassport_submit_request',