How to restrict access to fields for anonymous users?

Hello,

I would like to allow anonymous users to access a collection through the Realm Web SDK but to restrict some fields of that collection. Until now, I have only been able to give full access to all fields to anonymous users. I can’t manage to find a proper “Apply When” rule that matches anonymous users. I’m also very surprised there is no way to test data access rules in Realm even though I have seen such feature in other tools like Firebase.

Here’s what I have tried until now but doesn’t work :

    {
          "name": "anonymous",
          "apply_when": {
            "%%user.identities": {
              "providerType": "anon-user"
            }
          },
          "insert": false,
          "delete": false,
          "search": true,
          "fields": {
            "username": {
              "read": true
            }
          },
          "additional_fields": {}
        }

I would really appreciate your help.