WebID

WebID

Experimental WebID Emulation on top of a MutableData internally using RDF emulation

Instantiate the WebID emulation layer wrapping a MutableData instance, while making use of the RDF emulation to manipulate the MD entries

Constructor

new WebID(mData)

Parameters:
Name Type Description
mData MutableData

the MutableData to wrap around

Source:

Methods

(async) create(profile, nick) → {Promise}

Creates WebId as RDF data and commits to underlying MutableData

Parameters:
Name Type Description
profile Object
nick String

profile.nick

Source:
Example
// Assumes MutableData interface has been obtained
const profile = {
    nick: "safedev",
    name: "SAFENetwork Developer",
    uri: "safe://id.safedev"
};
const asyncFn = async () => {
  try {
      const webid = await mData.emulateAs('WebId');
      await webid.create(profile, profile.nick);
  } catch(err) {
      throw err;
  }
};

(async) fetchContent() → {Promise}

Fetches committed WebId data from underlying MutableData and loads in graph store

Source:
Example
// Assumes MutableData interface has been obtained
const asyncFn = async () => {
  try {
      const webid = await mData.emulateAs('WebId');
      await webid.fetchContent();
  } catch(err) {
      throw err;
  }
};

init()

Initialises WebID interface by emulating underlying MutableData as RDF and sets common namespace prefixes on instance

Source:

(async) serialise(profile) → {Promise.<String>}

Serialises WebId RDF data

Parameters:
Name Type Description
profile Object
Source:
Example
// Assumes MutableData interface has been obtained
const mimeType = "text/turtle";
const profile = {
    nick: "safedev",
    name: "SAFENetwork Developer",
    uri: "safe://id.safedev"
};
const asyncFn = async () => {
  try {
      const webid = await mData.emulateAs('WebId');
      await webid.create(profile, profile.nick);
      const serialised = await webid.serialise(mimeType);
  } catch(err) {
      throw err;
  }
};

(async) update(profile) → {Promise}

Updates WebId as RDF data and commits to underlying MutableData

Parameters:
Name Type Description
profile Object
Source:
Example
// Assumes MutableData interface has been obtained
const profile = {
    nick: "safedev",
    name: "SAFENetwork Developer",
    uri: "safe://id.safedev"
};
const asyncFn = async () => {
  try {
      const webid = await mData.emulateAs('WebId');
      await webid.create(profile, profile.nick);
      let updatedProfile = Object.assign({}, profile, { name: "Alexander Fleming" });
      await webid.update(profile);
  } catch(err) {
      throw err;
  }
};