@majikah/majik-file 0.0.3 → 0.0.5

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.
@@ -49,6 +49,10 @@ export interface MajikFileGroupKey {
49
49
  export interface MjkbSinglePayload {
50
50
  /** Base64-encoded ML-KEM-768 ciphertext (1088 bytes). */
51
51
  mlKemCipherText: string;
52
+ /** Original filename (e.g. "photo.png"). Short key keeps the binary compact. */
53
+ n?: string | null;
54
+ /** Original MIME type (e.g. "image/png"). Short key keeps the binary compact. */
55
+ m?: string | null;
52
56
  }
53
57
  /**
54
58
  * JSON payload embedded in a group .mjkb binary.
@@ -58,6 +62,10 @@ export interface MjkbSinglePayload {
58
62
  export interface MjkbGroupPayload {
59
63
  /** Per-recipient key entries. */
60
64
  keys: MajikFileGroupKey[];
65
+ /** Original filename (e.g. "photo.png"). Short key keeps the binary compact. */
66
+ n?: string | null;
67
+ /** Original MIME type (e.g. "image/png"). Short key keeps the binary compact. */
68
+ m?: string | null;
61
69
  }
62
70
  export type MjkbPayload = MjkbSinglePayload | MjkbGroupPayload;
63
71
  export declare function isMjkbGroupPayload(p: MjkbPayload): p is MjkbGroupPayload;
@@ -315,6 +315,8 @@ export class MajikFile {
315
315
  ciphertext = aesGcmEncrypt(sharedSecret, iv, compressed);
316
316
  payload = {
317
317
  mlKemCipherText: arrayToBase64(mlKemCT),
318
+ n: originalName ?? null,
319
+ m: resolvedMimeType ?? null,
318
320
  };
319
321
  }
320
322
  else {
@@ -343,7 +345,11 @@ export class MajikFile {
343
345
  encryptedAesKey: arrayToBase64(encryptedAesKey),
344
346
  };
345
347
  });
346
- payload = { keys };
348
+ payload = {
349
+ keys,
350
+ n: originalName ?? null,
351
+ m: resolvedMimeType ?? null,
352
+ };
347
353
  }
348
354
  // ── 6. Encode .mjkb ───────────────────────────────────────────────
349
355
  const mjkbBytes = encodeMjkb(iv, payload, ciphertext);
@@ -508,11 +514,12 @@ export class MajikFile {
508
514
  throw MajikFileError.decryptionFailed("Decryption failed — wrong key or corrupted .mjkb file");
509
515
  }
510
516
  const bytes = await MajikCompressor.decompress(compressed);
511
- // Extract original_name and mime_type from the payload.
512
- // Both fields are written at encryption time by MajikFile.create().
513
- // They may be null for files encrypted without metadata.
514
- const originalName = payload.original_name ?? null;
515
- const mimeType = payload.mime_type ?? null;
517
+ // Extract original filename and MIME type from the payload.
518
+ // Written at encryption time as short keys n/m to keep the binary compact.
519
+ // Older .mjkb files without these fields return null callers should fall
520
+ // back to stripping ".mjkb" from the filename and using "application/octet-stream".
521
+ const originalName = payload.n ?? null;
522
+ const mimeType = payload.m ?? null;
516
523
  return { bytes, originalName, mimeType };
517
524
  }
518
525
  catch (err) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@majikah/majik-file",
3
3
  "type": "module",
4
4
  "description": "Majik File is the core cryptographic engine for secure file handling in the Majikah ecosystem. It provides a post-quantum secure \"MJKB\" format designed for file encryption, multi-recipient key encapsulation, and transparent compression using NIST-standardized algorithms.",
5
- "version": "0.0.3",
5
+ "version": "0.0.5",
6
6
  "license": "Apache-2.0",
7
7
  "author": "Zelijah",
8
8
  "main": "./dist/index.js",