@hot-updater/react-native 0.22.2 → 0.23.1

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.
Files changed (39) hide show
  1. package/android/src/main/java/com/hotupdater/BundleFileStorageService.kt +17 -12
  2. package/android/src/main/java/com/hotupdater/HotUpdater.kt +1 -1
  3. package/android/src/main/java/com/hotupdater/HotUpdaterFactory.kt +1 -0
  4. package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +1 -1
  5. package/android/src/main/java/com/hotupdater/SignatureVerifier.kt +346 -0
  6. package/ios/HotUpdater/Internal/BundleFileStorageService.swift +26 -18
  7. package/ios/HotUpdater/Internal/SignatureVerifier.swift +339 -0
  8. package/lib/commonjs/checkForUpdate.js +1 -1
  9. package/lib/commonjs/checkForUpdate.js.map +1 -1
  10. package/lib/commonjs/index.js +16 -1
  11. package/lib/commonjs/index.js.map +1 -1
  12. package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -1
  13. package/lib/commonjs/types.js +45 -0
  14. package/lib/commonjs/types.js.map +1 -0
  15. package/lib/module/checkForUpdate.js +1 -1
  16. package/lib/module/checkForUpdate.js.map +1 -1
  17. package/lib/module/index.js +1 -0
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/module/specs/NativeHotUpdater.js.map +1 -1
  20. package/lib/module/types.js +40 -0
  21. package/lib/module/types.js.map +1 -0
  22. package/lib/typescript/commonjs/index.d.ts +1 -0
  23. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  24. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts +7 -2
  25. package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -1
  26. package/lib/typescript/commonjs/types.d.ts +34 -0
  27. package/lib/typescript/commonjs/types.d.ts.map +1 -0
  28. package/lib/typescript/module/index.d.ts +1 -0
  29. package/lib/typescript/module/index.d.ts.map +1 -1
  30. package/lib/typescript/module/specs/NativeHotUpdater.d.ts +7 -2
  31. package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -1
  32. package/lib/typescript/module/types.d.ts +34 -0
  33. package/lib/typescript/module/types.d.ts.map +1 -0
  34. package/package.json +7 -6
  35. package/plugin/build/withHotUpdater.js +55 -4
  36. package/src/checkForUpdate.ts +1 -1
  37. package/src/index.ts +5 -0
  38. package/src/specs/NativeHotUpdater.ts +7 -2
  39. package/src/types.ts +63 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAgBpE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,GACf,4BAA4B,CAS9B"}
@@ -3,6 +3,7 @@ import { updateBundle } from "./native";
3
3
  import { wrap } from "./wrap";
4
4
  export type { HotUpdaterEvent } from "./native";
5
5
  export * from "./store";
6
+ export { extractSignatureFailure, isSignatureVerificationError, type SignatureVerificationFailure, } from "./types";
6
7
  export type { HotUpdaterOptions } from "./wrap";
7
8
  export declare const HotUpdater: {
8
9
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAQL,YAAY,EACb,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,cAAc,SAAS,CAAC;AACxB,YAAY,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAQhD,eAAO,MAAM,UAAU;IACrB;;;;;;;;;;;;;;;;;;;;;OAqBG;;IAEH;;OAEG;;IAEH;;;;;;;;;;;;;;;;OAgBG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;;;;;;;;;;OAYG;;IAEH;;;;;;;;;;;;;;;;OAgBG;;IAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;;IAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;;IAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;;IAEH;;;;;;;;;;OAUG;;CAEJ,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAQL,YAAY,EACb,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,KAAK,4BAA4B,GAClC,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAQhD,eAAO,MAAM,UAAU;IACrB;;;;;;;;;;;;;;;;;;;;;OAqBG;;IAEH;;OAEG;;IAEH;;;;;;;;;;;;;;;;OAgBG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;;;;;;;;;;OAYG;;IAEH;;;;;;;;;;;;;;;;OAgBG;;IAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;;IAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;;IAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;;IAEH;;;;;;;;;;OAUG;;CAEJ,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
@@ -3,8 +3,13 @@ export interface UpdateBundleParams {
3
3
  bundleId: string;
4
4
  fileUrl: string | null;
5
5
  /**
6
- * SHA256 hash of the bundle file for integrity verification.
7
- * If provided, the native layer will verify the downloaded file's hash.
6
+ * File hash for integrity/signature verification.
7
+ *
8
+ * Format depends on signing configuration:
9
+ * - Signed: `sig:<base64_signature>` - Native will verify signature (and implicitly hash)
10
+ * - Unsigned: `<hex_hash>` - Native will verify SHA256 hash only
11
+ *
12
+ * Native determines verification mode by checking for "sig:" prefix.
8
13
  */
9
14
  fileHash: string | null;
10
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NativeHotUpdater.d.ts","sourceRoot":"","sources":["../../../../src/specs/NativeHotUpdater.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,IAAK,SAAQ,WAAW;IAEvC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAG3D,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,YAAY,EAAE,MAAM;QAC3B,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,OAAO,EAAE,MAAM,CAAC;QAChB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;KACjC,CAAC;CACH;;AAED,wBAAoE"}
1
+ {"version":3,"file":"NativeHotUpdater.d.ts","sourceRoot":"","sources":["../../../../src/specs/NativeHotUpdater.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB;;;;;;;;OAQG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,IAAK,SAAQ,WAAW;IAEvC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAG3D,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,YAAY,EAAE,MAAM;QAC3B,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,OAAO,EAAE,MAAM,CAAC;QAChB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;KACjC,CAAC;CACH;;AAED,wBAAoE"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Information about a signature verification failure.
3
+ * This is a security-critical event that indicates the bundle
4
+ * may have been tampered with or the public key is misconfigured.
5
+ */
6
+ export interface SignatureVerificationFailure {
7
+ /**
8
+ * The bundle ID that failed verification.
9
+ */
10
+ bundleId: string;
11
+ /**
12
+ * Human-readable error message from the native layer.
13
+ */
14
+ message: string;
15
+ /**
16
+ * The underlying error object.
17
+ */
18
+ error: Error;
19
+ }
20
+ /**
21
+ * Checks if an error is a signature verification failure.
22
+ * Matches error messages from both iOS and Android native implementations.
23
+ *
24
+ * **IMPORTANT**: This function relies on specific error message patterns from native code.
25
+ * If you change the error messages in the native implementations, update these patterns:
26
+ * - iOS: `ios/HotUpdater/Internal/SignatureVerifier.swift` (SignatureVerificationError)
27
+ * - Android: `android/src/main/java/com/hotupdater/SignatureVerifier.kt` (SignatureVerificationException)
28
+ */
29
+ export declare function isSignatureVerificationError(error: unknown): boolean;
30
+ /**
31
+ * Extracts signature verification failure details from an error.
32
+ */
33
+ export declare function extractSignatureFailure(error: unknown, bundleId: string): SignatureVerificationFailure;
34
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAgBpE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,GACf,4BAA4B,CAS9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/react-native",
3
- "version": "0.22.2",
3
+ "version": "0.23.1",
4
4
  "description": "React Native OTA solution for self-hosted",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -111,6 +111,7 @@
111
111
  },
112
112
  "devDependencies": {
113
113
  "@react-native-community/cli": "18.0.0",
114
+ "@types/node": "^22.10.5",
114
115
  "@types/react": "19.1.3",
115
116
  "@types/use-sync-external-store": "^0.0.6",
116
117
  "del-cli": "^6.0.0",
@@ -119,14 +120,14 @@
119
120
  "react-native": "0.79.1",
120
121
  "react-native-builder-bob": "^0.40.10",
121
122
  "typescript": "^5.8.3",
122
- "hot-updater": "0.22.2"
123
+ "hot-updater": "0.23.1"
123
124
  },
124
125
  "dependencies": {
125
126
  "use-sync-external-store": "1.5.0",
126
- "@hot-updater/core": "0.22.2",
127
- "@hot-updater/js": "0.22.2",
128
- "@hot-updater/plugin-core": "0.22.2",
129
- "@hot-updater/cli-tools": "0.22.2"
127
+ "@hot-updater/cli-tools": "0.23.1",
128
+ "@hot-updater/core": "0.23.1",
129
+ "@hot-updater/js": "0.23.1",
130
+ "@hot-updater/plugin-core": "0.23.1"
130
131
  },
131
132
  "scripts": {
132
133
  "build": "bob build && tsc -p plugin/tsconfig.build.json",
@@ -39,6 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
+ var node_path_1 = __importDefault(require("node:path"));
42
43
  var cli_tools_1 = require("@hot-updater/cli-tools");
43
44
  var config_plugins_1 = require("expo/config-plugins");
44
45
  var hot_updater_1 = require("hot-updater");
@@ -62,6 +63,36 @@ var getFingerprint = function () { return __awaiter(void 0, void 0, void 0, func
62
63
  }
63
64
  });
64
65
  }); };
66
+ /**
67
+ * Extract public key from private key in signing config
68
+ */
69
+ var getPublicKeyFromConfig = function (signingConfig) { return __awaiter(void 0, void 0, void 0, function () {
70
+ var privateKeyPath, privateKeyPEM, publicKeyPEM, error_1;
71
+ return __generator(this, function (_a) {
72
+ switch (_a.label) {
73
+ case 0:
74
+ if (!(signingConfig === null || signingConfig === void 0 ? void 0 : signingConfig.enabled) || !(signingConfig === null || signingConfig === void 0 ? void 0 : signingConfig.privateKeyPath)) {
75
+ return [2 /*return*/, null];
76
+ }
77
+ _a.label = 1;
78
+ case 1:
79
+ _a.trys.push([1, 3, , 4]);
80
+ privateKeyPath = node_path_1.default.isAbsolute(signingConfig.privateKeyPath)
81
+ ? signingConfig.privateKeyPath
82
+ : node_path_1.default.resolve(process.cwd(), signingConfig.privateKeyPath);
83
+ return [4 /*yield*/, (0, hot_updater_1.loadPrivateKey)(privateKeyPath)];
84
+ case 2:
85
+ privateKeyPEM = _a.sent();
86
+ publicKeyPEM = (0, hot_updater_1.getPublicKeyFromPrivate)(privateKeyPEM);
87
+ return [2 /*return*/, publicKeyPEM.trim()];
88
+ case 3:
89
+ error_1 = _a.sent();
90
+ throw new Error("[hot-updater] Failed to extract public key: ".concat(error_1 instanceof Error ? error_1.message : String(error_1), "\n") +
91
+ "Run 'npx hot-updater keys generate' to create signing keys");
92
+ case 4: return [2 /*return*/];
93
+ }
94
+ });
95
+ }); };
65
96
  /**
66
97
  * Native code modifications - should only run once
67
98
  */
@@ -91,7 +122,7 @@ var withHotUpdaterConfigAsync = function (props) { return function (config) {
91
122
  var modifiedConfig = config;
92
123
  // === iOS: Add channel and fingerprint to Info.plist ===
93
124
  modifiedConfig = (0, config_plugins_1.withInfoPlist)(modifiedConfig, function (cfg) { return __awaiter(void 0, void 0, void 0, function () {
94
- var fingerprintHash, config, fingerprint;
125
+ var fingerprintHash, config, fingerprint, publicKey;
95
126
  return __generator(this, function (_a) {
96
127
  switch (_a.label) {
97
128
  case 0:
@@ -105,18 +136,23 @@ var withHotUpdaterConfigAsync = function (props) { return function (config) {
105
136
  fingerprint = _a.sent();
106
137
  fingerprintHash = fingerprint.ios.hash;
107
138
  _a.label = 3;
108
- case 3:
139
+ case 3: return [4 /*yield*/, getPublicKeyFromConfig(config.signing)];
140
+ case 4:
141
+ publicKey = _a.sent();
109
142
  cfg.modResults.HOT_UPDATER_CHANNEL = channel;
110
143
  if (fingerprintHash) {
111
144
  cfg.modResults.HOT_UPDATER_FINGERPRINT_HASH = fingerprintHash;
112
145
  }
146
+ if (publicKey) {
147
+ cfg.modResults.HOT_UPDATER_PUBLIC_KEY = publicKey;
148
+ }
113
149
  return [2 /*return*/, cfg];
114
150
  }
115
151
  });
116
152
  }); });
117
153
  // === Android: Add channel and fingerprint to strings.xml ===
118
154
  modifiedConfig = (0, config_plugins_1.withStringsXml)(modifiedConfig, function (cfg) { return __awaiter(void 0, void 0, void 0, function () {
119
- var fingerprintHash, config, fingerprint;
155
+ var fingerprintHash, config, fingerprint, publicKey;
120
156
  return __generator(this, function (_a) {
121
157
  switch (_a.label) {
122
158
  case 0:
@@ -130,7 +166,9 @@ var withHotUpdaterConfigAsync = function (props) { return function (config) {
130
166
  fingerprint = _a.sent();
131
167
  fingerprintHash = fingerprint.android.hash;
132
168
  _a.label = 3;
133
- case 3:
169
+ case 3: return [4 /*yield*/, getPublicKeyFromConfig(config.signing)];
170
+ case 4:
171
+ publicKey = _a.sent();
134
172
  // Ensure resources object exists
135
173
  if (!cfg.modResults.resources) {
136
174
  cfg.modResults.resources = {};
@@ -163,6 +201,19 @@ var withHotUpdaterConfigAsync = function (props) { return function (config) {
163
201
  _: fingerprintHash,
164
202
  });
165
203
  }
204
+ if (publicKey) {
205
+ // Remove existing hot_updater_public_key entry if it exists
206
+ cfg.modResults.resources.string =
207
+ cfg.modResults.resources.string.filter(function (item) { return !(item.$ && item.$.name === "hot_updater_public_key"); });
208
+ // Add the new hot_updater_public_key entry
209
+ cfg.modResults.resources.string.push({
210
+ $: {
211
+ name: "hot_updater_public_key",
212
+ moduleConfig: "true",
213
+ },
214
+ _: publicKey,
215
+ });
216
+ }
166
217
  return [2 /*return*/, cfg];
167
218
  }
168
219
  });
@@ -81,7 +81,7 @@ export async function checkForUpdate(
81
81
  return updateBundle({
82
82
  bundleId: updateInfo.id,
83
83
  fileUrl: updateInfo.fileUrl,
84
- fileHash: updateInfo?.fileHash ?? null,
84
+ fileHash: updateInfo.fileHash,
85
85
  status: updateInfo.status,
86
86
  });
87
87
  },
package/src/index.ts CHANGED
@@ -15,6 +15,11 @@ import { wrap } from "./wrap";
15
15
 
16
16
  export type { HotUpdaterEvent } from "./native";
17
17
  export * from "./store";
18
+ export {
19
+ extractSignatureFailure,
20
+ isSignatureVerificationError,
21
+ type SignatureVerificationFailure,
22
+ } from "./types";
18
23
  export type { HotUpdaterOptions } from "./wrap";
19
24
 
20
25
  addListener("onProgress", ({ progress }) => {
@@ -5,8 +5,13 @@ export interface UpdateBundleParams {
5
5
  bundleId: string;
6
6
  fileUrl: string | null;
7
7
  /**
8
- * SHA256 hash of the bundle file for integrity verification.
9
- * If provided, the native layer will verify the downloaded file's hash.
8
+ * File hash for integrity/signature verification.
9
+ *
10
+ * Format depends on signing configuration:
11
+ * - Signed: `sig:<base64_signature>` - Native will verify signature (and implicitly hash)
12
+ * - Unsigned: `<hex_hash>` - Native will verify SHA256 hash only
13
+ *
14
+ * Native determines verification mode by checking for "sig:" prefix.
10
15
  */
11
16
  fileHash: string | null;
12
17
  }
package/src/types.ts ADDED
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Information about a signature verification failure.
3
+ * This is a security-critical event that indicates the bundle
4
+ * may have been tampered with or the public key is misconfigured.
5
+ */
6
+ export interface SignatureVerificationFailure {
7
+ /**
8
+ * The bundle ID that failed verification.
9
+ */
10
+ bundleId: string;
11
+ /**
12
+ * Human-readable error message from the native layer.
13
+ */
14
+ message: string;
15
+ /**
16
+ * The underlying error object.
17
+ */
18
+ error: Error;
19
+ }
20
+
21
+ /**
22
+ * Checks if an error is a signature verification failure.
23
+ * Matches error messages from both iOS and Android native implementations.
24
+ *
25
+ * **IMPORTANT**: This function relies on specific error message patterns from native code.
26
+ * If you change the error messages in the native implementations, update these patterns:
27
+ * - iOS: `ios/HotUpdater/Internal/SignatureVerifier.swift` (SignatureVerificationError)
28
+ * - Android: `android/src/main/java/com/hotupdater/SignatureVerifier.kt` (SignatureVerificationException)
29
+ */
30
+ export function isSignatureVerificationError(error: unknown): boolean {
31
+ if (!(error instanceof Error)) {
32
+ return false;
33
+ }
34
+
35
+ const message = error.message.toLowerCase();
36
+
37
+ // Match iOS SignatureVerificationError messages
38
+ // Match Android SignatureVerificationException messages
39
+ return (
40
+ message.includes("signature verification") ||
41
+ message.includes("public key not configured") ||
42
+ message.includes("public key format is invalid") ||
43
+ message.includes("signature format is invalid") ||
44
+ message.includes("bundle may be corrupted or tampered")
45
+ );
46
+ }
47
+
48
+ /**
49
+ * Extracts signature verification failure details from an error.
50
+ */
51
+ export function extractSignatureFailure(
52
+ error: unknown,
53
+ bundleId: string,
54
+ ): SignatureVerificationFailure {
55
+ const normalizedError =
56
+ error instanceof Error ? error : new Error(String(error));
57
+
58
+ return {
59
+ bundleId,
60
+ message: normalizedError.message,
61
+ error: normalizedError,
62
+ };
63
+ }