Okay, hypothetically, if somebody was looking for a name for a Free Software project that focuses on Web censorship circumvention, using multiple configurable non-standard in-browser delivery mechanisms, what would a good name be?

Asking for a friend.

Basically the whole day of hacking on the little decentralization project today. Good progress. This thing is becoming surprisingly usable.

I will announce the new name (it's going to either be SideWays or Samizdat, most probably) early next week, and full code will follow shortly.

Haven't had a project I was that excited about for a long while. I missed that feeling a lot!

Well that went fast! Rename complete, code a bit cleaned, stuff tested.

I give you Saмiзdaт:
git.occrp.org/libre/samizdat

Example deployment:
cdn.test.occrp.org/projects/sa

Go on, test in modern Firefox, Chromium, or Chrome.

There are g-glitches every now and then, but basically once the ServiceWorker kicks in you should see a "YES" there on the example page. When you do, you should also notice the favicon appearing. That means IPFS is working; there is no favicon on that server!

is moving forward nicely. We now have some basic explanation on the landing page, a nicer display of methods used to fetch content, and (just implemented, hot from the CI/CD pipeline!) info on which resources were fetched using which method.

Check it out:
cdn.test.occrp.org/projects/sa

Pretty sweet, if I may be so bold to say so!

This is still Proof-of-Concept quality, and so many things can be done so much better. But it works already, in a way.

So, yay!

For those new to the thing:
1. if you want to test it, load it, and then reload it -- or even close the tab and open a new one to load it again; this way the ServiceWorker will kick in and stuff will start happening;
2. it will not work without JS (sorry...), and it will not work in incognito/private mode.

To those who had already looked at it: I would be super interested if your service worker kicked in! You might not get the full functionality until the service worker reloads.

TFW you need to refactor your code to use a completely new (to you) technique of dealing with some particular problem, using technology you don't really feel that comfortable with...

...and 2h later stuff actually works:
git.occrp.org/libre/samizdat/b

I am very okay with this.

Also, can now chain multiple delivery plugins. Which means I should now be able to implement caching using Caching API.

Do I have a ticket where I am tracking this, you ask?

Why yes, yes I do:
git.occrp.org/libre/samizdat/i

Moar news: cache plugin implemented, but content not automagically pushed to local cache yet. You can test by:
1. going to cdn.test.occrp.org/projects/sa , reloading so that ServiceWorker kicks in
2. in JS console, run: await SamizdatPlugins[0].push(listLocalResources())
3. once the flurry of activity ends, block cdn.test.occrp.org in /etc/hosts
4. reload. should load immediately, and most resources should be marked as fetched from cache.

Clearing cache is as easy as:
await caches.delete('v1')

Once you do that, while cdn.test.occrp.org is still blocked, you can reload the page and you should see load content (slowly...) from gun+ipfs.

So! Now we have two plugins. 😈

New in : implemented auto-caching of successful requests, and UIs for clearing the cache and publishing to Gun+IPFS. Check it out: cdn.test.occrp.org/projects/sa

I will need to make caching a bit less aggressive, and/or Gun a bit more patient in waiting for the *latest* version of a given resource IPFS address, but all in all, works pretty ok.

Also, some more UI niceness would be good -- displaying progress of pushing to Gun+IPFS, and informing user that cache has been successfully cleared, that sort of thing.

Had a great long conversation with @tomasino about . Got some solid architectural advice. 👌🏾

Made fetch() into a plugin; we can now serve stuff from cache before a regular HTTP(S) fetch() goes out.

Next steps include:
- code cleanups
- reimplementing how we store/access data about which URL was retrieved how
- implementing a retrieve-from-cache-but-keep-fetching-in-background strategy so that a blocked site "loads" immediately, but the user still gets the fresh version eventually.

Also added some project status info and how to contact us on the landing page and in the README:
cdn.test.occrp.org/projects/sa

My ToDo list still includes moving the project to a public Gitlab instance (0xacab.org probably, since it hosts a bunch of related projects including @sutty).

I really need to do this soon, but it requires setting up the CI/CD pipeline in a new location (probably on my own server). And that's a bit of work.

Oooof, some serious code cleanups and rewrites in this weekend: git.occrp.org/libre/samizdat/c

The tl;dr is:
- regular fetch() is now also a plugin, which opens a number of possibilities;
- any plugin that can locally cache requests and responses is now treated specially: the first such plugin is called after a successful content retrieval automagically;
- if content is retrieved from cache, Samizdat continues trying to get it from a "live" source (fetch(), Gun+IPFS) in the background.

This last bit was suggested by @tomasino and turned out to be simpler to implement than expected. So, yay!

To make a v1.0.0 that feels fully functional, we need to also:
- rewrite the SamizdatInfo (keeping the information on which resource was fetched and how) thing;
- add some fancy-shmancy UI displayed on any Samizdat-managed page;
- which will together allow us to inform the user "hey, we got this from cache, but there seems to be fresher version; reload please".

Okay people, riddle me this: in I have a and one or more browser window contexts (aka "clients) that might be using said ServiceWorker. I would like to pass some information between the two. Most importantly I would like to inform the relevant browser window that all the fetches that the ServiceWorker was handling on its behalf are done.

Here's the ticket for more context
git.occrp.org/libre/samizdat/i

Currently I am doing this by keeping the relevant information in Indexed DB. This has drawbacks:
- data is the same for all browser windows, leading to potential confusion if there is more than one tab open using the ServiceWorker
- there are no events to hook to catch when Indexed DB data changes, so it's down to setInterval() method, which is fugly.

I *could* use Client API, specifically `postMessage` with `FetchEvent.clientId`, but clientId is not implemented on Safari (both Desktop and Mobile):
developer.mozilla.org/en-US/do

I *could* use MessageChannel API, but it requires setting up a channel between browser window and the SW, and there's no way to track which channel is used for which browser window.

Plus, SW is quickly reaped, context destroyed, channel killed. On a new fetch() ServiceWorker restarts but the channel does not work, so a new channel would need to be set-up.

But that can only happen from the browser window side, whereas only the ServiceWorker knows a fetch() has started.

🐔 🥚

I *still* could decide to use MessageChannel API, but would need to:
- keep track in SW which fetch is from which referrer (not sure that's possible even; probably available in Request.Headers)
- keep track which channel is for which URL/referrer
- it would still get confusing if there are two tabs open with the same URP
- and I would still need to do polling in setInterval() on browser window side, kinda defeating the purpose of the channel.

So unless there is a way to hook an event in a browser window whenever a fetch() starts or when all fetch() events finish, MessageChannel API doesn't seem to be better than just using Indexed DB and polling it in setInterval() on a regularly.

And so it doesn't seem it makes sense to use MessageChannel API at all, since either it's not effective, or clientId gets implemented in Safari soon and we should move to that.

But if I'm to re-implement the Samizdatinfo on clientId now, I need a sane graceful degradation strategy for Safari.

But perhaps I am overthinking this? Perhaps the only event I need is onload. At that point I'll know already if the page is loaded from cache or not, and can display a relevant message to the user ("cache in use, try reloading"), perhaps after a sane timeout (letting the secondary fetch() in SW try to finish).

So perhaps that's my graceful degradation strategy for Safari (and whatever else doesn't support FetchEvent.clientId)? It will not be able to handle other resources (like iframes or whatnot) very effectively, but it'll be better than nothing. And probably better than what we have now anyway.

Proof-of-Concept of the new signalling system done without removing the old one.

Can anyone test on Safari please? Open a new tab, open the JS console, and navigate here:
cdn.test.occrp.org/projects/sa

Then, reload (so that the service worker kicks in); you should see "ServiceWorker: yes" in orange.

Make sure that you see this commit ID in the console and in both places at the page bottom: c223b08c

If all of this is true, check if in the console you have messages saying: "SamizdatInfo received!"

Done some serious work on . Fixed some bugs, almost finished implementing the new messaging system (based on client.postMessage() in the end), ripped the old Indexed DB-based system out completely. Introduced new bugs to fix next.

Merge request here:
git.occrp.org/libre/samizdat/m

Still work in progress though.

Merged! now uses message passing instead of Indexed DB for ServiceWorker to inform the window clients of things. I CAN HAZ nice things, liek:
- info that a resource was fetched from cache, but fetching it via Gun+IPFS is running in background;
- near-instant info on resources being fetched and status of that;
- info when all resources get initially fetched (in the future this is when "stuff fetched from cache, but newer versions available, reload please" message will be displayed).

The Merge Request of Doom:
git.occrp.org/libre/samizdat/m

Try here:
cdn.test.occrp.org/projects/sa

You might need to reload the service worker (refer to browser docs). Automagic reloading of the service worker code will come... one day, inshallah!

Also, probably doesn't work on Safari, because crapple refuses to implement things. Graceful degradation will come... one day, inshallah!

So I guess the roadmap to 1.0-beta would be something along the lines of:
- fix the issues (like caching plugin use is double-counted; when reloading soon after a load there is no indication how/where the resources were loaded from);
- implement the "stuff loaded from cache but newer content available, reload to see" message;
- cleanup the browser window / UI side of things so that it's easy to include on any site.

A *lot* of work, but hey, now at least we kinda have a roadmap!

Follow

Ok, back to playing with after some traveling.

- caching plugin not double-counted anymore;
- finally there is a proper project website at samizdat.is/

Need to fix Gun+IPFS for the new domain, today is a good time.

Main project home still git.occrp.org/libre/samizdat/ for the time being, but hoping to move it to a public GitLab instance soon.

Ok, we have the and Gun daemons deployed on the new server for , and content for samizdat.is/ pushed to IPFS and Gun.

That means now when you load the site in Firefox you should get the favicon. Favicon does not exist on the server, but exists in IPFS, for the purpose of testing all works.

In Chrome/Chromium it should show up after a reload or two (take your time though, Chrome/Chromium caches things in weird ways).

Oh boy, the CI/CD pipeline at 0xacab.org did not work because I did not enable it in project settings. ! 🤦‍♀️

But ow it works! So we have the first successful deploy of samizdat.is/ from its new git home:
0xacab.org/rysiek/samizdat/-/j

Woo! That means our migration of Samizdat is complete. It's on it's own domain, and on an open GitLab instance. 🎉 :pensive_party_blob: 🎈

One of the Big Issues I will have to solve before becomes really useful is measuring usage. I even have an issue for that!
0xacab.org/rysiek/samizdat/iss

tl;dr: there needs to be a way to measure how many times Samizdat made it possible to circumvent censorship.

That's something that will have to run on reader's browser, and so there are serious privacy considerations.

But without being able to show it works, it will be hard to convince people (and site admins) it does.

In the meantime, working on cache invalidation for . One of the Two Hard Problems in IT (cache invalidation, naming things, and off-by-one errors)!

Anyway, trying to keep some context in cache using "x-samizdat-*" headers. But the Cache API doesn't seem to cache all headers, just some:
0xacab.org/rysiek/samizdat/iss

Of course, there is no mention of it anywhere in the docs (or I have not found it after hours of looking).

*sigh*

I *think* I figured out how to do cache invalidation in in a more-or-less sane way, *assuming that* only a single live plugin is in use.

I might have an idea how to do it across plugins too.

Relevant branch here:
0xacab.org/rysiek/samizdat/tre

Boom! Cache (or, rather, locally stashed version) invalidation implemented in 0xacab.org/rysiek/samizdat/mer

From now on if you visit the site once load the current Service Worker, stuff gets stashed, and then when you happen to visit the site on a blocked connection, it is *assumed* Gun+IPFS version is fresher.

If you visit again, and have the Gun+IPFS version stashed, IPFS addresses are compared to check freshness.

If a fresh version is available, a message is displayed to the reader.

I have to figure out how would a demo page for this stash invalidation thing look.

In the meantime, CI/CD pipeline succeeded, and so stash invalidation is deployed to samizdat.is/

🎉

What's the difference between a "cached" and "stashed" resource in , you ask? Excellent question!

There can be multiple Samizdat plugins that implement the basic idea of keeping a version of a resource locally. One plugin currently implementing this is called "cache" and uses the Cache API:
0xacab.org/rysiek/samizdat/blo

So, to avoid confusion, whenever I'm talking in general about keeping versions locally, I will call it "stashing".

This will be made clear here: 0xacab.org/rysiek/samizdat/blo

Oh, did I already say there's a Beta milestone for now, too? Well, there is:
0xacab.org/rysiek/samizdat/-/m

A few more issues will be added soon. Including documentation. Yes, you heard that right! There's going to be some documentation, inshallah!

Worked on the documenation for a bit. Also, started working on implementing the standalone interface. MR: 0xacab.org/rysiek/samizdat/mer

The idea is to have the basic interface defined in samizdat.js so that all an admin needs to do is include that file. Currently the interface is tightly tied to index.html.

@rysiek looks great congratulations! (could use some css tweaks on iOS, its loads a bit too wide)

@liaizon thanks! Merge requests welcome. 😉

The bigger problem right now is that the service worker:
- doesn't work on Safari;
- doesn't work on mobile.

Safari is the hard problem, since it just does not implement certain things Samizdat uses.

Mobile in general (that is, Android mostly, since iOS == Safari) - that's something that used to work but I must have broken it somehow. Need to debug it.

Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!