chayev / yurl

Universal Links / App Links Validator
https://yurl.chayev.com/
MIT License
30 stars 7 forks source link

Added Apple CDN Debug Headers #65

Closed aceslick911 closed 1 year ago

aceslick911 commented 1 year ago

Added apple CDN debug headers Eg:

curl https://app-site-association.cdn-apple.com/a/v1/MYDOMAIN -v
*   Trying 17.253.67.202:443...
* Connected to app-site-association.cdn-apple.com (17.253.67.202) port 443 (#0)

...

> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Apple-Failure-Details: {"status":"403 Forbidden"}
< Apple-Failure-Reason: SWCERR00101 Bad HTTP Response: 403 Forbidden
< Apple-From: https://MYDOMAIN/.well-known/apple-app-site-association
< Apple-Try-Direct: false
< Cache-Control: max-age=1800,public
< Content-Length: 10
< Content-Type: text/plain; charset=utf-8
< Date: Fri, 20 Jan 2023 03:03:22 GMT
< Expires: Fri, 20 Jan 2023 03:03:32 GMT
< Age: 1399
< Via: http/1.1 ausyd2-vp-vst-002.ts.apple.com (acdn/176.13298), https/1.1 ausyd2-vp-vfe-008.ts.apple.com (acdn/168.13283), http/1.1 ausyd2-edge-lx-011.ts.apple.com (acdn/59.14204), http/1.1 ausyd2-edge-bx-008.ts.apple.com (acdn/59.14204)

...

adds new output:

Apple CDN Debug Headers: https://app-site-association.cdn-apple.com/a/v1/MYDOMAIN AppleFailureDetails: [{"status":"403 Forbidden"}] AppleFailureReason: [SWCERR00101 Bad HTTP Response: 403 Forbidden] AppleFrom: [https://MYDOMAIN/.well-known/apple-app-site-association] AppleTryDirect: [false] CacheControl: [max-age=1800,public] ContentLength: [10] Date: [Fri, 20 Jan 2023 04:15:46 GMT] Expires: [Fri, 20 Jan 2023 04:15:57 GMT] Via: [https/1.1 ausyd2-vp-vst-003.ts.apple.com (acdn/176.13298), https/1.1 ausyd2-vp-vfe-005.ts.apple.com (acdn/168.13283), http/1.1 ausyd2-edge-lx-011.ts.apple.com (acdn/59.14204), http/1.1 ausyd2-edge-bx-017.ts.apple.com (acdn/59.14204)] Age: [1538]

chayev commented 1 year ago

@aceslick911 Thank you so much for your contribution here!

The idea to add Apple CDN Debug Headers is great! I reviewed your code and can see what you are trying to do.

Please note that I have tested and can confirm that the headers are not being added to the output of the CLI or web app. Have you tested on your end? Could you show me a screenshot of what you are seeing?

Here are some instructions on how you can test the web app locally:

Let me know if you have any questions about this.

chayev commented 1 year ago

Also, could you please try refactoring the code to not change these functions:

Please make a new function (something like getAppleCDNDebugHeaders() ) that holds the logic. You should be able to accomplish the same thing you are trying by calling your new function within loadAASAContents().

aceslick911 commented 1 year ago

Hi @chayev

Apologies I must have messed something up after rebasing šŸ˜…

Here's an example of ASA failures with the cleaned up code:

image

Here's an example where all checks pass:

image

Hope this can help other teams out there - as it's so difficult and complicated these days to figure out what's gone wrong with deep linking without helpful validation tools that cover conditions not even listed in most documentation out there.

So many external factors - which is why I was compelled to make this contribution šŸ‘

chayev commented 1 year ago

@aceslick911 Thank you again for addressing the changes requested. From taking a quick look I can now see the output in the web app! I will need more time to review the code a bit closer, will keep you updated.

I wanted to share this quote to show how important this change is: "Starting with macOS 11 and iOS 14, apps no longer send requests for apple-app-site-association files directly to your web server. Instead, they send these requests to an Apple-managed content delivery network (CDN) dedicated to associated domains." source

We will get this added into production as soon as the code is review.

@aceslick911 for now, could you please rebase and squash (or fixup) so that there is only one commit? It would make merging this PR cleaner. Let me know if you have any questions/concerns about this.

aceslick911 commented 1 year ago

Thanks for the review @chayev - addressed all the comments āœ…

All were valid and easy to address :)

Rebased and squashed šŸ‘

chayev commented 1 year ago

@aceslick911 thanks for addressing the review so quickly! Confirming that I see all of the changed and they look great.

Please note that something is off now. It looks like the Apple CDN Cache Checks always fail. It might be due to the lines 314 - 317. The CDN Cached Contents are always empty. See facebook.com for example:

image

I checked a few other domains as well. They were working before and now it always comes back as a failure. Please address when you get a chance.

aceslick911 commented 1 year ago

Thanks having a look now @chayev

aceslick911 commented 1 year ago

Woops. != instead of ==

image

fixed

chayev commented 1 year ago

@aceslick911 thank you so much for your contribution to this project! This PR has been merged into main and will be included in the next release.

If you have any other idea, we are open to them! Please contribute again.

Feel free to reach out to me via email (michael @ chayev.com [no spaces]), I would like to learn how you use yURL and if you have any suggestions on how we can do better.