Home Reference Source Test
public class | source

GraphConnector

The Graph Connector contains the contact list/address book.

Constructor Summary

Public Constructor
public

constructor(hypertyRuntimeURL: string, messageBus: messageBus, storageManager: storageManager)

Constructs a new and empty Graph Connector.

Member Summary

Public Members
public

contacts: *[]

public
public
public
public

groups: *[]

public
public
public get

Returns the MessageBus.

public set

messageBus(messageBus: MessageBus): *

Sets the MessageBus.

public
public
public

Method Summary

Public Methods
public

addContact(guid: string, firstName: string, lastName: string): boolean

Add a contact to the Graph Connector.

public

addGroupName(guid: string, groupName: string): boolean

Adds a group to a contact identified by a GUID.

public

Adds a Legacy ID for the user.

public

Adds a UserID for the user.

public

Calculates the Bloom filter containing all non-private contacts.

public

checkGUID(guid: string): array

Checks, if the given GUID is known and returns a list of contacs that are direct connections as well as a list of contacts that (most likely) know the given contact.

public

editContact(guidOld: string, firstName: string, lastName: string, guidNew: string, privStatus: boolean): array

Edit the values for a specific contact.

public

extend(obj1: Object, obj2: Object): Object

Type cast one object to another equivalent to "$.extend" of jquery

public

Generates a GUID and returns a mnemonic from which the GUID can be re-created later.

public

getAllContacts(): array

Returns all the contacts, excluding the owner.

public

getContact(name: string): array

Returns the list of contacts which matches the search string "name".

public

getContactUserIDs(guid: string): array

Returns ArrayList of userIDs of a contact, if contact not found then it will return a string 'Contact Does not exist'

public

Returns the globalRegistryRecord for the owner.

public

getGroup(groupName: string): array

Returns all contacts with a given group name, including the owner if applicable.

public

getGroupNames(): array

Returns all unique group names.

public

To return the owner.

public

To check whether the GUID already exist.

public

Queries the Global Registry for a given GUID.

public

Removes a contact from the Graph Connector.

public

removeGroupName(guid: string, groupName: string): boolean

Removes a group for a contact, identified by a GUID.

public

removeLegacyID(type: string, category: string, description: string, id: string): boolean

Removes a LegacyID for the user.

public

Removes a location for a user identified by a given GUID.

public

Removes a UserID for the user.

public

Takes the Global Registry Record as a signed JWT and sends it to the Global Registry via the MessageBus.

public

setActive(int: int): boolean

Sets active attribute of the GlobalRegistryRecord.

public

Sets the bloomfilter of a contact.

public

setContactUserIDs(guid: string, uid: string, domain: string): boolean

Returns success if the userID is successfully added for a contact

public

setDefaults(voice: string, chat: string, video: string): boolean

set User Defaults.

public

setLocation(guid: string, locationName: string): boolean

Adds a location for a user identified by a given GUID.

public

setOwnerName(fname: string, lname: string): boolean

Sets the first name and last name of the owner.

public

setRevoked(int: int): boolean

Sets revoked attribute of the GlobalRegistryRecord.

public

setTimeout(Timeout: Date): boolean

Sets Timeout attribute of the GlobalRegistryRecord.

public

SignGenerates a public/private key pair from a given mnemonic.

public

store the entry into the storage Manager for the given keys: globalRegistryRecord, contacts, groups.

public

updateContactInfo(guid: string, firstName: string, lastName: string): boolean

Add a contact to the Graph Connector.

public

useGUID(mnemonicAndSalt: string): Promise

Generates a public/private key pair from a given mnemonic (16 words).

Public Constructors

public constructor(hypertyRuntimeURL: string, messageBus: messageBus, storageManager: storageManager) source

Constructs a new and empty Graph Connector.

Params:

NameTypeAttributeDescription
hypertyRuntimeURL string

The Hyperty Runtime URL.

messageBus messageBus

The Message Bus.

storageManager storageManager

the storage Manager.

Public Members

public contacts: *[] source

public contactsBloomFilter1Hop: * source

public firstName: string source

public globalRegistryRecord: * source

public groups: *[] source

public lastCalculationBloomFilter1Hop: * source

public lastName: string source

public get messageBus: * source

Returns the MessageBus.

public set messageBus(messageBus: MessageBus): * source

Sets the MessageBus.

public privateKey: * source

public residenceLocation: string source

public storageManager: * source

Public Methods

public addContact(guid: string, firstName: string, lastName: string): boolean source

Add a contact to the Graph Connector.

Params:

NameTypeAttributeDescription
guid string

GUID of the new contact.

firstName string

First name of the new contact.

lastName string

Last name of the new contact.

Return:

boolean

returns True if the Contact is successfully added, false otherwise.

public addGroupName(guid: string, groupName: string): boolean source

Adds a group to a contact identified by a GUID.

Params:

NameTypeAttributeDescription
guid string

GUID of the contact.

groupName string

Group Name to be added to the contact.

Return:

boolean

Success if the group name is successfully added.

public addLegacyID(): boolean source

Adds a Legacy ID for the user.

Params:

NameTypeAttributeDescription
type. string
category. string
description. string
id. string

Return:

boolean

returns false if the ID exists and the Legacy ID will not be added, true otherwise.

public addUserID(): boolean source

Adds a UserID for the user.

Params:

NameTypeAttributeDescription
uid. string
domain. string

Return:

boolean

returns false if the userID exists and the user ID will not be added, true otherwise.

public calculateBloomFilter1Hop() source

Calculates the Bloom filter containing all non-private contacts.

public checkGUID(guid: string): array source

Checks, if the given GUID is known and returns a list of contacs that are direct connections as well as a list of contacts that (most likely) know the given contact.

Params:

NameTypeAttributeDescription
guid string

GUID of the contact to look for.

Return:

array

relatedContacts List of related direct contacts and of related friends-of-friends contacts.The format is: RelatedContacts<Direct<GraphConnectorContactData>,FoF<GraphConnectorContactData>>.

public editContact(guidOld: string, firstName: string, lastName: string, guidNew: string, privStatus: boolean): array source

Edit the values for a specific contact.

Params:

NameTypeAttributeDescription
guidOld string

GUID to identify the contact to edit.

firstName string

First name of the contact.

lastName string

Last name of the contact.

guidNew string

New guid of the contact.

privStatus boolean

Boolean value to set the private status of the contact.

Return:

array

Returns the array which contains the contact with new values

public extend(obj1: Object, obj2: Object): Object source

Type cast one object to another equivalent to "$.extend" of jquery

Params:

NameTypeAttributeDescription
obj1 Object

Object to which the other object need to be typecasted.

obj2 Object

Object needs to typecasted.

Return:

Object

Obj2 with typecasted to obj1.

public generateGUID(): string source

Generates a GUID and returns a mnemonic from which the GUID can be re-created later.

Return:

string

mnemonic A string with 16 words.

public getAllContacts(): array source

Returns all the contacts, excluding the owner.

Return:

array

All the contacts. The format is: Contacts<GraphConnectorContactData>.

public getContact(name: string): array source

Returns the list of contacts which matches the search string "name". Ex. "Joh" will return users with first or last name "John" or "Aljohanas".

Params:

NameTypeAttributeDescription
name string

First or last name to look for in the contact list.

Return:

array

matchingContacts Contacts matching the given name. The format is: Contacts<GraphConnectorContactData>.

public getContactUserIDs(guid: string): array source

Returns ArrayList of userIDs of a contact, if contact not found then it will return a string 'Contact Does not exist'

Params:

NameTypeAttributeDescription
guid string

guid of the contact whose userID has to be added.

Return:

array

success returns Arraylist of userID of a contact, if contact not found then it will return a string 'Contact Does not exist'

public getGlobalRegistryRecord(): object source

Returns the globalRegistryRecord for the owner.

Return:

object

public getGroup(groupName: string): array source

Returns all contacts with a given group name, including the owner if applicable.

Params:

NameTypeAttributeDescription
groupName string

Name of the group to return.

Return:

array

matchingContacts Contacts matching the given group name. The format is: Contacts<GraphConnectorContactData>.

public getGroupNames(): array source

Returns all unique group names.

Return:

array

Array containing all unique group names.

public getOwner(): GraphConnectorContactData source

To return the owner.

Return:

GraphConnectorContactData

Returns the owner.

public guidExist(guid: string): boolean source

To check whether the GUID already exist.

Params:

NameTypeAttributeDescription
guid string

GUID which needs to be checked.

Return:

boolean

Returns true if the GUID exist

public queryGlobalRegistry(guid: string): Promise source

Queries the Global Registry for a given GUID. Adds the UserID information from the Global Registry to a contact, if the given GUID matches a user in the contacts. Returns a Graph Connector Contact Data as a Promise.

Params:

NameTypeAttributeDescription
guid string

The GUID to query the Global Registry for

Return:

Promise

Promise Graph Connector Contact Data containing UserIDs.

public removeContact(guid: string): boolean source

Removes a contact from the Graph Connector.

Params:

NameTypeAttributeDescription
guid string

GUID of the user to be removed.

Return:

boolean

Success if the Contact is successfully removed.

public removeGroupName(guid: string, groupName: string): boolean source

Removes a group for a contact, identified by a GUID.

Params:

NameTypeAttributeDescription
guid string

GUID of the contact.

groupName string

Group name to be removed for the contact.

Return:

boolean

Success if the group name is successfully removed.

public removeLegacyID(type: string, category: string, description: string, id: string): boolean source

Removes a LegacyID for the user.

Params:

NameTypeAttributeDescription
type string
category string
description string
id string

Return:

boolean

true if the LegacyID exists and deleted, false otherwise.

public removeLocation(guid: string): boolean source

Removes a location for a user identified by a given GUID.

Params:

NameTypeAttributeDescription
guid string

GUID of the contact.

Return:

boolean

True if the Location is successfully removed, false otherwise.

public removeUserID(): boolean source

Removes a UserID for the user.

Params:

NameTypeAttributeDescription
uid. string
domain. string

Return:

boolean

true if the userID exists and deleted, false otherwise.

public sendGlobalRegistryRecord(jwt: string): Propmise source

Takes the Global Registry Record as a signed JWT and sends it to the Global Registry via the MessageBus. Returns the response code of the REST-interface of the Global Registry as a Promise.

Params:

NameTypeAttributeDescription
jwt string

The Global Registry Record as a signed JWT.

Return:

Propmise

Promise Response Code from Global Registry.

public setActive(int: int): boolean source

Sets active attribute of the GlobalRegistryRecord.

Params:

NameTypeAttributeDescription
int int

Value to set the active flag of the GlobalRegistryRecord to.

Return:

boolean

True if Active is succesfully set, false otherwise.

public setBloomFilter1HopContact(guid: string, bf: BloomFilter): boolean source

Sets the bloomfilter of a contact.

Params:

NameTypeAttributeDescription
guid string

GUID of the contact to set the bloom filter.

bf BloomFilter

BloomFilter object.

Return:

boolean

success if the contact guid is found and the bloom filter is set

public setContactUserIDs(guid: string, uid: string, domain: string): boolean source

Returns success if the userID is successfully added for a contact

Params:

NameTypeAttributeDescription
guid string

guid of the contact whose userID has to be added.

uid string

userID which is supposed to be added.

domain string

domain which is supposed to be added.

Return:

boolean

success returns true if userID is successfully added to the contact.

public setDefaults(voice: string, chat: string, video: string): boolean source

set User Defaults.

Params:

NameTypeAttributeDescription
voice string
chat string
video string

Return:

boolean

returns True if the Defaults are successfully added, false otherwise.

public setLocation(guid: string, locationName: string): boolean source

Adds a location for a user identified by a given GUID.

Params:

NameTypeAttributeDescription
guid string

GUID of the contact.

locationName string

location of the contact

Return:

boolean

Success if the Location is successfully added

public setOwnerName(fname: string, lname: string): boolean source

Sets the first name and last name of the owner.

Params:

NameTypeAttributeDescription
fname string

The owner's first name.

lname string

The owner's last name.

Return:

boolean

Returns true if the owner name is successfully added.

public setRevoked(int: int): boolean source

Sets revoked attribute of the GlobalRegistryRecord.

Params:

NameTypeAttributeDescription
int int

Value to set the revoked flag of the GlobalRegistryRecord to.

Return:

boolean

True if Revoked is succesfully set, false otherwise.

public setTimeout(Timeout: Date): boolean source

Sets Timeout attribute of the GlobalRegistryRecord.

Params:

NameTypeAttributeDescription
Timeout Date

Date to set the timeout of the GlobalRegistryRecord to.

Return:

boolean

True if Timeout is succesfully set, false otherwise.

public signGlobalRegistryRecord(): string source

SignGenerates a public/private key pair from a given mnemonic.

Return:

string

JWT JSON Web Token ready to commit to Global Registry.

public storeGraphConnector() source

store the entry into the storage Manager for the given keys: globalRegistryRecord, contacts, groups.

public updateContactInfo(guid: string, firstName: string, lastName: string): boolean source

Add a contact to the Graph Connector.

Params:

NameTypeAttributeDescription
guid string

GUID of the new contact.

firstName string

First name of the new contact.

lastName string

Last name of the new contact.

Return:

boolean

returns True if the Contact is successfully added, false otherwise.

public useGUID(mnemonicAndSalt: string): Promise source

Generates a public/private key pair from a given mnemonic (16 words). Expects a string containing 16 words seperated by single spaces. Retrieves data from the Global Registry.

Params:

NameTypeAttributeDescription
mnemonicAndSalt string

A string of 16 words.

Return:

Promise

Promise Global Registry Record.