From 8f06754880e74f6433fc6a84c566bb4088fdab00 Mon Sep 17 00:00:00 2001 From: Bill Barman Date: Fri, 23 Nov 2018 09:19:38 +0800 Subject: [PATCH] more docs --- src/libDDO/Authentication.ts | 15 +++++++++++++++ src/libDDO/DDO.ts | 1 + src/libDDO/Proof.ts | 16 ++++++++++++++++ src/libDDO/PublicKey.ts | 20 +++++++++++++++++++- src/libDDO/Service.ts | 17 ++++++++++++++++- 5 files changed, 67 insertions(+), 2 deletions(-) diff --git a/src/libDDO/Authentication.ts b/src/libDDO/Authentication.ts index 6ec61fe..6722dd5 100644 --- a/src/libDDO/Authentication.ts +++ b/src/libDDO/Authentication.ts @@ -1,3 +1,8 @@ +/* + * Class to provide DDO Authentication + * + * + */ import PublicKey from "./PublicKey" @@ -25,6 +30,11 @@ export default class Authentication { this.type = data.type } + /* + * Convert this authentication object to data for exporting + * + * :return IAuthentication data type + */ public toData(): IAuthentication { const data: IAuthentication = { type: this.type, @@ -36,6 +46,11 @@ export default class Authentication { return data } + /* + * validate the sturcture of this object + * + * :return ture if the authentiacion object is valid + */ public isValid(): boolean { return this.publicKeyId && this.publicKeyId.length > 0 && this.type.length && this.type.length > 0 } diff --git a/src/libDDO/DDO.ts b/src/libDDO/DDO.ts index c618f46..496a8d1 100644 --- a/src/libDDO/DDO.ts +++ b/src/libDDO/DDO.ts @@ -3,6 +3,7 @@ * DDO Library to parse, create and validate DDO JSON data * */ + import Authentication from "./Authentication" import Proof from "./Proof" import PublicKey from "./PublicKey" diff --git a/src/libDDO/Proof.ts b/src/libDDO/Proof.ts index df0445f..b35afa2 100644 --- a/src/libDDO/Proof.ts +++ b/src/libDDO/Proof.ts @@ -1,3 +1,10 @@ +/* + * + * Proof class + * + * + */ + interface IProof { created?: string creator?: string @@ -19,6 +26,9 @@ export default class Proof { this.signatureValue = data.signatureValue } + /* + * Return data for a proof + */ public toData(): IProof { return { created: this.created, @@ -28,6 +38,12 @@ export default class Proof { } as IProof } + /* + * check to see if this proof object is valid, only check the consistancy + * of the object, this does not check the proof signatue + * + * :return true if the proof object is valid and complete + */ public isValid(): boolean { return this.created && this.created.length > 0 && this.creator && this.creator.length > 0 diff --git a/src/libDDO/PublicKey.ts b/src/libDDO/PublicKey.ts index e1dc8a4..98c8fc6 100644 --- a/src/libDDO/PublicKey.ts +++ b/src/libDDO/PublicKey.ts @@ -1,4 +1,7 @@ - +/* + * Class to provide access to the DDO public key + * + */ interface IPublicKey { id?: string owner?: string @@ -37,6 +40,11 @@ export default class PublicKey { } } + /* + * Convert this object to a IPublicKey data type + * + * :return IPublicKey data type + */ public toData(): IPublicKey { return { id: this.id, @@ -46,6 +54,11 @@ export default class PublicKey { } as IPublicKey } + /* + * Validate the structure of this object + * + * :return true if this object data is valid + */ public isValid(): boolean { return this.id && this.id.length > 0 && this.owner && this.owner.length > 0 @@ -53,6 +66,11 @@ export default class PublicKey { && this.value && this.value.length > 0 } + /* + * Decode the public key storage into binary format + * + * :return binary format of the public key + */ public decodeValue(): string { let value = this.value let buffer = null diff --git a/src/libDDO/Service.ts b/src/libDDO/Service.ts index 9c022a8..696f0cf 100644 --- a/src/libDDO/Service.ts +++ b/src/libDDO/Service.ts @@ -1,4 +1,9 @@ - +/* + * + * Servic class to provide access to the DDO service + * + * + */ interface IService { id?: string serviceEndpoint?: string @@ -25,6 +30,11 @@ export default class Service { delete dataRef.type } + /* + * convert this object to data + * + * :return IService data type + */ public toData(): IService { let data: IService = { id: this.id, @@ -37,6 +47,11 @@ export default class Service { return data as IService } + /* + * Validate the structure of this object's data + * + * :return true if the data is valid + */ public isValid(): boolean { return this.id && this.id.length > 0 && this.endpoint && this.endpoint.length > 0