Skip to content

Should @id of parent objects be used as a base IRI for relative IRI references? #447

@trwnh

Description

@trwnh

By my understanding, the way to absolutize a relative IRI reference in JSON-LD is currently something like this:

  • if the JsonLdProcessor has JsonLdOptions.base set, then use that.
  • otherwise, if the active context includes a @base declaration, then use that.
  • otherwise, if the document was fetched from a remote location, then the base IRI can be inferred by the IRI of the request.
    • if the response was HTML, then maybe <base> can be used?
  • otherwise, emit a warning?

However, there is a possibility for objects to be nested or embedded in other objects. Especially in non-flattened form.

I would interpret a document like so:

{
  "@context": [
    "https://www.w3.org/ns/did/v1",
    "https://w3id.org/security/multikey/v1",
    "https://w3id.org/security/suites/secp256k1-2019/v1"
  ],
  "alsoKnownAs": [
    "at://atproto.com"
  ],
  "id": "did:plc:ewvi7nxzyoun6zhxrhs64oiz",
  "service": [
    {
      "id": "#atproto_pds",  // this is a relative reference, right?
      "serviceEndpoint": "https://enoki.us-east.host.bsky.network",
      "type": "AtprotoPersonalDataServer"
    }
  ],
  "verificationMethod": [
    {
      "controller": "did:plc:ewvi7nxzyoun6zhxrhs64oiz",
      "id": "did:plc:ewvi7nxzyoun6zhxrhs64oiz#atproto",
      "publicKeyMultibase": "zQ3shunBKsXixLxKtC5qeSG9E4J5RkGN57im31pcTzbNQnm5w",
      "type": "Multikey"
    }
  ]
}

where it seems like the node with "id": "#atproto_pds" is part of its parent context, the node with "id": "did:plc:ewvi7nxzyoun6zhxrhs64oiz"... which I think represents the document?

So the question is: Should the @id of parent objects be considered in the expansion of relative IRI references? If not, why not? If yes, should we consider only the top-level parent or should we instead consider the most recent absolutized parent?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions