https://deno.land/ is a secure runtime for typescript... it supports loading of modules from URLs...
For example:
import { serve } from "https://deno.land/[email protected]/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
for await (const req of s) {
req.respond({ body: "Hello World\n" });
}
I have written a tiny did:github http resolver in it, that is capable of resolving both did documents and typescript modules... here is what the import syntax looks like:
import { getHelloWorld } from "http://localhost:8000/did:github:OR13/dndx/master/mod.ts";
const helloWorld = getHelloWorld();
console.log(helloWorld); // Prints "Hello World" in bold
My question is: What is the best way to represent "did:github:OR13/dndx/master/mod.ts" using service endpoints and did parameters?
I'm not sure I fully understand, but you could have a service endpoint in your DID document that points to your Github org:
{
"@context": "https://www.w3.org/ns/did/v1",
"id": "did:example:123456789abcdefghi",
"authentication": [{
"id": "did:example:123456789abcdefghi#keys-1",
"type": "Ed25519VerificationKey2018",
"controller": "did:example:123456789abcdefghi",
"publicKeyBase58": "H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV"
}],
"service": [{
"id":"did:example:123456789abcdefghi#github",
"serviceEndpoint": "https://github.com/OR13/"
}]
}
And then you could construct a DID URL like this:
did:example:123456789abcdefghi?service=github&relativeRef=dndx/master/mod.ts
Which would dereference to this service endpoint URL:
https://github.com/OR13/dndx/master/mod.ts
This would be method-independent, i.e. you don't have to use Github DIDs.
@peacekeeper thats exactly what I was looking for! I was just confused because of all the changes to did params
Confirmed this to be working, given the way DID Parameters are defined, DID URIs can be used to represent software packages, and through DID dereferencing, they can be used for deno and other languages... no modification is needed.
Most helpful comment
I'm not sure I fully understand, but you could have a service endpoint in your DID document that points to your Github org:
And then you could construct a DID URL like this:
did:example:123456789abcdefghi?service=github&relativeRef=dndx/master/mod.tsWhich would dereference to this service endpoint URL:
https://github.com/OR13/dndx/master/mod.tsThis would be method-independent, i.e. you don't have to use Github DIDs.