@majikah/majik-universal-id-client 0.0.4 → 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.
@@ -510,13 +510,13 @@ export declare class MajikUniversalIdClient {
510
510
  key?: MajikKey;
511
511
  expectedSignerId?: string;
512
512
  }): Promise<Array<VerificationResult & {
513
- handler: string | null;
514
- mimeType: string | null;
513
+ handler: string | undefined;
514
+ mimeType: string | undefined;
515
515
  error: Error | null;
516
516
  }>>;
517
517
  /**
518
518
  * Extract the embedded MajikSignature from a file.
519
- * Returns a fully typed MajikSignature instance, or null if not found.
519
+ * Returns an array of typed MajikSignature instance, or empty if not found.
520
520
  *
521
521
  * Does not verify — use verifyFile() to verify.
522
522
  *
@@ -526,7 +526,7 @@ export declare class MajikUniversalIdClient {
526
526
  */
527
527
  extractSignature(file: Blob, options?: {
528
528
  mimeType?: string;
529
- }): Promise<MajikSignature | null>;
529
+ }): Promise<MajikSignature[] | null>;
530
530
  /**
531
531
  * Return a clean copy of the file with any embedded signature removed.
532
532
  * The returned bytes are exactly what was originally signed.
@@ -607,7 +607,7 @@ export declare class MajikUniversalIdClient {
607
607
  */
608
608
  getFileSignatureInfo(file: Blob, options?: {
609
609
  mimeType?: string;
610
- }): Promise<MajikSignature | null>;
610
+ }): Promise<MajikSignature[] | null>;
611
611
  /**
612
612
  * Sign an image with dual-layer embedding.
613
613
  *
@@ -982,20 +982,21 @@ export class MajikUniversalIdClient {
982
982
  * });
983
983
  */
984
984
  async verifyFile(file, options) {
985
- console.log("Verifying File");
986
985
  try {
987
986
  const publicKeys = await this._resolveSignerPublicKeys(options);
988
987
  if (publicKeys) {
989
- return MajikSignature.verifyFile(file, publicKeys, {
988
+ const results = await MajikSignature.verifyFile(file, publicKeys, {
990
989
  expectedSignerId: options?.expectedSignerId,
991
990
  mimeType: options?.mimeType,
992
991
  }, true);
992
+ return results[0];
993
993
  }
994
- // No signer provided — extract and use self-reported keys
994
+ // No signer provided — extract and use self-reported keys from first signature.
995
+ // For full multi-sig verification, pass a contactId or publicKeyBase64.
995
996
  const extracted = await MajikSignature.extractFrom(file, {
996
997
  mimeType: options?.mimeType,
997
998
  });
998
- if (!extracted) {
999
+ if (!extracted.length) {
999
1000
  return {
1000
1001
  valid: false,
1001
1002
  signerId: "",
@@ -1004,10 +1005,12 @@ export class MajikUniversalIdClient {
1004
1005
  reason: "No embedded signature found",
1005
1006
  };
1006
1007
  }
1007
- return MajikSignature.verifyFile(file, extracted.extractPublicKeys(), {
1008
- expectedSignerId: options?.expectedSignerId,
1008
+ const firstSig = extracted[0];
1009
+ const results = await MajikSignature.verifyFile(file, firstSig.extractPublicKeys(), {
1010
+ expectedSignerId: firstSig.signerId,
1009
1011
  mimeType: options?.mimeType,
1010
1012
  }, true);
1013
+ return results[0];
1011
1014
  }
1012
1015
  catch (err) {
1013
1016
  this._emit("error", err, { context: "verifyFile" });
@@ -1045,34 +1048,36 @@ export class MajikUniversalIdClient {
1045
1048
  try {
1046
1049
  let result;
1047
1050
  if (publicKeys) {
1048
- result = await MajikSignature.verifyFile(file, publicKeys, {
1051
+ const results = await MajikSignature.verifyFile(file, publicKeys, {
1049
1052
  mimeType,
1050
1053
  expectedSignerId,
1051
1054
  });
1055
+ result = results[0];
1052
1056
  }
1053
1057
  else {
1054
- // No signer hint — use self-reported keys from each file's envelope
1055
1058
  const extracted = await MajikSignature.extractFrom(file, {
1056
1059
  mimeType,
1057
1060
  });
1058
- if (!extracted) {
1061
+ if (!extracted.length) {
1059
1062
  return {
1060
1063
  valid: false,
1061
- signerId: "",
1062
- contentHash: "",
1064
+ signerId: undefined,
1065
+ contentHash: undefined,
1063
1066
  timestamp: new Date().toISOString(),
1064
1067
  reason: "No embedded signature found",
1065
- handler: null,
1066
- mimeType: mimeType ?? null,
1068
+ handler: undefined,
1069
+ mimeType,
1067
1070
  error: null,
1068
1071
  };
1069
1072
  }
1070
- result = await MajikSignature.verifyFile(file, extracted.extractPublicKeys(), { mimeType, expectedSignerId });
1073
+ const firstSig = extracted[0];
1074
+ const results = await MajikSignature.verifyFile(file, firstSig.extractPublicKeys(), { mimeType, expectedSignerId: firstSig.signerId });
1075
+ result = results[0];
1071
1076
  }
1072
1077
  return {
1073
1078
  ...result,
1074
- handler: result.handler ?? null,
1075
- mimeType: mimeType ?? null,
1079
+ handler: result.handler,
1080
+ mimeType,
1076
1081
  error: null,
1077
1082
  };
1078
1083
  }
@@ -1080,11 +1085,11 @@ export class MajikUniversalIdClient {
1080
1085
  this._emit("error", err, { context: "batchVerifyFiles" });
1081
1086
  return {
1082
1087
  valid: false,
1083
- signerId: "",
1084
- contentHash: "",
1088
+ signerId: undefined,
1089
+ contentHash: undefined,
1085
1090
  timestamp: new Date().toISOString(),
1086
- handler: null,
1087
- mimeType: mimeType ?? null,
1091
+ handler: undefined,
1092
+ mimeType,
1088
1093
  error: err instanceof Error ? err : new Error(String(err)),
1089
1094
  };
1090
1095
  }
@@ -1093,7 +1098,7 @@ export class MajikUniversalIdClient {
1093
1098
  // ── Signature Utilities ───────────────────────────────────────────────────
1094
1099
  /**
1095
1100
  * Extract the embedded MajikSignature from a file.
1096
- * Returns a fully typed MajikSignature instance, or null if not found.
1101
+ * Returns an array of typed MajikSignature instance, or empty if not found.
1097
1102
  *
1098
1103
  * Does not verify — use verifyFile() to verify.
1099
1104
  *
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@majikah/majik-universal-id-client",
3
3
  "type": "module",
4
4
  "description": "The core universal identity model for the Majikah ecosystem, featuring hybrid PQC signatures (Ed25519 + ML-DSA), ML-KEM-768 private info encryption, and multi-stage Didit verification graduation.",
5
- "version": "0.0.4",
5
+ "version": "0.0.5",
6
6
  "license": "Apache-2.0",
7
7
  "author": "Zelijah",
8
8
  "main": "./dist/index.js",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@majikah/majik-key": "^0.2.3",
49
- "@majikah/majik-universal-id": "^0.0.6",
49
+ "@majikah/majik-universal-id": "^0.0.8",
50
50
  "idb": "^8.0.3"
51
51
  },
52
52
  "devDependencies": {