SmartTokenLabs / token-negotiator

The token-negotiator is an NPM package designed for use with TokenScript.
MIT License
19 stars 11 forks source link

update design to avoid accessing 3rd party storage #23

Closed nicktaras closed 2 years ago

nicktaras commented 3 years ago

When a user visits the ticket issuer website, the tickets will not load by default via Safari IOS. The user must navigate to their settings and remove the prevention of cross site cookies.

https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage https://developer.mozilla.org/en-US/docs/Web/API/Storage_Access_API https://developer.mozilla.org/en-US/docs/Web/API/Storage_Access_API/Using https://webkit.org/blog/8124/introducing-storage-access-api/

This ticket is to confirm if this is an acceptable experience for our end users.

If Yes. We can add details of how to change the settings. If No, we can look to apply a solution such as using Post Message, Storage Access API Flow for Safari.

Google to phase out third party cookies 2022 - https://www.theverge.com/2020/1/14/21064698/google-third-party-cookies-chrome-two-years-privacy-safari-firefox

AW-STJ commented 3 years ago

If Google is going to phase out 3rd party cookies before Devcon happens, then we will need to address it now.

Let us take a look at the alternative solution.

@colourful-land - can you give us some guidance. From chat with Nick, it seems like the full-proof solution would be to use a backend API / Service. However, this is how web 2.0 works.

SmartLayer commented 3 years ago

@nicktaras no not acceptable. but I don't remember we ever planed to access any 3rd party cookie or 3rd party website's local storage at all. @oleggrib said earlier all comms are done by messaging to/from iframe. If you are facing this problem, either @oleggrib 's work is not extensive enough to cover the negotiator case, or you are missing some of his code.

SmartLayer commented 3 years ago

@nicktaras I think this will work: when a user access issuer's website, the website opens an iframe to the issuer's outlet to get ticket information, just like the 3rd party website. It is the code in that outlet that decides to pass ticket token objects based in predefined whitelist rules in JAVASCRIPT, not that the issuer's website fetches data from local storage. Push, not fetch.

nicktaras commented 3 years ago

Screenshot 2021-06-23 at 16 50 51

This is to share the current state - latest code. To help us to address the changes required.

nicktaras commented 3 years ago

Added notes from today's meeting:

SmartLayer commented 3 years ago

@nicktaras the outlet should produce proof, not the secret used to make such proof. @oleggrib has code to produce such proof, just make sure it's produced in the outlet and sent out, not produced outside of the outlet by reading its secret.

nicktaras commented 3 years ago

@oleggrib could you share where the code you have produced for the proof can be located and I will integrate this.

oleggrib commented 3 years ago

https://github.com/TokenScript/attestation/blob/javascript-crypto/src/main/javascript/negotiator/src/Negotiator.js this is last source of Negotiator, it can interact between iframes

nicktaras commented 2 years ago

Re-opened this issue for the time being which contains resources to this issue / previous efforts made.

nicktaras commented 2 years ago

https://developer.mozilla.org/en-US/docs/Web/API/Storage_Access_API

@colourful-land I'm going look at implementing this today - where if this works, this will enable our solution with Iframes to work across all major platforms.

Safari (Mobile and desktop), Firefox, Windows, Chrome, Android. Although experimental, I think this is the best route to take if this covers all the browsers.

Note:

nicktaras commented 2 years ago

Closing this ticket, where we are no longer using cross origin communication with window.postmessage()

Additional notes:

Storage API only provided access to cookies, not local storage when a user gesture was made. This is also an experimental technology, where it has been avoided for now.

It is possible to use cross origin local storage, on the basis that the user has seen the origin tab - however if we think of an example where the user has 3 or more tokens across different issuer pages, this will be a very bad user experience.

The found solution is to use cross origin cookies, with the concept around attestation via the top window (embedded web components e.g. overlay + attestation.id modal).