-
Notifications
You must be signed in to change notification settings - Fork 78
Closed
Description
Why
The current implementation in ProviderProxyService.connectToShell uses message.toString() to serialize Uint8Array shell payloads, which produces a comma-separated string format (e.g., "1,27,65"). While this works correctly with the current provider proxy expectations, base64 encoding would be a better choice for binary data because:
- More compact: Base64 is more space-efficient than comma-separated strings
- Standardized: Base64 is a well-established encoding for binary data in text formats
- Explicitly designed for binary data: Reduces ambiguity and potential edge cases
- Better compatibility: Standard encoding makes it easier to work with other tools and libraries
What
Update the shell payload serialization in both the frontend and provider proxy backend:
-
Frontend (
apps/deploy-web/src/services/provider-proxy/provider-proxy.service.ts):- Change
transformSentMessageinconnectToShellmethod to encode theUint8Arrayas base64 instead of using.toString() - Update the
datafield to contain the base64-encoded string
- Change
-
Backend (provider proxy):
- Update the provider proxy to expect and decode base64-encoded payloads instead of comma-separated strings
- Ensure backward compatibility if needed during the transition
References
- PR refactor: extracts logs/events/shell logic to service layer #2177: refactor: extracts logs/events/shell logic to service layer #2177
- Discussion: refactor: extracts logs/events/shell logic to service layer #2177 (comment)
Additional Context
The current code location:
transformSentMessage: message => {
const remoteMessage: Record<string, unknown> = {
type: "websocket",
url,
auth: providerCredentialsToApiCredentials(input.providerCredentials),
chainNetwork: this.netConfig.mapped(input.chainNetwork),
providerAddress: input.providerAddress
};
if (message.length > 0) {
remoteMessage.data = message.toString(); // <-- Change to base64 encoding
}
return JSON.stringify(remoteMessage);
}Reactions are currently unavailable