mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
more docs
This commit is contained in:
parent
50d6a7e1d9
commit
8f06754880
@ -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
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user