API Docs for: 1.3.12
Show:

EcRemoteLinkedData Class

Data wrapper to represent remotely hosted data. Includes necessary KBAC fields for permission controls, signing, identifying and locating the object.

Methods

addOwner

(
  • newOwner
)

Adds an owner to the object, if the owner does not exist. Note that this method invalidates all signatures.

Parameters:

  • newOwner EcPk

    PK of the new owner.

addReader

(
  • newReader
)

Adds a reader to the object, if the reader does not exist. Note that this method invalidates all signatures.

Parameters:

  • newReader EcPk

    PK of the new reader.

assignId

(
  • server
  • uniqueIdentifier
)

Will generate an identifier using the server URL provided (usually from an EcRepository) and unique identifier.

Parameters:

  • server String

    Base URL of the server's repository functionality.

  • uniqueIdentifier String

    Canonical identifier. Must contain a letter or symbol.

assignId

(
  • server
  • uniqueIdentifier
)

Will generate an identifier using the server URL provided (usually from an EcRepository) and unique identifier.

Parameters:

  • server String

    Base URL of the server's repository functionality.

  • uniqueIdentifier String

    Canonical identifier. Must contain a letter or symbol.

assignId

(
  • server
  • uniqueIdentifier
)

Will generate an identifier using the server URL provided (usually from an EcRepository) and unique identifier.

Parameters:

  • server String

    Base URL of the server's repository functionality.

  • uniqueIdentifier String

    Canonical identifier. Must contain a letter or symbol.

atIfy

() Object
Forces Javascript to encode the object in alphabetical order in order to make signature based actions more viable. Also places @(at) symbols in front of appropriate fields.

Returns:

Object: Serializable JSON object.

canEdit

(
  • pk
)
Boolean

Determines if the PK matches an owner or if the object is public. Homogenizes the PEM strings for comparison. Homogenization is necessary for comparing PKCS#1 and PKCS#8 or PKs with Certificates, etc.

Parameters:

  • pk EcPk

    Public Key of the owner.

Returns:

Boolean:

True if owner is represented by the PK, false otherwise.

canEdit

(
  • pk
)
Boolean

Determines if the PK matches an owner or if the object is public. Homogenizes the PEM strings for comparison. Homogenization is necessary for comparing PKCS#1 and PKCS#8 or PKs with Certificates, etc.

Parameters:

  • pk EcPk

    Public Key of the owner.

Returns:

Boolean:

True if owner is represented by the PK, false otherwise.

copyFrom

(
  • that
)
Also could be called "upcast", for those in the know.

Ghetto method of copying properties from some other object. As freshly deserialized javascript objects do not inherently attach the functions of their type, it is this or factory hell.

Parameters:

  • that Object
    The freshly deserialized object, or the object to upcast into this object.

deAtify

() EcLinkedData
Removes the @ symbol from properties in order to make them more accessible in Javascript.

Returns:

EcLinkedData: This object, with @ properties converted to @-less properties.

generateId

(
  • server
)

Will generate an identifier using the server URL provided (usually from an EcRepository).

Parameters:

  • server String

    Base URL of the server's repository functionality.

generateShortId

(
  • server
)

Will generate an short (non-versioned) identifier using the server URL provided (usually from an EcRepository).

Parameters:

  • server String

    Base URL of the server's repository functionality.

getFullType

() String
Gets the fully qualified type name, as JSON-LD allows the "namespace" of the type to be defined in @context.

Returns:

String: Fully qualified type name.

getGuid

() String

Return the GUID portion of the short ID.

Returns:

String:

Guid of the linked data object.

getSearchStringByType

() String

Return a valid ElasticSearch search string that will retrieve all objects with this type.

Returns:

String:

ElasticSearch compatible search string.

getServerBaseUrl

() String

Return the URL Base portion of the short ID.

Returns:

String:

Server Base URL of the linked data object.

getTimestamp

()

Returns the ID timestamp of the object, for versioning purposes.

getTypes

() String
Gets all versions of JSON-LD type strings for this type of object.

Returns:

String: Array of URIs.

hasOwner

(
  • pk
)
Boolean

Determines if the object has a reader identified by pk. Homogenizes the PEM strings for comparison. Homogenization is necessary for comparing PKCS#1 and PKCS#8 or PKs with Certificates, etc.

Parameters:

  • pk EcPk

    Public Key of the owner.

Returns:

Boolean:

True if owner is represented by the PK, false otherwise.

hasOwner

(
  • pk
)
Boolean

Determines if the object has an owner identified by pk. Homogenizes the PEM strings for comparison. Homogenization is necessary for comparing PKCS#1 and PKCS#8 or PKs with Certificates, etc.

Parameters:

  • pk EcPk

    Public Key of the owner.

Returns:

Boolean:

True if owner is represented by the PK, false otherwise.

invalid

() Boolean

Determines if the object is not retrievable from a repository should it be written.

Returns:

Boolean:

True if the object is NOT VALID for storage, false otherwise.

isA

(
  • type
)
Boolean
Uses the object's fully qualified type name and compares it to the provided type.

Parameters:

  • type String
    Fully qualified type name uri.

Returns:

Boolean: True if match, False if not.

isAny

(
  • type
)
Boolean
Uses the object's fully qualified type name and compares it to the provided type.

Parameters:

  • type String
    Fully qualified type name uris.

Returns:

Boolean: True if match, False if not.

isId

(
  • id
)
Boolean

Returns true if the provided ID represents this object. Use this, as version information can make direct comparison difficult.

Parameters:

  • id String

Returns:

Boolean:

True if the provided ID represents this object.

removeOwner

(
  • oldOwner
)

Removes an owner from the object, if the owner does exist. Note that this method invalidates all signatures.

Parameters:

  • oldOwner EcPk

    PK to remove.

removeReader

(
  • oldReader
)

Removes a reader from the object, if the reader does exist. Note that this method invalidates all signatures.

Parameters:

  • oldReader EcPk

    PK of the old reader.

setContextAndType

(
  • context
  • type
)
Set the JSON-LD @context and @type.

Parameters:

  • context String
    JSON-LD Context.
  • type String
    JSON-LD Type.

shortId

() String

Return the ID of this object without the version information. Used to reference the latest version of an object.

Returns:

String:

ID of the latest version of this object.

signWith

(
  • ppk
)

Sign this object using a private key. Does not check for ownership, objects signed with keys absent from owner or reader may be removed.

Parameters:

  • ppk EcPpk

    Public private keypair.

toJson

() String
Serializes this object to JSON.

Returns:

String: JSON formatted object (with JSON-LD fields).

toSignableJson

()

Encodes the object in a form where it is ready to be signed. This method is under long term review, and may change from version to version.

Returns:

ASCII-sort order encoded space-free and tab-free JSON-LD.

trimVersionFromUrl

(
  • id
)
static

Removes the version information from an identifier. Warning: Will remove identifier if the identifier is composed solely of digits!!!

Parameters:

  • id String

    Slash delimited URL or path.

Returns:

ID without version.

updateTimestamp

()

Updates the ID timestamp of the object, for versioning purposes.

upgrade

()

Upgrades the object to the latest version, performing transforms and the like.

verify

() Boolean

Verifies the object's signatures.

Returns:

Boolean:

true if all of the signatures could be verified, false if they could not

Properties

context

String
JSON-LD @context field.

id

String (URL)

URL/URI used to retrieve, store and identify the object.

owner

String (PEM)

PEM encoded public keys of the owner of the object. A repository, upon receiving a write operation, will ensure either the data did not previously exist, or that an owner has provided a signature authorizing the replacement of the old data with the new data.

reader

String (PEM)

PEM encoded public keys of identities authorized to view the object. A repository will ignore write operations from these identities, but will allow them to read the object.

signature

String (Base64)

Signatures of the object. The signing method is as follows: Remove the signature field. Encode the object and its fields in ascii-sort order JSON-LD using a space-free, tab-free encoding. Sign the aforementioned string.

type

String
JSON-LD @type field.