Global

Members

# async authenticate

This function checks if the password is correct

View Source password.ts, line 104

Example
auth('public/OSI-password.png', 'password', 'database/passwords.json');

# blacklisted

This function checks if a file is blacklisted

View Source blacklist.ts, line 4

# async buildSecureObject

This function builds an object with the path, the hash and the salt

View Source password.ts, line 25

Example
buildSecureObject('public/OSI-password.png', 'password');

# async changePassword

This function changes the password on a secure file

View Source password.ts, line 83

Example
changePassword('public/OSI-password.png', 'password', 'database/passwords.json');

# constant db

This constant is the path to the database
Default Value:
  • __dirname + '/../database/passwords.json'

View Source password.ts, line 8

Example
const db = __dirname + '/../database/passwords.json';

# async deleteSecureFile

This function deletes a secure file from the database

View Source password.ts, line 63

Example
deleteSecureFile('public/OSI-password.png', 'database/passwords.json');

# makeSalt

This function generates a random salt

View Source password.ts, line 16

Example
makeSalt();

# async newSecureFile

This function adds a new secure file to the database

View Source password.ts, line 42

Example
newSecureFile('public/OSI-password.png', 'password', false, 'database/passwords.json');

# async readJSON

Read JSON files

View Source jsonWorker.ts, line 3

Example
const data = await readJSON<SecureObjects>("example.json");

# serveFile

This function serves a file from the database

View Source serveFile.ts, line 8

Example
serveFile(fastify, 'public/OSI-password.png', true);

# constant server

This constant is the Fastify server

View Source server.ts, line 10

# async writeJSON

Write JSON files (Blanks them)

View Source jsonWorker.ts, line 13

Example
await writeJSON("example.json", { hello: "world" });

Methods

# async authenticate(file, password, dbpopt)

This function checks if the password is correct
Parameters:
Name Type Attributes Default Description
file The path to the file
password The password to check
dbp <optional>
db The path to the database

View Source password.ts, line 182

True if the password is correct, false otherwise
Example
auth('public/OSI-password.png', 'password', 'database/passwords.json');

# blacklisted(path)

This function checks if a file is blacklisted
Parameters:
Name Type Description
path The path to the file

View Source blacklist.ts, line 30

If the file is blacklisted

# async buildSecureObject(file, password)

This function builds an object with the path, the hash and the salt
Parameters:
Name Type Description
file The path to the file
password The password to hash

View Source password.ts, line 137

The object with the path, the hash and the salt
Example
buildSecureObject('public/OSI-password.png', 'password');

# async changePassword(file, password, dbpopt) → {Promise.<void>}

This function changes the password on a secure file
Parameters:
Name Type Attributes Default Description
file The path to the file
password The new password
dbp <optional>
db The path to the database

View Source password.ts, line 170

If the file doesn't exist
Error
Promise.<void>
Example
changePassword('public/OSI-password.png', 'password', 'database/passwords.json');

# async deleteSecureFile(file, dbpopt) → {Promise.<void>}

This function deletes a secure file from the database
Parameters:
Name Type Attributes Default Description
file The path to the file
dbp <optional>
db The path to the database

View Source password.ts, line 159

If the file doesn't exist
Error
Promise.<void>
Example
deleteSecureFile('public/OSI-password.png', 'database/passwords.json');

# makeSalt()

This function generates a random salt

View Source password.ts, line 130

The salt
Example
makeSalt();

# async newSecureFile(file, password, dbpopt) → {Promise.<void>}

This function adds a new secure file to the database
Parameters:
Name Type Attributes Default Description
file The path to the file
password The password to hash
dbp <optional>
db The path to the database

View Source password.ts, line 147

If the file already exists
Error
Promise.<void>
Example
newSecureFile('public/OSI-password.png', 'password', false, 'database/passwords.json');

# async readJSON(path) → {Promise.<T>}

Read JSON files
Parameters:
Name Type Description
path The path to the JSON file

View Source jsonWorker.ts, line 26

Promise.<T>
Example
const data = await readJSON<SecureObjects>("example.json");

# serveFile(fastifyInstance, path, securedopt) → {Promise.<void>}

This function serves a file from the database
Parameters:
Name Type Attributes Default Description
fastifyInstance The Fastify Instance
path The path to the file
secured <optional>
false If the file is secured

View Source serveFile.ts, line 58

Promise.<void>
Example
serveFile(fastify, 'public/OSI-password.png', true);

# async start()

Start Fastify server

View Source server.ts, line 41

# async writeJSON(path, data) → {Promise.<void>}

Write JSON files (Blanks them)
Parameters:
Name Type Description
path The path to the JSON file
data The JSON object

View Source jsonWorker.ts, line 35

Promise.<void>
Example
await writeJSON("example.json", { hello: "world" });