Skip to content

Commit

Permalink
Make attachments and app bindings more robust yet secure
Browse files Browse the repository at this point in the history
  • Loading branch information
larkox committed Feb 7, 2025
1 parent c804a1a commit 20a4da5
Show file tree
Hide file tree
Showing 20 changed files with 250 additions and 160 deletions.
22 changes: 11 additions & 11 deletions app/actions/remote/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function handleBindingClick<Res=unknown>(serverUrl: string, binding
id: 'apps.error.malformed_binding',
defaultMessage: 'This binding is not properly formed. Contact the App developer.',
});
return {error: makeCallErrorResponse(errMsg)};
return {error: makeCallErrorResponse<Res>(errMsg)};
}

const res: AppCallResponse<Res> = {
Expand All @@ -48,7 +48,7 @@ export async function handleBindingClick<Res=unknown>(serverUrl: string, binding
id: 'apps.error.malformed_binding',
defaultMessage: 'This binding is not properly formed. Contact the App developer.',
});
return {error: makeCallErrorResponse(errMsg)};
return {error: makeCallErrorResponse<Res>(errMsg)};
}

const callRequest = createCallRequest(
Expand Down Expand Up @@ -83,7 +83,7 @@ export async function doAppSubmit<Res=unknown>(serverUrl: string, inCall: AppCal
id: 'apps.error.responses.form.no_form',
defaultMessage: 'Response type is `form`, but no valid form was included in response.',
});
return {error: makeCallErrorResponse(errMsg)};
return {error: makeCallErrorResponse<Res>(errMsg)};
}

cleanForm(res.form);
Expand All @@ -96,7 +96,7 @@ export async function doAppSubmit<Res=unknown>(serverUrl: string, inCall: AppCal
id: 'apps.error.responses.navigate.no_url',
defaultMessage: 'Response type is `navigate`, but no url was included in response.',
});
return {error: makeCallErrorResponse(errMsg)};
return {error: makeCallErrorResponse<Res>(errMsg)};
}

return {data: res};
Expand All @@ -107,7 +107,7 @@ export async function doAppSubmit<Res=unknown>(serverUrl: string, inCall: AppCal
}, {
type: responseType,
});
return {error: makeCallErrorResponse(errMsg)};
return {error: makeCallErrorResponse<Res>(errMsg)};
}
}
} catch (error) {
Expand All @@ -116,7 +116,7 @@ export async function doAppSubmit<Res=unknown>(serverUrl: string, inCall: AppCal
defaultMessage: 'Received an unexpected error.',
});
logDebug('error on doAppSubmit', getFullErrorMessage(error));
return {error: makeCallErrorResponse(errMsg)};
return {error: makeCallErrorResponse<Res>(errMsg)};
}
}

Expand All @@ -135,7 +135,7 @@ export async function doAppFetchForm<Res=unknown>(serverUrl: string, call: AppCa
id: 'apps.error.responses.form.no_form',
defaultMessage: 'Response type is `form`, but no valid form was included in response.',
});
return {error: makeCallErrorResponse(errMsg)};
return {error: makeCallErrorResponse<Res>(errMsg)};
}
cleanForm(res.form);
return {data: res};
Expand All @@ -144,7 +144,7 @@ export async function doAppFetchForm<Res=unknown>(serverUrl: string, call: AppCa
id: 'apps.error.responses.unknown_type',
defaultMessage: 'App response type not supported. Response type: {type}.',
}, {type: responseType});
return {error: makeCallErrorResponse(errMsg)};
return {error: makeCallErrorResponse<Res>(errMsg)};
}
}
} catch (error) {
Expand All @@ -153,7 +153,7 @@ export async function doAppFetchForm<Res=unknown>(serverUrl: string, call: AppCa
defaultMessage: 'Received an unexpected error.',
});
logDebug('error on doAppFetchForm', getFullErrorMessage(error));
return {error: makeCallErrorResponse(errMsg)};
return {error: makeCallErrorResponse<Res>(errMsg)};
}
}

Expand All @@ -175,7 +175,7 @@ export async function doAppLookup<Res=unknown>(serverUrl: string, call: AppCallR
id: 'apps.error.responses.unknown_type',
defaultMessage: 'App response type not supported. Response type: {type}.',
}, {type: responseType});
return {error: makeCallErrorResponse(errMsg)};
return {error: makeCallErrorResponse<Res>(errMsg)};
}
}
} catch (error: any) {
Expand All @@ -184,7 +184,7 @@ export async function doAppLookup<Res=unknown>(serverUrl: string, call: AppCallR
defaultMessage: 'Received an unexpected error.',
});
logDebug('error on doAppLookup', getFullErrorMessage(error));
return {error: makeCallErrorResponse(errMsg)};
return {error: makeCallErrorResponse<Res>(errMsg)};
}
}

Expand Down
Loading

0 comments on commit 20a4da5

Please sign in to comment.