added NAS configuration file; updated MediaViewer to support thumbnail carousel; improved error handling in NASAPI and NASAUTH; refactored various comments for clarity

This commit is contained in:
bobbert committed 2026-02-22 19:19:55 +00:00
1 parent 9519b32d68
commit f8e11fc368
27 files changed
+1036 -558

No files matched your search

+7 -15
View File
@@ -1,24 +1,19 @@
import * as Crypto from 'expo-crypto';
/**
* Credential Encryption Service
*
* Uses expo-crypto for password hashing (SHA-256)
* Uses base64 encoding for storing account data objects in the database
* Handles password hashing (SHA-256) and base64 encoding of account data objects
*/
class CredentialEncryption {
/**
* Hash a password using SHA-256 via expo-crypto
* Returns a hex digest string
* Hash a password with SHA-256 and return a hex digest
*/
async hashPassword(password) {
try {
if (!password) throw new Error('Password is required');
const digest = await Crypto.digestStringAsync(
return await Crypto.digestStringAsync(
Crypto.CryptoDigestAlgorithm.SHA256,
password
);
return digest;
} catch (error) {
console.error('Password hashing error:', error);
throw new Error('Failed to hash password: ' + error.message);
@@ -26,7 +21,7 @@ class CredentialEncryption {
}
/**
* Verify a password against a stored hash
* Compare a plaintext password against a stored hash
*/
async verifyPassword(password, storedHash) {
try {
@@ -39,15 +34,13 @@ class CredentialEncryption {
}
/**
* Encrypt an object for database storage (base64-encoded JSON)
* Encode an object as a base64 JSON string for database storage
*/
encrypt(data) {
try {
if (!data) throw new Error('No data provided to encrypt');
const jsonString = JSON.stringify(data);
// btoa is available in React Native / Hermes
const encoded = btoa(unescape(encodeURIComponent(jsonString)));
return encoded;
return btoa(unescape(encodeURIComponent(jsonString)));
} catch (error) {
console.error('Encryption error:', error);
throw new Error('Failed to encrypt data: ' + error.message);
@@ -55,7 +48,7 @@ class CredentialEncryption {
}
/**
* Decrypt a base64-encoded JSON string back to an object
* Decode a base64 JSON string back to an object
*/
decrypt(encryptedData) {
try {
@@ -70,4 +63,3 @@ class CredentialEncryption {
}
export default new CredentialEncryption();