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