From 93f72a5ee87e26d9cfb09db6e7e396dc0a40af13 Mon Sep 17 00:00:00 2001 From: Alan Grainger Date: Fri, 7 Feb 2025 15:22:02 +0800 Subject: [PATCH] Update docs --- app/src/encrypt.ts | 10 ++++++++-- app/src/immich.ts | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/encrypt.ts b/app/src/encrypt.ts index 3cc092c..a212d9d 100644 --- a/app/src/encrypt.ts +++ b/app/src/encrypt.ts @@ -1,7 +1,7 @@ import crypto from 'crypto' interface EncryptedPayload { - iv: string; + iv: string; // Initialization Vector (IV) cr: string; // Encrypted data } @@ -9,6 +9,9 @@ interface EncryptedPayload { const key = crypto.randomBytes(32) const algorithm = 'aes-256-cbc' +/** + * Encrypt text data for storing in the session cookie + */ export function encrypt (text: string): EncryptedPayload { try { const ivBuf = crypto.randomBytes(16) @@ -27,7 +30,10 @@ export function encrypt (text: string): EncryptedPayload { } } -export function decrypt (payload: EncryptedPayload) { +/** + * Decrypt data which was stored in the session cookie + */ +export function decrypt (payload: EncryptedPayload): string { try { const decipher = crypto.createDecipheriv(algorithm, Buffer.from(key), Buffer.from(payload.iv, 'hex')) let decrypted = decipher.update(payload.cr, 'hex', 'utf8') diff --git a/app/src/immich.ts b/app/src/immich.ts index 78587a1..c8d21bb 100644 --- a/app/src/immich.ts +++ b/app/src/immich.ts @@ -25,6 +25,7 @@ class Immich { } } catch (e) { log('Unable to reach Immich on ' + process.env.IMMICH_URL) + log(`From the server IPP is running on, see if you can curl to ${this.apiUrl()}/server/ping and receive a JSON result.`) } }