90dc-core 1.19.6 → 1.19.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/clients/ImagesClient.d.ts +2 -0
- package/dist/lib/clients/ImagesClient.d.ts.map +1 -1
- package/dist/lib/clients/ImagesClient.js +128 -20
- package/dist/lib/clients/ImagesClient.js.map +1 -1
- package/dist/lib/clients/types/images.types.d.ts +1 -0
- package/dist/lib/clients/types/images.types.d.ts.map +1 -1
- package/dist/lib/clients/types/images.types.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,6 +19,8 @@ export declare class ImagesClient {
|
|
|
19
19
|
updateProgressPhotoDate(input: t.UpdateProgressPhotoDateInput): Promise<t.UserProgressPhotoRecord | null>;
|
|
20
20
|
deleteProgressPhoto(uuid: string, userUuid: string): Promise<boolean>;
|
|
21
21
|
private migrateLegacyPhotosForUser;
|
|
22
|
+
private getSignedUrl;
|
|
23
|
+
private decryptLegacyImage;
|
|
22
24
|
private base64ToBuffer;
|
|
23
25
|
private handleError;
|
|
24
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImagesClient.d.ts","sourceRoot":"","sources":["../../../src/lib/clients/ImagesClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ImagesClient.d.ts","sourceRoot":"","sources":["../../../src/lib/clients/ImagesClient.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,KAAK,CAAC,MAAM,yBAAyB,CAAC;AAalD,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAA6C;IAC3D,OAAO,CAAC,GAAG,CAAgB;gBAEf,MAAM,EAAE,CAAC,CAAC,MAAM;IAa5B,OAAO,CAAC,aAAa;IA4CR,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IActD,QAAQ,CAAC,IAAI,EAAE,MA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kB;IAwB1B,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,WAAW;CAOpB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import admin from "firebase-admin";
|
|
2
2
|
import { v4 as uuidv4 } from "uuid";
|
|
3
|
+
import { readFileSync } from "fs";
|
|
4
|
+
import { createDecipheriv } from "crypto";
|
|
3
5
|
import { ExternalAPIError } from "../Errors/AppError.js";
|
|
4
6
|
import { Log } from "../utils/Logger.js";
|
|
5
7
|
import { validateBase64Image } from "../utils/imageValidation.js";
|
|
@@ -17,7 +19,7 @@ const RECIPE_PHOTO_TYPES = [
|
|
|
17
19
|
];
|
|
18
20
|
const imageName = {
|
|
19
21
|
avatar: (userUuid)=>`${userUuid}--avatar.png`,
|
|
20
|
-
progress: (userUuid, day, programId)
|
|
22
|
+
progress: (userUuid, day, programId)=>`progress/${userUuid}--${day}day--${programId}.png`,
|
|
21
23
|
recipe: (recipeUuid, type)=>`${recipeUuid}--${type}.png`
|
|
22
24
|
};
|
|
23
25
|
export class ImagesClient {
|
|
@@ -46,8 +48,7 @@ export class ImagesClient {
|
|
|
46
48
|
const serviceAccountPath = process.env.FIREBASE_SERVICE_ACCOUNT_KEY;
|
|
47
49
|
if (serviceAccountPath) {
|
|
48
50
|
// Local development with service account file
|
|
49
|
-
const
|
|
50
|
-
const serviceAccount = JSON.parse(fs.readFileSync(serviceAccountPath, "utf-8"));
|
|
51
|
+
const serviceAccount = JSON.parse(readFileSync(serviceAccountPath, "utf-8"));
|
|
51
52
|
admin.initializeApp({
|
|
52
53
|
credential: admin.credential.cert(serviceAccount),
|
|
53
54
|
storageBucket
|
|
@@ -227,9 +228,19 @@ export class ImagesClient {
|
|
|
227
228
|
'updatedAt'
|
|
228
229
|
]
|
|
229
230
|
});
|
|
230
|
-
|
|
231
|
+
// Generate signed URLs for migrated records
|
|
232
|
+
const withUrls = await Promise.all(migratedRecords.map(async (record)=>({
|
|
233
|
+
...record,
|
|
234
|
+
url: await this.getSignedUrl(record.firebasePath)
|
|
235
|
+
})));
|
|
236
|
+
return withUrls;
|
|
231
237
|
}
|
|
232
|
-
|
|
238
|
+
// Generate signed URLs for all records
|
|
239
|
+
const withUrls = await Promise.all(records.map(async (record)=>({
|
|
240
|
+
...record,
|
|
241
|
+
url: await this.getSignedUrl(record.firebasePath)
|
|
242
|
+
})));
|
|
243
|
+
return withUrls;
|
|
233
244
|
}
|
|
234
245
|
async getProgressPhotosByProgram(programId, userUuid) {
|
|
235
246
|
const records = await UserProgressPhoto.findAll({
|
|
@@ -282,9 +293,19 @@ export class ImagesClient {
|
|
|
282
293
|
'updatedAt'
|
|
283
294
|
]
|
|
284
295
|
});
|
|
285
|
-
|
|
296
|
+
// Generate signed URLs
|
|
297
|
+
const withUrls = await Promise.all(migratedRecords.map(async (record)=>({
|
|
298
|
+
...record,
|
|
299
|
+
url: await this.getSignedUrl(record.firebasePath)
|
|
300
|
+
})));
|
|
301
|
+
return withUrls;
|
|
286
302
|
}
|
|
287
|
-
|
|
303
|
+
// Generate signed URLs for all records
|
|
304
|
+
const withUrls = await Promise.all(records.map(async (record)=>({
|
|
305
|
+
...record,
|
|
306
|
+
url: await this.getSignedUrl(record.firebasePath)
|
|
307
|
+
})));
|
|
308
|
+
return withUrls;
|
|
288
309
|
}
|
|
289
310
|
async updateProgressPhotoDate(input) {
|
|
290
311
|
const [affectedRows] = await UserProgressPhoto.update({
|
|
@@ -340,30 +361,48 @@ export class ImagesClient {
|
|
|
340
361
|
this.logger.info("Starting legacy photo migration", {
|
|
341
362
|
userUuid
|
|
342
363
|
});
|
|
343
|
-
// List all files in the legacy
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
364
|
+
// List all files in the legacy /progress folder with pattern: progress/{userUuid}--{day}day--{programId}.png
|
|
365
|
+
let files;
|
|
366
|
+
try {
|
|
367
|
+
[files] = await this.bucket.getFiles({
|
|
368
|
+
prefix: `progress/${userUuid}--`
|
|
369
|
+
});
|
|
370
|
+
} catch (authError) {
|
|
371
|
+
this.logger.error("Firebase authentication failed during migration, skipping", {
|
|
372
|
+
userUuid,
|
|
373
|
+
error: authError instanceof Error ? authError.message : String(authError)
|
|
374
|
+
});
|
|
375
|
+
return; // Skip migration if auth fails
|
|
376
|
+
}
|
|
347
377
|
if (files.length === 0) {
|
|
348
378
|
this.logger.info("No legacy photos found for user", {
|
|
349
379
|
userUuid
|
|
350
380
|
});
|
|
351
381
|
return;
|
|
352
382
|
}
|
|
353
|
-
|
|
354
|
-
|
|
383
|
+
let migratedCount = 0;
|
|
384
|
+
let skippedCount = 0;
|
|
355
385
|
for (const file of files){
|
|
356
386
|
const fileName = file.name;
|
|
357
|
-
// Parse legacy filename: {userUuid}--{day}day--{programId}.png
|
|
358
|
-
const match = fileName.match(/^(.+)--(\d+)day--(.+)\.png$/);
|
|
387
|
+
// Parse legacy filename: progress/{userUuid}--{day}day--{programId}.png
|
|
388
|
+
const match = fileName.match(/^progress\/(.+)--(\d+)day--(.+)\.png$/);
|
|
359
389
|
if (!match) {
|
|
360
390
|
this.logger.warn("Skipping file with unexpected name format", {
|
|
361
391
|
fileName
|
|
362
392
|
});
|
|
363
393
|
continue;
|
|
364
394
|
}
|
|
365
|
-
const [, , dayStr, programId] = match;
|
|
395
|
+
const [, fileUserUuid, dayStr, programId] = match;
|
|
366
396
|
const day = parseInt(dayStr, 10);
|
|
397
|
+
// Verify this file belongs to the user
|
|
398
|
+
if (fileUserUuid !== userUuid) {
|
|
399
|
+
this.logger.warn("File doesn't belong to this user, skipping", {
|
|
400
|
+
fileName,
|
|
401
|
+
userUuid,
|
|
402
|
+
fileUserUuid
|
|
403
|
+
});
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
367
406
|
// Check if this photo was already migrated (by programId + userUuid + approximate day)
|
|
368
407
|
const existing = await UserProgressPhoto.findOne({
|
|
369
408
|
where: {
|
|
@@ -378,8 +417,20 @@ export class ImagesClient {
|
|
|
378
417
|
});
|
|
379
418
|
continue;
|
|
380
419
|
}
|
|
381
|
-
// Download the legacy photo
|
|
382
|
-
const [
|
|
420
|
+
// Download the legacy photo (encrypted in storage)
|
|
421
|
+
const [encryptedContents] = await file.download();
|
|
422
|
+
// Decrypt the legacy photo
|
|
423
|
+
let decryptedBuffer;
|
|
424
|
+
try {
|
|
425
|
+
decryptedBuffer = this.decryptLegacyImage(encryptedContents);
|
|
426
|
+
} catch (decryptError) {
|
|
427
|
+
this.logger.error("Failed to decrypt legacy photo, skipping", {
|
|
428
|
+
fileName,
|
|
429
|
+
decryptError
|
|
430
|
+
});
|
|
431
|
+
skippedCount++;
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
383
434
|
// Calculate photoDate based on day offset (we don't have program start date, so use upload time)
|
|
384
435
|
// In reality, this would need Program model to calculate exact date
|
|
385
436
|
const photoDate = new Date(); // Fallback: use current time
|
|
@@ -387,12 +438,13 @@ export class ImagesClient {
|
|
|
387
438
|
// Generate new UUID and path
|
|
388
439
|
const newUuid = uuidv4();
|
|
389
440
|
const newFirebasePath = `progress-pictures/${userUuid}/${newUuid}.png`;
|
|
390
|
-
//
|
|
391
|
-
await this.bucket.file(newFirebasePath).save(
|
|
441
|
+
// Save decrypted (plain) image to new Firebase location
|
|
442
|
+
await this.bucket.file(newFirebasePath).save(decryptedBuffer, {
|
|
392
443
|
metadata: {
|
|
393
444
|
contentType: "image/png"
|
|
394
445
|
}
|
|
395
446
|
});
|
|
447
|
+
migratedCount++;
|
|
396
448
|
// Create database record
|
|
397
449
|
await UserProgressPhoto.create({
|
|
398
450
|
uuid: newUuid,
|
|
@@ -421,6 +473,62 @@ export class ImagesClient {
|
|
|
421
473
|
// Don't throw - migration failure shouldn't break the request
|
|
422
474
|
}
|
|
423
475
|
}
|
|
476
|
+
async getSignedUrl(firebasePath) {
|
|
477
|
+
try {
|
|
478
|
+
const file = this.bucket.file(firebasePath);
|
|
479
|
+
// Check if file exists first
|
|
480
|
+
const [exists] = await file.exists();
|
|
481
|
+
if (!exists) {
|
|
482
|
+
this.logger.warn("File not found for signed URL generation", {
|
|
483
|
+
firebasePath
|
|
484
|
+
});
|
|
485
|
+
return undefined;
|
|
486
|
+
}
|
|
487
|
+
// Generate signed URL with proper expiration date
|
|
488
|
+
const expirationDate = new Date();
|
|
489
|
+
expirationDate.setDate(expirationDate.getDate() + 7); // 7 days from now
|
|
490
|
+
const [url] = await file.getSignedUrl({
|
|
491
|
+
action: "read",
|
|
492
|
+
expires: expirationDate
|
|
493
|
+
});
|
|
494
|
+
this.logger.debug("Generated signed URL", {
|
|
495
|
+
firebasePath
|
|
496
|
+
});
|
|
497
|
+
return url;
|
|
498
|
+
} catch (error) {
|
|
499
|
+
this.logger.error("Failed to generate signed URL", {
|
|
500
|
+
firebasePath,
|
|
501
|
+
error: error instanceof Error ? error.message : String(error),
|
|
502
|
+
errorDetails: error
|
|
503
|
+
});
|
|
504
|
+
return undefined;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
decryptLegacyImage(encryptedBuffer) {
|
|
508
|
+
try {
|
|
509
|
+
const encryptionKey = process.env.ENCRYPTION_KEY;
|
|
510
|
+
if (!encryptionKey) {
|
|
511
|
+
throw new Error("ENCRYPTION_KEY not found in environment");
|
|
512
|
+
}
|
|
513
|
+
// Extract IV from first 16 bytes
|
|
514
|
+
const iv = encryptedBuffer.slice(0, 16);
|
|
515
|
+
const encryptedData = encryptedBuffer.slice(16);
|
|
516
|
+
// Decrypt using AES-256-CBC
|
|
517
|
+
const decipher = createDecipheriv("aes-256-cbc", Buffer.from(encryptionKey), iv);
|
|
518
|
+
const decryptedData = Buffer.concat([
|
|
519
|
+
decipher.update(encryptedData),
|
|
520
|
+
decipher.final()
|
|
521
|
+
]);
|
|
522
|
+
// Old implementation adds extra prefix, remove it (20 bytes)
|
|
523
|
+
// Original: "data:image/jpeg;base64," + decryptedImageData.toString('base64').slice(20, ...)
|
|
524
|
+
return decryptedData.slice(20);
|
|
525
|
+
} catch (error) {
|
|
526
|
+
this.logger.error("Failed to decrypt legacy image", {
|
|
527
|
+
error
|
|
528
|
+
});
|
|
529
|
+
throw new Error("Image decryption failed");
|
|
530
|
+
}
|
|
531
|
+
}
|
|
424
532
|
base64ToBuffer(base64) {
|
|
425
533
|
const data = base64.includes(",") ? base64.split(",")[1] : base64;
|
|
426
534
|
return Buffer.from(data, "base64");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/clients/ImagesClient.ts"],"sourcesContent":["import admin from \"firebase-admin\";\nimport { Bucket } from \"@google-cloud/storage\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { ExternalAPIError } from \"../Errors/AppError.js\";\nimport { Log } from \"../utils/Logger.js\";\nimport { validateBase64Image } from \"../utils/imageValidation.js\";\nimport { UserProgressPhoto } from \"../dbmodels/user/UserProgressPhoto.js\";\nimport type * as t from \"./types/images.types.js\";\n\nconst PROGRESS_DAYS = [1, 30, 60, 90];\n\ntype RecipePhotoType = \"ingredients\" | \"cover\" | \"method\";\nconst RECIPE_PHOTO_TYPES: RecipePhotoType[] = [\"ingredients\", \"cover\", \"method\"];\n\nconst imageName = {\n avatar: (userUuid: string) => `${userUuid}--avatar.png`,\n progress: (userUuid: string, day: number, programId: string) => `${userUuid}--${day}day--${programId}.png`,\n recipe: (recipeUuid: string, type: RecipePhotoType) => `${recipeUuid}--${type}.png`,\n};\n\nexport class ImagesClient {\n private bucket: Bucket;\n private logger = Log.getInstance().extend(\"images-client\");\n private app: admin.app.App;\n\n constructor(config: t.Config) {\n if (config.firebaseApp) {\n // Use provided Firebase app\n this.app = config.firebaseApp;\n } else {\n // Initialize Firebase if needed (following FirebasePushNotificationClient pattern)\n this.initializeApp(config.storageBucket);\n this.app = admin.app();\n }\n\n this.bucket = this.app.storage().bucket(config.storageBucket);\n }\n\n private initializeApp(storageBucket: string): void {\n try {\n // Check if app already exists\n if (admin.apps?.length && admin.apps.length > 0) {\n this.logger.info(\"Using existing Firebase app\");\n return;\n }\n\n // Try to load service account from environment (for local development)\n const serviceAccountPath = process.env.FIREBASE_SERVICE_ACCOUNT_KEY;\n\n if (serviceAccountPath) {\n // Local development with service account file\n const fs = require(\"fs\");\n const serviceAccount = JSON.parse(fs.readFileSync(serviceAccountPath, \"utf-8\"));\n\n admin.initializeApp({\n credential: admin.credential.cert(serviceAccount),\n storageBucket,\n });\n\n this.logger.info(\"Firebase initialized with service account file\", {\n projectId: serviceAccount.project_id,\n storageBucket,\n });\n } else {\n // Production: use application default credentials\n admin.initializeApp({\n credential: admin.credential.applicationDefault(),\n storageBucket,\n });\n\n this.logger.info(\"Firebase initialized with application default credentials\", {\n storageBucket,\n });\n }\n } catch (error) {\n this.logger.error(\"Failed to initialize Firebase Admin SDK\", { error });\n throw new ExternalAPIError(\n \"Failed to initialize Firebase\",\n `Error: ${String(error)}`\n );\n }\n }\n\n public async saveImage(base64: string, name: string): Promise<void> {\n try {\n this.logger.info(\"Saving image\", { name });\n\n const buffer = this.base64ToBuffer(base64);\n const file = this.bucket.file(name);\n await file.save(buffer, { contentType: \"image/png\" });\n\n this.logger.info(\"Image saved successfully\", { name });\n } catch (error) {\n this.handleError(error, \"saveImage\");\n }\n }\n\n public async getImage(name: string): Promise<string | undefined> {\n try {\n this.logger.info(\"Getting image\", { name });\n\n const file = this.bucket.file(name);\n const [exists] = await file.exists();\n if (!exists) {\n return undefined;\n }\n\n const [contents] = await file.download();\n return \"data:image/jpeg;base64,\" + contents.toString(\"base64\");\n } catch (error) {\n this.logger.error(`Failed to get image: ${name}`, { error });\n return undefined;\n }\n }\n\n public async saveAvatar(userUuid: string, base64: string): Promise<void> {\n await this.saveImage(base64, imageName.avatar(userUuid));\n }\n\n public async getAvatar(userUuid: string): Promise<string | undefined> {\n return this.getImage(imageName.avatar(userUuid));\n }\n\n public async saveProgressPhoto(userUuid: string, day: number, programId: string, base64: string): Promise<void> {\n await this.saveImage(base64, imageName.progress(userUuid, day, programId));\n }\n\n public async getProgressPhotos(userUuid: string, programId: string): Promise<t.ProgressPhoto[]> {\n const photos: t.ProgressPhoto[] = [];\n\n for (const day of PROGRESS_DAYS) {\n const base64 = await this.getImage(imageName.progress(userUuid, day, programId));\n if (base64) {\n photos.push({ day, base64 });\n }\n }\n\n return photos;\n }\n\n public async saveRecipePhotos(input: t.SaveRecipePhotosInput): Promise<void> {\n await Promise.all([\n this.saveImage(input.ingredientBase64, imageName.recipe(input.recipeUuid, \"ingredients\")),\n this.saveImage(input.coverBase64, imageName.recipe(input.recipeUuid, \"cover\")),\n this.saveImage(input.methodBase64, imageName.recipe(input.recipeUuid, \"method\")),\n ]);\n }\n\n public async getRecipePhotos(recipeUuid: string): Promise<t.RecipePhotos | undefined> {\n const results = await Promise.all(\n RECIPE_PHOTO_TYPES.map((type) => this.getImage(imageName.recipe(recipeUuid, type)))\n );\n\n if (results.every((r) => !r)) {\n return undefined;\n }\n\n // BUG: cover/method swapped — preserved from original ImageController.ts to keep backward compat with frontend\n return {\n ingredientBase64: results[0] ?? \"\",\n methodBase64: results[1] ?? \"\",\n coverBase64: results[2] ?? \"\",\n };\n }\n\n public async saveUserProgressPhoto(\n input: t.UserProgressPhotoInput\n ): Promise<t.UserProgressPhotoRecord> {\n // Validate image\n validateBase64Image(input.base64);\n\n // Generate UUID for the photo\n const uuid = uuidv4();\n\n // Prepare Firebase path\n const firebasePath = `progress-pictures/${input.userUuid}/${uuid}.png`;\n\n // Upload to Firebase Storage\n const base64Data = input.base64.replace(/^data:image\\/\\w+;base64,/, \"\");\n const buffer = Buffer.from(base64Data, \"base64\");\n\n const file = this.bucket.file(firebasePath);\n await file.save(buffer, {\n metadata: {\n contentType: \"image/png\",\n },\n });\n\n // Save metadata to database\n const photoDate = input.photoDate || new Date();\n const record = await UserProgressPhoto.create({\n uuid,\n userUuid: input.userUuid,\n firebasePath,\n photoDate,\n programId: input.programId || null,\n });\n\n return record.toJSON() as t.UserProgressPhotoRecord;\n }\n\n async getUserProgressPhotos(\n userUuid: string\n ): Promise<t.UserProgressPhotoRecord[]> {\n const records = await UserProgressPhoto.findAll({\n where: { userUuid },\n order: [[\"photoDate\", \"DESC\"]],\n raw: true,\n attributes: ['uuid', 'userUuid', 'firebasePath', 'photoDate', 'programId', 'createdAt', 'updatedAt'],\n });\n\n // If no photos in new system, attempt to migrate from legacy Firebase structure\n if (records.length === 0) {\n this.logger.info(\"No photos in new system, checking for legacy photos to migrate\", { userUuid });\n await this.migrateLegacyPhotosForUser(userUuid);\n\n // Re-fetch after migration\n const migratedRecords = await UserProgressPhoto.findAll({\n where: { userUuid },\n order: [[\"photoDate\", \"DESC\"]],\n raw: true,\n attributes: ['uuid', 'userUuid', 'firebasePath', 'photoDate', 'programId', 'createdAt', 'updatedAt'],\n });\n\n return migratedRecords as t.UserProgressPhotoRecord[];\n }\n\n return records as t.UserProgressPhotoRecord[];\n }\n\n async getProgressPhotosByProgram(\n programId: string,\n userUuid?: string\n ): Promise<t.UserProgressPhotoRecord[]> {\n const records = await UserProgressPhoto.findAll({\n where: { programId },\n order: [[\"photoDate\", \"DESC\"]],\n raw: true,\n attributes: ['uuid', 'userUuid', 'firebasePath', 'photoDate', 'programId', 'createdAt', 'updatedAt'],\n });\n\n // If no photos found and userUuid provided, attempt migration\n if (records.length === 0 && userUuid) {\n this.logger.info(\"No photos found for program, attempting migration\", { programId, userUuid });\n await this.migrateLegacyPhotosForUser(userUuid);\n\n // Re-fetch after migration\n const migratedRecords = await UserProgressPhoto.findAll({\n where: { programId },\n order: [[\"photoDate\", \"DESC\"]],\n raw: true,\n attributes: ['uuid', 'userUuid', 'firebasePath', 'photoDate', 'programId', 'createdAt', 'updatedAt'],\n });\n\n return migratedRecords as t.UserProgressPhotoRecord[];\n }\n\n return records as t.UserProgressPhotoRecord[];\n }\n\n async updateProgressPhotoDate(\n input: t.UpdateProgressPhotoDateInput\n ): Promise<t.UserProgressPhotoRecord | null> {\n const [affectedRows] = await UserProgressPhoto.update(\n { photoDate: input.photoDate },\n {\n where: {\n uuid: input.uuid,\n userUuid: input.userUuid, // Ensure user owns the photo\n },\n }\n );\n\n if (affectedRows === 0) {\n return null; // Photo not found or user doesn't own it\n }\n\n const updated = await UserProgressPhoto.findOne({\n where: { uuid: input.uuid },\n raw: true,\n });\n\n return updated as t.UserProgressPhotoRecord;\n }\n\n async deleteProgressPhoto(\n uuid: string,\n userUuid: string\n ): Promise<boolean> {\n // Find the photo to get the firebasePath\n const photo = await UserProgressPhoto.findOne({\n where: { uuid, userUuid },\n raw: true,\n });\n\n if (!photo) {\n return false; // Photo not found or user doesn't own it\n }\n\n // Delete from Firebase Storage\n const file = this.bucket.file(photo.firebasePath);\n try {\n await file.delete();\n } catch (error) {\n // If file doesn't exist in storage, continue with database deletion\n console.warn(`Failed to delete file from storage: ${photo.firebasePath}`, error);\n }\n\n // Delete from database\n await UserProgressPhoto.destroy({\n where: { uuid, userUuid },\n });\n\n return true;\n }\n\n private async migrateLegacyPhotosForUser(userUuid: string): Promise<void> {\n try {\n this.logger.info(\"Starting legacy photo migration\", { userUuid });\n\n // List all files in the legacy path pattern: {userUuid}--{day}day--{programId}.png\n const [files] = await this.bucket.getFiles({\n prefix: `${userUuid}--`,\n });\n\n if (files.length === 0) {\n this.logger.info(\"No legacy photos found for user\", { userUuid });\n return;\n }\n\n const migratedCount = 0;\n const skippedCount = 0;\n\n for (const file of files) {\n const fileName = file.name;\n\n // Parse legacy filename: {userUuid}--{day}day--{programId}.png\n const match = fileName.match(/^(.+)--(\\d+)day--(.+)\\.png$/);\n if (!match) {\n this.logger.warn(\"Skipping file with unexpected name format\", { fileName });\n continue;\n }\n\n const [, , dayStr, programId] = match;\n const day = parseInt(dayStr, 10);\n\n // Check if this photo was already migrated (by programId + userUuid + approximate day)\n const existing = await UserProgressPhoto.findOne({\n where: { userUuid, programId },\n raw: true,\n });\n\n if (existing) {\n this.logger.debug(\"Photo already migrated, skipping\", { fileName });\n continue;\n }\n\n // Download the legacy photo\n const [contents] = await file.download();\n\n // Calculate photoDate based on day offset (we don't have program start date, so use upload time)\n // In reality, this would need Program model to calculate exact date\n const photoDate = new Date(); // Fallback: use current time\n photoDate.setDate(photoDate.getDate() - (90 - day)); // Rough estimate based on day\n\n // Generate new UUID and path\n const newUuid = uuidv4();\n const newFirebasePath = `progress-pictures/${userUuid}/${newUuid}.png`;\n\n // Copy to new Firebase location\n await this.bucket.file(newFirebasePath).save(contents, {\n metadata: {\n contentType: \"image/png\",\n },\n });\n\n // Create database record\n await UserProgressPhoto.create({\n uuid: newUuid,\n userUuid,\n firebasePath: newFirebasePath,\n photoDate,\n programId,\n });\n\n this.logger.info(\"Migrated legacy photo\", {\n oldPath: fileName,\n newPath: newFirebasePath,\n day,\n programId,\n });\n }\n\n this.logger.info(\"Legacy photo migration completed\", {\n userUuid,\n migrated: migratedCount,\n skipped: skippedCount,\n });\n } catch (error) {\n this.logger.error(\"Failed to migrate legacy photos\", { userUuid, error });\n // Don't throw - migration failure shouldn't break the request\n }\n }\n\n private base64ToBuffer(base64: string): Buffer {\n const data = base64.includes(\",\") ? base64.split(\",\")[1]! : base64;\n return Buffer.from(data, \"base64\");\n }\n\n private handleError(error: unknown, method: string): never {\n this.logger.error(`Firebase Storage error in ${method}`, { error });\n throw new ExternalAPIError(\n `Firebase Storage error: ${error instanceof Error ? error.message : String(error)}`,\n `Service: Firebase Storage, Method: ${method}`\n );\n }\n}\n"],"names":["admin","v4","uuidv4","ExternalAPIError","Log","validateBase64Image","UserProgressPhoto","PROGRESS_DAYS","RECIPE_PHOTO_TYPES","imageName","avatar","userUuid","progress","day","programId","recipe","recipeUuid","type","ImagesClient","bucket","logger","getInstance","extend","app","config","firebaseApp","initializeApp","storageBucket","storage","apps","length","info","serviceAccountPath","process","env","FIREBASE_SERVICE_ACCOUNT_KEY","fs","require","serviceAccount","JSON","parse","readFileSync","credential","cert","projectId","project_id","applicationDefault","error","String","saveImage","base64","name","buffer","base64ToBuffer","file","save","contentType","handleError","getImage","exists","undefined","contents","download","toString","saveAvatar","getAvatar","saveProgressPhoto","getProgressPhotos","photos","push","saveRecipePhotos","input","Promise","all","ingredientBase64","coverBase64","methodBase64","getRecipePhotos","results","map","every","r","saveUserProgressPhoto","uuid","firebasePath","base64Data","replace","Buffer","from","metadata","photoDate","Date","record","create","toJSON","getUserProgressPhotos","records","findAll","where","order","raw","attributes","migrateLegacyPhotosForUser","migratedRecords","getProgressPhotosByProgram","updateProgressPhotoDate","affectedRows","update","updated","findOne","deleteProgressPhoto","photo","delete","console","warn","destroy","files","getFiles","prefix","migratedCount","skippedCount","fileName","match","dayStr","parseInt","existing","debug","setDate","getDate","newUuid","newFirebasePath","oldPath","newPath","migrated","skipped","data","includes","split","method","Error","message"],"mappings":"AAAA,OAAOA,WAAW,iBAAiB;AAEnC,SAASC,MAAMC,MAAM,QAAQ,OAAO;AACpC,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,GAAG,QAAQ,qBAAqB;AACzC,SAASC,mBAAmB,QAAQ,8BAA8B;AAClE,SAASC,iBAAiB,QAAQ,wCAAwC;AAG1E,MAAMC,gBAAgB;IAAC;IAAG;IAAI;IAAI;CAAG;AAGrC,MAAMC,qBAAwC;IAAC;IAAe;IAAS;CAAS;AAEhF,MAAMC,YAAY;IAChBC,QAAQ,CAACC,WAAqB,GAAGA,SAAS,YAAY,CAAC;IACvDC,UAAU,CAACD,UAAkBE,KAAaC,YAAsB,GAAGH,SAAS,EAAE,EAAEE,IAAI,KAAK,EAAEC,UAAU,IAAI,CAAC;IAC1GC,QAAQ,CAACC,YAAoBC,OAA0B,GAAGD,WAAW,EAAE,EAAEC,KAAK,IAAI,CAAC;AACrF;AAEA,OAAO,MAAMC;IACHC,OAAe;IACfC,SAAShB,IAAIiB,WAAW,GAAGC,MAAM,CAAC,iBAAiB;IACnDC,IAAmB;IAE3B,YAAYC,MAAgB,CAAE;QAC5B,IAAIA,OAAOC,WAAW,EAAE;YACtB,4BAA4B;YAC5B,IAAI,CAACF,GAAG,GAAGC,OAAOC,WAAW;QAC/B,OAAO;YACL,mFAAmF;YACnF,IAAI,CAACC,aAAa,CAACF,OAA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B,MAAM,CAAC2B,KAAK,CAAC,mCAAmC;gBAAEpC;gBAAUoC;YAAM;QACvE,8DAA8D;QAChE;IACF;IAEQM,eAAeH,MAAc,EAAU;QAC7C,MAAMqF,OAAOrF,OAAOsF,QAAQ,CAAC,OAAOtF,OAAOuF,KAAK,CAAC,IAAI,CAAC,EAAE,GAAIvF;QAC5D,OAAOqC,OAAOC,IAAI,CAAC+C,MAAM;IAC3B;IAEQ9E,YAAYV,KAAc,EAAE2F,MAAc,EAAS;QACzD,IAAI,CAACtH,MAAM,CAAC2B,KAAK,CAAC,CAAC,0BAA0B,EAAE2F,QAAQ,EAAE;YAAE3F;QAAM;QACjE,MAAM,IAAI5C,iBACR,CAAC,wBAAwB,EAAE4C,iBAAiB4F,QAAQ5F,MAAM6F,OAAO,GAAG5F,OAAOD,QAAQ,EACnF,CAAC,mCAAmC,EAAE2F,QAAQ;IAElD;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/clients/ImagesClient.ts"],"sourcesContent":["import admin from \"firebase-admin\";\nimport { Bucket } from \"@google-cloud/storage\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { readFileSync } from \"fs\";\nimport { createDecipheriv } from \"crypto\";\nimport { ExternalAPIError } from \"../Errors/AppError.js\";\nimport { Log } from \"../utils/Logger.js\";\nimport { validateBase64Image } from \"../utils/imageValidation.js\";\nimport { UserProgressPhoto } from \"../dbmodels/user/UserProgressPhoto.js\";\nimport type * as t from \"./types/images.types.js\";\n\nconst PROGRESS_DAYS = [1, 30, 60, 90];\n\ntype RecipePhotoType = \"ingredients\" | \"cover\" | \"method\";\nconst RECIPE_PHOTO_TYPES: RecipePhotoType[] = [\"ingredients\", \"cover\", \"method\"];\n\nconst imageName = {\n avatar: (userUuid: string) => `${userUuid}--avatar.png`,\n progress: (userUuid: string, day: number, programId: string) => `progress/${userUuid}--${day}day--${programId}.png`,\n recipe: (recipeUuid: string, type: RecipePhotoType) => `${recipeUuid}--${type}.png`,\n};\n\nexport class ImagesClient {\n private bucket: Bucket;\n private logger = Log.getInstance().extend(\"images-client\");\n private app: admin.app.App;\n\n constructor(config: t.Config) {\n if (config.firebaseApp) {\n // Use provided Firebase app\n this.app = config.firebaseApp;\n } else {\n // Initialize Firebase if needed (following FirebasePushNotificationClient pattern)\n this.initializeApp(config.storageBucket);\n this.app = admin.app();\n }\n\n this.bucket = this.app.storage().bucket(config.storageBucket);\n }\n\n private initializeApp(storageBucket: string): void {\n try {\n // Check if app already exists\n if (admin.apps?.length && admin.apps.length > 0) {\n this.logger.info(\"Using existing Firebase app\");\n return;\n }\n\n // Try to load service account from environment (for local development)\n const serviceAccountPath = process.env.FIREBASE_SERVICE_ACCOUNT_KEY;\n\n if (serviceAccountPath) {\n // Local development with service account file\n const serviceAccount = JSON.parse(readFileSync(serviceAccountPath, \"utf-8\"));\n\n admin.initializeApp({\n credential: admin.credential.cert(serviceAccount),\n storageBucket,\n });\n\n this.logger.info(\"Firebase initialized with service account file\", {\n projectId: serviceAccount.project_id,\n storageBucket,\n });\n } else {\n // Production: use application default credentials\n admin.initializeApp({\n credential: admin.credential.applicationDefault(),\n storageBucket,\n });\n\n this.logger.info(\"Firebase initialized with application default credentials\", {\n storageBucket,\n });\n }\n } catch (error) {\n this.logger.error(\"Failed to initialize Firebase Admin SDK\", { error });\n throw new ExternalAPIError(\n \"Failed to initialize Firebase\",\n `Error: ${String(error)}`\n );\n }\n }\n\n public async saveImage(base64: string, name: string): Promise<void> {\n try {\n this.logger.info(\"Saving image\", { name });\n\n const buffer = this.base64ToBuffer(base64);\n const file = this.bucket.file(name);\n await file.save(buffer, { contentType: \"image/png\" });\n\n this.logger.info(\"Image saved successfully\", { name });\n } catch (error) {\n this.handleError(error, \"saveImage\");\n }\n }\n\n public async getImage(name: string): Promise<string | undefined> {\n try {\n this.logger.info(\"Getting image\", { name });\n\n const file = this.bucket.file(name);\n const [exists] = await file.exists();\n if (!exists) {\n return undefined;\n }\n\n const [contents] = await file.download();\n return \"data:image/jpeg;base64,\" + contents.toString(\"base64\");\n } catch (error) {\n this.logger.error(`Failed to get image: ${name}`, { error });\n return undefined;\n }\n }\n\n public async saveAvatar(userUuid: string, base64: string): Promise<void> {\n await this.saveImage(base64, imageName.avatar(userUuid));\n }\n\n public async getAvatar(userUuid: string): Promise<string | undefined> {\n return this.getImage(imageName.avatar(userUuid));\n }\n\n public async saveProgressPhoto(userUuid: string, day: number, programId: string, base64: string): Promise<void> {\n await this.saveImage(base64, imageName.progress(userUuid, day, programId));\n }\n\n public async getProgressPhotos(userUuid: string, programId: string): Promise<t.ProgressPhoto[]> {\n const photos: t.ProgressPhoto[] = [];\n\n for (const day of PROGRESS_DAYS) {\n const base64 = await this.getImage(imageName.progress(userUuid, day, programId));\n if (base64) {\n photos.push({ day, base64 });\n }\n }\n\n return photos;\n }\n\n public async saveRecipePhotos(input: t.SaveRecipePhotosInput): Promise<void> {\n await Promise.all([\n this.saveImage(input.ingredientBase64, imageName.recipe(input.recipeUuid, \"ingredients\")),\n this.saveImage(input.coverBase64, imageName.recipe(input.recipeUuid, \"cover\")),\n this.saveImage(input.methodBase64, imageName.recipe(input.recipeUuid, \"method\")),\n ]);\n }\n\n public async getRecipePhotos(recipeUuid: string): Promise<t.RecipePhotos | undefined> {\n const results = await Promise.all(\n RECIPE_PHOTO_TYPES.map((type) => this.getImage(imageName.recipe(recipeUuid, type)))\n );\n\n if (results.every((r) => !r)) {\n return undefined;\n }\n\n // BUG: cover/method swapped — preserved from original ImageController.ts to keep backward compat with frontend\n return {\n ingredientBase64: results[0] ?? \"\",\n methodBase64: results[1] ?? \"\",\n coverBase64: results[2] ?? \"\",\n };\n }\n\n public async saveUserProgressPhoto(\n input: t.UserProgressPhotoInput\n ): Promise<t.UserProgressPhotoRecord> {\n // Validate image\n validateBase64Image(input.base64);\n\n // Generate UUID for the photo\n const uuid = uuidv4();\n\n // Prepare Firebase path\n const firebasePath = `progress-pictures/${input.userUuid}/${uuid}.png`;\n\n // Upload to Firebase Storage\n const base64Data = input.base64.replace(/^data:image\\/\\w+;base64,/, \"\");\n const buffer = Buffer.from(base64Data, \"base64\");\n\n const file = this.bucket.file(firebasePath);\n await file.save(buffer, {\n metadata: {\n contentType: \"image/png\",\n },\n });\n\n // Save metadata to database\n const photoDate = input.photoDate || new Date();\n const record = await UserProgressPhoto.create({\n uuid,\n userUuid: input.userUuid,\n firebasePath,\n photoDate,\n programId: input.programId || null,\n });\n\n return record.toJSON() as t.UserProgressPhotoRecord;\n }\n\n async getUserProgressPhotos(\n userUuid: string\n ): Promise<t.UserProgressPhotoRecord[]> {\n const records = await UserProgressPhoto.findAll({\n where: { userUuid },\n order: [[\"photoDate\", \"DESC\"]],\n raw: true,\n attributes: ['uuid', 'userUuid', 'firebasePath', 'photoDate', 'programId', 'createdAt', 'updatedAt'],\n });\n\n // If no photos in new system, attempt to migrate from legacy Firebase structure\n if (records.length === 0) {\n this.logger.info(\"No photos in new system, checking for legacy photos to migrate\", { userUuid });\n await this.migrateLegacyPhotosForUser(userUuid);\n\n // Re-fetch after migration\n const migratedRecords = await UserProgressPhoto.findAll({\n where: { userUuid },\n order: [[\"photoDate\", \"DESC\"]],\n raw: true,\n attributes: ['uuid', 'userUuid', 'firebasePath', 'photoDate', 'programId', 'createdAt', 'updatedAt'],\n });\n\n // Generate signed URLs for migrated records\n const withUrls = await Promise.all(\n (migratedRecords as t.UserProgressPhotoRecord[]).map(async (record) => ({\n ...record,\n url: await this.getSignedUrl(record.firebasePath),\n }))\n );\n\n return withUrls;\n }\n\n // Generate signed URLs for all records\n const withUrls = await Promise.all(\n (records as t.UserProgressPhotoRecord[]).map(async (record) => ({\n ...record,\n url: await this.getSignedUrl(record.firebasePath),\n }))\n );\n\n return withUrls;\n }\n\n async getProgressPhotosByProgram(\n programId: string,\n userUuid?: string\n ): Promise<t.UserProgressPhotoRecord[]> {\n const records = await UserProgressPhoto.findAll({\n where: { programId },\n order: [[\"photoDate\", \"DESC\"]],\n raw: true,\n attributes: ['uuid', 'userUuid', 'firebasePath', 'photoDate', 'programId', 'createdAt', 'updatedAt'],\n });\n\n // If no photos found and userUuid provided, attempt migration\n if (records.length === 0 && userUuid) {\n this.logger.info(\"No photos found for program, attempting migration\", { programId, userUuid });\n await this.migrateLegacyPhotosForUser(userUuid);\n\n // Re-fetch after migration\n const migratedRecords = await UserProgressPhoto.findAll({\n where: { programId },\n order: [[\"photoDate\", \"DESC\"]],\n raw: true,\n attributes: ['uuid', 'userUuid', 'firebasePath', 'photoDate', 'programId', 'createdAt', 'updatedAt'],\n });\n\n // Generate signed URLs\n const withUrls = await Promise.all(\n (migratedRecords as t.UserProgressPhotoRecord[]).map(async (record) => ({\n ...record,\n url: await this.getSignedUrl(record.firebasePath),\n }))\n );\n\n return withUrls;\n }\n\n // Generate signed URLs for all records\n const withUrls = await Promise.all(\n (records as t.UserProgressPhotoRecord[]).map(async (record) => ({\n ...record,\n url: await this.getSignedUrl(record.firebasePath),\n }))\n );\n\n return withUrls;\n }\n\n async updateProgressPhotoDate(\n input: t.UpdateProgressPhotoDateInput\n ): Promise<t.UserProgressPhotoRecord | null> {\n const [affectedRows] = await UserProgressPhoto.update(\n { photoDate: input.photoDate },\n {\n where: {\n uuid: input.uuid,\n userUuid: input.userUuid, // Ensure user owns the photo\n },\n }\n );\n\n if (affectedRows === 0) {\n return null; // Photo not found or user doesn't own it\n }\n\n const updated = await UserProgressPhoto.findOne({\n where: { uuid: input.uuid },\n raw: true,\n });\n\n return updated as t.UserProgressPhotoRecord;\n }\n\n async deleteProgressPhoto(\n uuid: string,\n userUuid: string\n ): Promise<boolean> {\n // Find the photo to get the firebasePath\n const photo = await UserProgressPhoto.findOne({\n where: { uuid, userUuid },\n raw: true,\n });\n\n if (!photo) {\n return false; // Photo not found or user doesn't own it\n }\n\n // Delete from Firebase Storage\n const file = this.bucket.file(photo.firebasePath);\n try {\n await file.delete();\n } catch (error) {\n // If file doesn't exist in storage, continue with database deletion\n console.warn(`Failed to delete file from storage: ${photo.firebasePath}`, error);\n }\n\n // Delete from database\n await UserProgressPhoto.destroy({\n where: { uuid, userUuid },\n });\n\n return true;\n }\n\n private async migrateLegacyPhotosForUser(userUuid: string): Promise<void> {\n try {\n this.logger.info(\"Starting legacy photo migration\", { userUuid });\n\n // List all files in the legacy /progress folder with pattern: progress/{userUuid}--{day}day--{programId}.png\n let files;\n try {\n [files] = await this.bucket.getFiles({\n prefix: `progress/${userUuid}--`,\n });\n } catch (authError) {\n this.logger.error(\"Firebase authentication failed during migration, skipping\", {\n userUuid,\n error: authError instanceof Error ? authError.message : String(authError),\n });\n return; // Skip migration if auth fails\n }\n\n if (files.length === 0) {\n this.logger.info(\"No legacy photos found for user\", { userUuid });\n return;\n }\n\n let migratedCount = 0;\n let skippedCount = 0;\n\n for (const file of files) {\n const fileName = file.name;\n\n // Parse legacy filename: progress/{userUuid}--{day}day--{programId}.png\n const match = fileName.match(/^progress\\/(.+)--(\\d+)day--(.+)\\.png$/);\n if (!match) {\n this.logger.warn(\"Skipping file with unexpected name format\", { fileName });\n continue;\n }\n\n const [, fileUserUuid, dayStr, programId] = match;\n const day = parseInt(dayStr, 10);\n\n // Verify this file belongs to the user\n if (fileUserUuid !== userUuid) {\n this.logger.warn(\"File doesn't belong to this user, skipping\", { fileName, userUuid, fileUserUuid });\n continue;\n }\n\n // Check if this photo was already migrated (by programId + userUuid + approximate day)\n const existing = await UserProgressPhoto.findOne({\n where: { userUuid, programId },\n raw: true,\n });\n\n if (existing) {\n this.logger.debug(\"Photo already migrated, skipping\", { fileName });\n continue;\n }\n\n // Download the legacy photo (encrypted in storage)\n const [encryptedContents] = await file.download();\n\n // Decrypt the legacy photo\n let decryptedBuffer: Buffer;\n try {\n decryptedBuffer = this.decryptLegacyImage(encryptedContents);\n } catch (decryptError) {\n this.logger.error(\"Failed to decrypt legacy photo, skipping\", { fileName, decryptError });\n skippedCount++;\n continue;\n }\n\n // Calculate photoDate based on day offset (we don't have program start date, so use upload time)\n // In reality, this would need Program model to calculate exact date\n const photoDate = new Date(); // Fallback: use current time\n photoDate.setDate(photoDate.getDate() - (90 - day)); // Rough estimate based on day\n\n // Generate new UUID and path\n const newUuid = uuidv4();\n const newFirebasePath = `progress-pictures/${userUuid}/${newUuid}.png`;\n\n // Save decrypted (plain) image to new Firebase location\n await this.bucket.file(newFirebasePath).save(decryptedBuffer, {\n metadata: {\n contentType: \"image/png\",\n },\n });\n\n migratedCount++;\n\n // Create database record\n await UserProgressPhoto.create({\n uuid: newUuid,\n userUuid,\n firebasePath: newFirebasePath,\n photoDate,\n programId,\n });\n\n this.logger.info(\"Migrated legacy photo\", {\n oldPath: fileName,\n newPath: newFirebasePath,\n day,\n programId,\n });\n }\n\n this.logger.info(\"Legacy photo migration completed\", {\n userUuid,\n migrated: migratedCount,\n skipped: skippedCount,\n });\n } catch (error) {\n this.logger.error(\"Failed to migrate legacy photos\", { userUuid, error });\n // Don't throw - migration failure shouldn't break the request\n }\n }\n\n private async getSignedUrl(firebasePath: string): Promise<string | undefined> {\n try {\n const file = this.bucket.file(firebasePath);\n\n // Check if file exists first\n const [exists] = await file.exists();\n if (!exists) {\n this.logger.warn(\"File not found for signed URL generation\", { firebasePath });\n return undefined;\n }\n\n // Generate signed URL with proper expiration date\n const expirationDate = new Date();\n expirationDate.setDate(expirationDate.getDate() + 7); // 7 days from now\n\n const [url] = await file.getSignedUrl({\n action: \"read\",\n expires: expirationDate,\n });\n\n this.logger.debug(\"Generated signed URL\", { firebasePath });\n return url;\n } catch (error) {\n this.logger.error(\"Failed to generate signed URL\", {\n firebasePath,\n error: error instanceof Error ? error.message : String(error),\n errorDetails: error\n });\n return undefined;\n }\n }\n\n private decryptLegacyImage(encryptedBuffer: Buffer): Buffer {\n try {\n const encryptionKey = process.env.ENCRYPTION_KEY;\n if (!encryptionKey) {\n throw new Error(\"ENCRYPTION_KEY not found in environment\");\n }\n\n // Extract IV from first 16 bytes\n const iv = encryptedBuffer.slice(0, 16);\n const encryptedData = encryptedBuffer.slice(16);\n\n // Decrypt using AES-256-CBC\n const decipher = createDecipheriv(\"aes-256-cbc\", Buffer.from(encryptionKey), iv);\n const decryptedData = Buffer.concat([decipher.update(encryptedData), decipher.final()]);\n\n // Old implementation adds extra prefix, remove it (20 bytes)\n // Original: \"data:image/jpeg;base64,\" + decryptedImageData.toString('base64').slice(20, ...)\n return decryptedData.slice(20);\n } catch (error) {\n this.logger.error(\"Failed to decrypt legacy image\", { error });\n throw new Error(\"Image decryption failed\");\n }\n }\n\n private base64ToBuffer(base64: string): Buffer {\n const data = base64.includes(\",\") ? base64.split(\",\")[1]! : base64;\n return Buffer.from(data, \"base64\");\n }\n\n private handleError(error: unknown, method: string): never {\n this.logger.error(`Firebase Storage error in ${method}`, { error });\n throw new ExternalAPIError(\n `Firebase Storage error: ${error instanceof Error ? error.message : String(error)}`,\n `Service: Firebase Storage, Method: ${method}`\n );\n }\n}\n"],"names":["admin","v4","uuidv4","readFileSync","createDecipheriv","ExternalAPIError","Log","validateBase64Image","UserProgressPhoto","PROGRESS_DAYS","RECIPE_PHOTO_TYPES","imageName","avatar","userUuid","progress","day","programId","recipe","recipeUuid","type","ImagesClient","bucket","logger","getInstance","extend","app","config","firebaseApp","initializeApp","storageBucket","storage","apps","length","info","serviceAccountPath","process","env","FIREBASE_SERVICE_ACCOUNT_KEY","serviceAccount","JSON","parse","credential","cert","projectId","project_id","applicationDefault","error","String","saveImage","base64","name","buffer","base64ToBuffer","file","save","contentType","handleError","getImage","exists","undefined","contents","download","toString","saveAvatar","getAvatar","saveProgressPhoto","getProgressPhotos","photos","push","saveRecipePhotos","input","Promise","all","ingredientBase64","coverBase64","methodBase64","getRecipePhotos","results","map","every","r","saveUserProgressPhoto","uuid","firebasePath","base64Data","replace","Buffer","from","metadata","photoDate","Date","record","create","toJSON","getUserProgressPhotos","records","findAll","where","order","raw","attributes","migrateLegacyPhotosForUser","migratedRecords","withUrls","url","getSignedUrl","getProgressPhotosByProgram","updateProgressPhotoDate","affectedRows","update","updated","findOne","deleteProgressPhoto","photo","delete","console","warn","destroy","files","getFiles","prefix","authError","Error","message","migratedCount","skippedCount","fileName","match","fileUserUuid","dayStr","parseInt","existing","debug","encryptedContents","decryptedBuffer","decryptLegacyImage","decryptError","setDate","getDate","newUuid","newFirebasePath","oldPath","newPath","migrated","skipped","expirationDate","action","expires","errorDetails","encryptedBuffer","encryptionKey","ENCRYPTION_KEY","iv","slice","encryptedData","decipher","decryptedData","concat","final","data","includes","split","method"],"mappings":"AAAA,OAAOA,WAAW,iBAAiB;AAEnC,SAASC,MAAMC,MAAM,QAAQ,OAAO;AACpC,SAASC,YAAY,QAAQ,KAAK;AAClC,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,GAAG,QAAQ,qBAAqB;AACzC,SAASC,mBAAmB,QAAQ,8BAA8B;AAClE,SAASC,iBAAiB,QAAQ,wCAAwC;AAG1E,MAAMC,gBAAgB;IAAC;IAAG;IAAI;IAAI;CAAG;AAGrC,MAAMC,qBAAwC;IAAC;IAAe;IAAS;CAAS;AAEhF,MAAMC,YAAY;IAChBC,QAAQ,CAACC,WAAqB,GAAGA,SAAS,YAAY,CAAC;IACvDC,UAAU,CAACD,UAAkBE,KAAaC,YAAsB,CAAC,SAAS,EAAEH,SAAS,EAAE,EAAEE,IAAI,KAAK,EAAEC,UAAU,IAAI,CAAC;IACnHC,QAAQ,CAACC,YAAoBC,OAA0B,GAAGD,WAAW,EAAE,EAAEC,KAAK,IAAI,CAAC;AACrF;AAEA,OAAO,MAAMC;IACHC,OAAe;IACfC,SAAShB,IAAIiB,WAAW,GAAGC,MAAM,CAAC,iBAAiB;IACnDC,IAAmB;IAE3B,YAAYC,MAAgB,CAAE;QAC5B,IAAIA,OAAOC,WAAW,EAAE;YACtB,4BAA4B;YAC5B,IAAI,CAACF,GAAG,GAAGC,OAAOC,WAAW;QAC/B,OAAO;YACL,mFAAmF;YACnF,IAAI,CAACC,aAAa,CAACF,OAAOG,aAAa;YACvC,IAAI,CAAC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AM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"images.types.d.ts","sourceRoot":"","sources":["../../../../src/lib/clients/types/images.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AAExC,MAAM,WAAW,MAAM;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/clients/types/images.types.ts"],"sourcesContent":["import type admin from \"firebase-admin\";\n\nexport interface Config {\n storageBucket: string;\n firebaseApp?: admin.app.App;\n}\n\nexport interface ProgressPhoto {\n day: number;\n base64: string;\n}\n\nexport interface RecipePhotos {\n ingredientBase64: string;\n coverBase64: string;\n methodBase64: string;\n}\n\nexport interface SaveRecipePhotosInput {\n recipeUuid: string;\n ingredientBase64: string;\n coverBase64: string;\n methodBase64: string;\n}\n\nexport interface UserProgressPhotoInput {\n userUuid: string;\n base64: string;\n photoDate?: Date; // Optional, defaults to now\n programId?: string; // Optional, for legacy program association\n}\n\nexport interface UserProgressPhotoRecord {\n uuid: string;\n userUuid: string;\n firebasePath: string;\n photoDate: Date;\n programId: string | null;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface UpdateProgressPhotoDateInput {\n uuid: string;\n userUuid: string;\n photoDate: Date;\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/clients/types/images.types.ts"],"sourcesContent":["import type admin from \"firebase-admin\";\n\nexport interface Config {\n storageBucket: string;\n firebaseApp?: admin.app.App;\n}\n\nexport interface ProgressPhoto {\n day: number;\n base64: string;\n}\n\nexport interface RecipePhotos {\n ingredientBase64: string;\n coverBase64: string;\n methodBase64: string;\n}\n\nexport interface SaveRecipePhotosInput {\n recipeUuid: string;\n ingredientBase64: string;\n coverBase64: string;\n methodBase64: string;\n}\n\nexport interface UserProgressPhotoInput {\n userUuid: string;\n base64: string;\n photoDate?: Date; // Optional, defaults to now\n programId?: string; // Optional, for legacy program association\n}\n\nexport interface UserProgressPhotoRecord {\n uuid: string;\n userUuid: string;\n firebasePath: string;\n photoDate: Date;\n programId: string | null;\n createdAt: Date;\n updatedAt: Date;\n url?: string | undefined; // Optional signed URL for frontend access\n}\n\nexport interface UpdateProgressPhotoDateInput {\n uuid: string;\n userUuid: string;\n photoDate: Date;\n}\n"],"names":[],"mappings":"AA2CA,WAIC"}
|