Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[expo-updates] add ability for android clients to handle header signatures #11897

Merged
merged 6 commits into from
Feb 11, 2021

Conversation

jkhales
Copy link
Contributor

@jkhales jkhales commented Feb 10, 2021

Why

EAS updates will send the signature back in the headers.

Working on PR for the iOS version separately.

How

  • Added logic to handle signatures in headers as well as in the body.
  • because signed manifests put have the manifest as a key inside the body instead of equal to the body itself, did some renaming to clarify this. e.g. renamed extractManifest to extractUpdateResponseJson

Test Plan

Tested signed/unsigned on new/legacy format manifests.

@github-actions
Copy link
Contributor

Native Component List for this branch is ready

Comment on lines +146 to +147
preManifest.put("isVerified", false);
Manifest manifest = ManifestFactory.getManifest(preManifest, configuration);
Copy link
Contributor Author

@jkhales jkhales Feb 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously we only set isVerified to false on unsigned manifests from XDL. isVerified was never set on unsigned manifests from non-XDL sources. Grep'ing the expo repo it seems this is handled by interpreting null to be false using optBoolean.

Following 'explicit is better than implicit' as well as this code comment:

// We should treat these manifests as unsigned rather than signed with an invalid signature. 

This PR centralizes the treatment of unsigned manifests from XDL and non-XDL sources to these lines.

@@ -204,7 +213,7 @@ public void onResponse(Call call, Response response) throws IOException {
});
}

private static JSONObject extractManifest(String manifestString, UpdatesConfiguration configuration) throws IOException {
private static JSONObject extractUpdateResponseJson(String manifestString, UpdatesConfiguration configuration) throws IOException {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function seems like it is dead code. It is unable to handle the array case in the case that the manifest is signed.

Is there a use case for arrays of sdkVersions only in the case of unsigned manifests?

Otherwise we could just replace this with a call to JSONObject.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a use case for arrays of sdkVersions only in the case of unsigned manifests?

Yes, exactly -- the "array" case is used for multi-manifests generated by expo export, which are never signed. While we could add the ability to handle signatures in the body, I think it's better to just focus on supporting the modern method of header signatures moving forward.

@jkhales jkhales requested a review from esamelson February 10, 2021 19:54
@jkhales jkhales marked this pull request as ready for review February 10, 2021 19:54
Copy link
Contributor

@esamelson esamelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, this looks great 🎉 Feel free to land this now, if you want -- no need to wait to combine with the iOS side.

@@ -204,7 +213,7 @@ public void onResponse(Call call, Response response) throws IOException {
});
}

private static JSONObject extractManifest(String manifestString, UpdatesConfiguration configuration) throws IOException {
private static JSONObject extractUpdateResponseJson(String manifestString, UpdatesConfiguration configuration) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a use case for arrays of sdkVersions only in the case of unsigned manifests?

Yes, exactly -- the "array" case is used for multi-manifests generated by expo export, which are never signed. While we could add the ability to handle signatures in the body, I think it's better to just focus on supporting the modern method of header signatures moving forward.

Copy link
Contributor

@esamelson esamelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, meant to approve (with the suggested change)

@jkhales jkhales merged commit 8c0896b into master Feb 11, 2021
@jkhales jkhales deleted the @jkhales/add-header-signatures branch February 11, 2021 14:34
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants