Skip to content

Commit

Permalink
Improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
SphaeraFintech committed Apr 5, 2020
1 parent f2ea8da commit bbe01f9
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 65 deletions.
20 changes: 10 additions & 10 deletions src/Apostille.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ export class Apostille {

/**
* Create an Apostille
* @param {string} filename Name of the file (with extension)
* @param {string} fileContent Content of the file (as Base64)
* @param {string} tags Tags for the file
* @param {string} description Description for the file
* @param {string} url Url for the file
* @param {string} privateKey Private key of owner
* @param {NetworkType} network Network type
* @return {Apostille} An Apostille
* @param {string} filename - Name of the file (with extension)
* @param {string} fileContent - Content of the file (as Base64)
* @param {string} tags - Tags for the file
* @param {string} description - Description for the file
* @param {string} url - Url for the file
* @param {string} privateKey - Private key of owner
* @param {NetworkType} network - Network type
* @return {Apostille} - An Apostille
*/
public static create(filename: string, fileContent: string, tags: string, description: string, url: string, privateKey: string, network: NetworkType): Apostille {
const owner = Account.createFromPrivateKey(privateKey, network);
Expand All @@ -61,8 +61,8 @@ export class Apostille {

/**
* Update an Apostille
* @param {Metadata[]} metadata Dedicated account's metadata
* @return {boolean} True if success, false otherwise
* @param {Metadata[]} metadata - Dedicated account's metadata
* @return {boolean} - True if success, false otherwise
*/
public update(metadata: Metadata[]): boolean {
const m = ApostilleMetadata.create(metadata);
Expand Down
8 changes: 4 additions & 4 deletions src/ApostilleAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export class ApostilleAccount {
/**
* Generate an Apostille account for a file.
* Will always generate the same account for a given file name and owner private key
* @param {string} privateKey Private key of owner
* @param {string} filename File name (with extension)
* @param {NetworkType} network Network type
* @return {Account} Apostille Account
* @param {string} privateKey - Private key of owner
* @param {string} filename - File name (with extension)
* @param {NetworkType} network - Network type
* @return {Account} - Apostille Account
*/
public static create(privateKey: string, filename: string, network: NetworkType): Account {
const owner = Account.createFromPrivateKey(privateKey, network);
Expand Down
10 changes: 5 additions & 5 deletions src/ApostilleHash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export class ApostilleHash {

/**
* Hash the file content and sign it
* @param {string} data File content (as Base64)
* @param {string} privateKey Private key of owner
* @param {NetworkType} network Network type
* @param {string} data - File content (as Base64)
* @param {string} privateKey - Private key of owner
* @param {NetworkType} network - Network type
* @return {ApostilleHash}
*/
public static create(data: string, privateKey: string, network: NetworkType): ApostilleHash {
Expand All @@ -39,8 +39,8 @@ export class ApostilleHash {

/**
* Hash the file content with SHA256
* @param {string} data File content (Base64)
* @return {string} SHA256 hash of the file content
* @param {string} data - File content (Base64)
* @return {string} - SHA256 hash of the file content
*/
public static hash(data: string): string {
const rawContent = CryptoJS.enc.Base64.parse(data);
Expand Down
12 changes: 6 additions & 6 deletions src/ApostilleHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export class ApostilleHistory {

/**
* Create an history account used for indexing Apostilles
* @param {string} privateKey Private key of owner
* @param {NetworkType} network Network type
* @return {Account} History Account
* @param {string} privateKey - Private key of owner
* @param {NetworkType} network - Network type
* @return {Account} - History Account
*/
public static create(privateKey: string, network: NetworkType): Account {
const owner = Account.createFromPrivateKey(privateKey, network);
Expand All @@ -38,9 +38,9 @@ export class ApostilleHistory {

/**
* Create a metadata transaction for recording history account address in owner's account metadata
* @param {PublicAccount} owner PublicAccount of owner
* @param {PublicAccount} history PublicAccount of history
* @param {NetworkType} network Network type
* @param {PublicAccount} owner - PublicAccount of owner
* @param {PublicAccount} history - PublicAccount of history
* @param {NetworkType} network - Network type
* @return {InnerTransaction}
*/
public static metadataTransaction(owner: PublicAccount, history: PublicAccount, network: NetworkType): InnerTransaction {
Expand Down
4 changes: 2 additions & 2 deletions src/ApostilleMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export class ApostilleMetadata {

/**
* Isolate Apostille related metadata from dedicated account's metadata
* @param {Metadata[]} metadata Dedicated account's metadata
* @return {ApostilleMetadata} Apostille metadata
* @param {Metadata[]} metadata - Dedicated account's metadata
* @return {ApostilleMetadata} - Apostille metadata
*/
public static create(metadata: Metadata[]): ApostilleMetadata {
const name = ApostilleUtils.findMetadataByKey(metadata, metadataKey.name);
Expand Down
16 changes: 8 additions & 8 deletions src/ApostilleTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class ApostilleTransactions {

/**
* Create base transactions for the Apostille
* @param {Apostille} apostille An Apostille
* @param {Apostille} apostille - An Apostille
* @return {InnerTransaction[]}
*/
public static create(apostille: Apostille): InnerTransaction[] {
Expand All @@ -50,10 +50,10 @@ export class ApostilleTransactions {

/**
* Create an AccountMetadataTransaction
* @param {Apostille} apostille An Apostille
* @param {string} metadataKey Metadata hex key
* @param {string} oldVal Old metadata value
* @param {string} newVal New metadata value
* @param {Apostille} apostille - An Apostille
* @param {string} metadataKey - Metadata hex key
* @param {string} oldVal - Old metadata value
* @param {string} newVal - New metadata value
* @return {InnerTransaction}
*/
public static metadata(apostille: Apostille, metadataKey: string, oldVal: string, newVal: string): InnerTransaction {
Expand All @@ -71,7 +71,7 @@ export class ApostilleTransactions {

/**
* Assign ownership of a dedicated account
* @param {Apostille} apostille An Apostille
* @param {Apostille} apostille - An Apostille
* @return {InnerTransaction}
*/
public static ownership(apostille: Apostille): InnerTransaction {
Expand All @@ -80,7 +80,7 @@ export class ApostilleTransactions {

/**
* Create a core transfer transaction
* @param {Apostille} apostille An Apostille
* @param {Apostille} apostille - An Apostille
* @return {InnerTransaction}
*/
public static core(apostille: Apostille): InnerTransaction {
Expand All @@ -94,7 +94,7 @@ export class ApostilleTransactions {

/**
* Create an history transfer transaction
* @param {Apostille} apostille An Apostille
* @param {Apostille} apostille - An Apostille
* @return {InnerTransaction}
*/
public static history(apostille: Apostille): InnerTransaction {
Expand Down
38 changes: 19 additions & 19 deletions src/ApostilleUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ApostilleUtils {
/**
* Create a short date as yyyy-mm-dd
* @param {Date} date
* @return {string} Date as yyyy-mm-dd
* @return {string} - Date as yyyy-mm-dd
*/
public static toShortDate(date: Date): string {
let dd: number | string = date.getDate();
Expand All @@ -35,26 +35,26 @@ export class ApostilleUtils {

/**
* Get the extension of a file
* @param {string} filename
* @return {string} File extension
* @param {string} filename - Name of the file
* @return {string} - File extension
*/
public static getExtension(filename: string): string {
return "." + filename.split('.').slice(1).pop() || "";
}

/**
* Remove the extension of a file
* @param {string} filename
* @return {string} File name without extension
* @param {string} filename - Name of the file
* @return {string} - File name without extension
*/
public static removeExtension(filename: string): string {
return filename.replace(/\.[^/.]+$/, "");
};

/**
* Extract all signers required from an array of Apostilles
* @param {Apostilles[]} apostilles Apostille array
* @return {Account[]} An array of signers Accounts
* @param {Apostilles[]} apostilles - Apostille array
* @return {Account[]} - An array of signers Accounts
*/
public static extractSigners(apostilles: Apostille[]): Account[] {
let signers = [];
Expand All @@ -69,8 +69,8 @@ export class ApostilleUtils {

/**
* Extract all transactions from an array of Apostilles
* @param {Apostilles[]} apostilles Apostille array
* @return {InnerTransaction[]} An array of inner transactions
* @param {Apostilles[]} apostilles - Apostille array
* @return {InnerTransaction[]} - An array of inner transactions
*/
public static extractTransactions(apostilles: Apostille[]): InnerTransaction[] {
let txes = [];
Expand All @@ -82,9 +82,9 @@ export class ApostilleUtils {

/**
* Return the MetadataEntry corresponding to a given key from an array of Metadata
* @param {Metadata[]} metadata Metadata array
* @param {string} key Metadata key
* @return {MetadataEntry} MetadataEntry or undefined
* @param {Metadata[]} metadata - Metadata array
* @param {string} key - Metadata key
* @return {MetadataEntry} - MetadataEntry or undefined
*/
public static findMetadataByKey(metadata: Metadata[], key: string): MetadataEntry {
const meta = metadata.find(meta => meta.metadataEntry.scopedMetadataKey.toHex().toLocaleLowerCase() === key);
Expand All @@ -93,9 +93,9 @@ export class ApostilleUtils {

/**
* Check if two metadata values are identical
* @param {string} firstValue A value
* @param {string} secondValue A value
* @return {boolean} True if identical, false otherwise
* @param {string} firstValue - A value
* @param {string} secondValue - A value
* @return {boolean} - True if identical, false otherwise
*/
public static isIdentical(firstValue: string, secondValue: string): boolean {
if (firstValue === secondValue) return true;
Expand All @@ -104,8 +104,8 @@ export class ApostilleUtils {

/**
* Extract dedicated account from file name in Apostille format
* @param {string} filename File name in Apostille format (Ex: "MyProject - TBLJAVZXTDY3EXNVC5IMEYZN35OPHAQK5GOQXWPH - 2020-01-29.txt")
* @return {Address} Dedicated account or undefined
* @param {string} filename - File name in Apostille format (Ex: "MyProject - TBLJAVZXTDY3EXNVC5IMEYZN35OPHAQK5GOQXWPH - 2020-01-29.txt")
* @return {Address} - Dedicated account or undefined
*/
public static extractDedicatedFromName(filename: string): Address {
const arr = filename.split(" ");
Expand All @@ -119,8 +119,8 @@ export class ApostilleUtils {

/**
* Retrieve original file name from file name in Apostille format
* @param {string} filename File name in Apostille format (Ex: "MyProject - TBLJAVZXTDY3EXNVC5IMEYZN35OPHAQK5GOQXWPH - 2020-01-29.txt")
* @return {string} Original file name with extension
* @param {string} filename - File name in Apostille format (Ex: "MyProject - TBLJAVZXTDY3EXNVC5IMEYZN35OPHAQK5GOQXWPH - 2020-01-29.txt")
* @return {string} - Original file name with extension
*/
public static getOriginalFilename(filename: string): string {
const arr = filename.split(" ");
Expand Down
16 changes: 8 additions & 8 deletions src/ApostilleVerification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export class ApostilleVerification {

/**
* Verify an Apostille
* @param {string} filename Name of the file in Apostille format (Ex: "MyProject - TBLJAVZXTDY3EXNVC5IMEYZN35OPHAQK5GOQXWPH - 2020-01-29.txt")
* @param {string} data File content (as Base64)
* @param {Metadata[]} metadata Dedicated account's metadata
* @param {string} filename - Name of the file in Apostille format (Ex: "MyProject - TBLJAVZXTDY3EXNVC5IMEYZN35OPHAQK5GOQXWPH - 2020-01-29.txt")
* @param {string} data - File content (as Base64)
* @param {Metadata[]} metadata - Dedicated account's metadata
* @return {ApostilleVerificationResult}
*/
public static verify(filename: string, data: string, metadata: Metadata[]): ApostilleVerificationResult {
Expand All @@ -41,11 +41,11 @@ export class ApostilleVerification {

/**
* Verify an Apostille hash signature
* @param {string} publicKey Public key of owner
* @param {string} data File content (as Base64)
* @param {string} hash Apostille hash
* @param {NetworkType} network Network type
* @return {boolean} True if hash signature is valid, false otherwise
* @param {string} publicKey - Public key of owner
* @param {string} data - File content (as Base64)
* @param {string} hash - Apostille hash
* @param {NetworkType} network - Network type
* @return {boolean} - True if hash signature is valid, false otherwise
*/
public static verifyHash(publicKey: string, data: string, hash: string, network: NetworkType): boolean {
const owner = PublicAccount.createFromPublicKey(publicKey, network);
Expand Down
6 changes: 3 additions & 3 deletions src/ApostilleVerificationResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export class ApostilleVerificationResult {

/**
* Create an object containing the Apostille verification result
* @param {number} code Result code
* @param {boolean} result Verification result
* @param {ApostilleMetadata} metadata Apostille metadata (optional)
* @param {number} code - Result code
* @param {boolean} result - Verification result
* @param {ApostilleMetadata} metadata - Apostille metadata (optional)
* @return {ApostilleVerificationResult}
*/
public static create(code: number, result: boolean, metadata: ApostilleMetadata = undefined): ApostilleVerificationResult {
Expand Down

0 comments on commit bbe01f9

Please sign in to comment.