NRS links with request parameters

I was thinking how web apps on safe network could be used without having to copy/create/link the code files. This could be considered similar to, say, a command line app that can take different input to deliver different output.

From messing about with sequences and NRS maps, I can see that I can create a link to a URL with parameters. I was wondering whether these would be exposed to the browser or whether only special parameter (e.g. v=0) are extracted? So, in the example below, could I retrieve ‘test’ from ‘var1’ if I navigated to safe://sequence?

To explain my line of thought, it would be good to be able to load a web app from a starting point, such as a map containing properties. These could then configure the app, point to data sources, etc. This would seem like a neat way to bootstrap a web app with personalised properties, without having to touch a line of code - it could just be an NRS command.

Is this possible/feasible? I can’t remember how the browser used to handle this or whether NRS was even mature enough to test it. It would seem like a neat way to treat web apps as actual apps, rather than just clones/includes, etc.

Sample NRS:

paul@Vader:~$ safe dog safe://sequence --json
[
  "safe://sequence",
  [
    {
      "NrsMapContainer": {
        "public_name": "sequence",
        "xorurl": "safe://hyryygyaudepew9mccw4k37eowiz5t64cwg7inhdgcbu93atack7u3wudyyn7a",
        "xorname": [
          19,
          26,
          26,
          138,
          125,
          108,
          101,
          52,
          172,
          245,
          16,
          165,
          111,
          184,
          251,
          76,
          161,
          187,
          81,
          112,
          102,
          96,
          103,
          252,
          226,
          56,
          98,
          187,
          60,
          210,
          99,
          0
        ],
        "type_tag": 1500,
        "version": 0,
        "nrs_map": {
          "sub_names_map": {},
          "default": {
            "OtherRdf": {
              "created": "2021-03-05T14:59:02Z",
              "link": "safe://hyryyyy68crrax3qsp6ourp4q8th57rqdc9ys153w13rzc1buo6chfbxipcnmy?v=0&var1=test",
              "modified": "2021-03-05T14:59:02Z"
            }
          }
        },
        "data_type": "PublicSequence",
        "resolved_from": "safe://sequence"
      }
    },
    {
      "PublicSequence": {
        "xorurl": "safe://hyryyyy68crrax3qsp6ourp4q8th57rqdc9ys153w13rzc1buo6chfbxipcnmy?v=0&var1=test",
        "xorname": [
          199,
          97,
          9,
          135,
          229,
          214,
          111,
          161,
          50,
          55,
          78,
          60,
          121,
          190,
          145,
          195,
          103,
          193,
          105,
          111,
          52,
          150,
          73,
          118,
          72,
          51,
          135,
          153,
          194,
          133,
          245,
          107
        ],
        "type_tag": 1200,
        "version": 0,
        "data": [],
        "resolved_from": "safe://hyryyyy68crrax3qsp6ourp4q8th57rqdc9ys153w13rzc1buo6chfbxipcnmy?v=0&var1=test"
      }
    }
  ]
]

The query params should be handled by the app, like the browser, and pass it to the application, at least that’s how it works in normal browsers and apps, thus the answer to your question should be ‘Yes’.

If you have a link like the one you showed, I think we just need to make sure the browser retrieves not only the content from the Safe-URL resolver (fetch), but also the resolved URL, in your example the browser should be able to use the “resolved_from” field for that purpose:

2 Likes

I’m thinking that the fetch itself would need to use the resolved_from field, so that any version information is processed accordingly. Perhaps there would also need to be an override, if the NRS URL also provided (say) v=1 or some such too?

Given we can’t do this sort of think using DNS on clear net (as it is just a host/IP resolver), I’m assuming the browser will need to retrieve the request parameters from resolved_from and pass them into the application/document context within the browser? Again, any overrides would need to be considered as above. Then it would be just like navigating directly to the resolved_from with the request parameters included.

I’m wondering whether there are downsides to this approach, but it would seem like a great way to just use web apps as ‘tools’ against the data specified. So, you could specify a ‘blog’ tool and then point it at your configuration map, which provides ‘posts’ list for a data source, etc.

Obviously, folks may want to use a more traditional approach of uploading a page to do the same, but I’m digging the idea that it isn’t necessary.

Yes, good point, except for the actual v which shouldn’t perhaps be overridden as it’s to fetch the version, the rest perhaps can be overridden, but I think again it’s up to the app, in this case the browser may/should ignore any query param found in resolved_from that is being overridden by the original URL the user entered.

1 Like