@gfean/react-native-bundle-drop 0.6.0 → 0.8.0

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 (86) hide show
  1. package/BundleDrop.podspec +96 -0
  2. package/README.md +249 -9
  3. package/android/build.gradle +72 -5
  4. package/android/src/main/java/com/bundledrop/BundleDropModule.kt +137 -13
  5. package/android/src/main/java/com/bundledrop/BundleDropNativePaths.kt +43 -13
  6. package/android/src/main/java/com/bundledrop/BundleDropOtaResolver.kt +35 -0
  7. package/android/src/main/java/com/bundledrop/BundleDropStartupRecovery.kt +1117 -0
  8. package/ios/BundleDropBridge.m +27 -0
  9. package/ios/BundleDropLocator.swift +31 -15
  10. package/ios/BundleDropModule.swift +106 -3
  11. package/ios/BundleDropOtaResolver.swift +137 -29
  12. package/ios/BundleDropStartupRecovery.swift +1108 -0
  13. package/ios/BundleDropStartupRecoveryAdapter.swift +301 -0
  14. package/lib/CLI/cli.js +9 -5
  15. package/lib/CLI/scripts/doctor.js +28 -9
  16. package/lib/CLI/scripts/expo/configure-expo.js +2 -1
  17. package/lib/CLI/scripts/init-config.d.ts +2 -2
  18. package/lib/CLI/scripts/init-config.js +23 -14
  19. package/lib/CLI/scripts/login-cli.js +2 -3
  20. package/lib/CLI/scripts/native/write-runtime-identity.d.ts +19 -0
  21. package/lib/CLI/scripts/native/write-runtime-identity.js +92 -0
  22. package/lib/CLI/scripts/sight-artifacts.d.ts +9 -1
  23. package/lib/CLI/scripts/sight-artifacts.js +20 -8
  24. package/lib/CLI/scripts/sight-assets.d.ts +15 -0
  25. package/lib/CLI/scripts/sight-assets.js +71 -0
  26. package/lib/CLI/scripts/sight-cli.d.ts +3 -0
  27. package/lib/CLI/scripts/sight-cli.js +50 -4
  28. package/lib/CLI/scripts/sight-compare/assets.d.ts +6 -0
  29. package/lib/CLI/scripts/sight-compare/assets.js +73 -0
  30. package/lib/CLI/scripts/sight-compare/dependencies.d.ts +22 -0
  31. package/lib/CLI/scripts/sight-compare/dependencies.js +289 -0
  32. package/lib/CLI/scripts/sight-compare/git.d.ts +22 -0
  33. package/lib/CLI/scripts/sight-compare/git.js +116 -0
  34. package/lib/CLI/scripts/sight-compare/inspect-project.d.ts +37 -0
  35. package/lib/CLI/scripts/sight-compare/inspect-project.js +191 -0
  36. package/lib/CLI/scripts/sight-compare/metadata.d.ts +4 -0
  37. package/lib/CLI/scripts/sight-compare/metadata.js +39 -0
  38. package/lib/CLI/scripts/sight-compare/process.d.ts +22 -0
  39. package/lib/CLI/scripts/sight-compare/process.js +221 -0
  40. package/lib/CLI/scripts/sight-compare/run.d.ts +3 -0
  41. package/lib/CLI/scripts/sight-compare/run.js +290 -0
  42. package/lib/CLI/scripts/sight-compare/snapshot.d.ts +26 -0
  43. package/lib/CLI/scripts/sight-compare/snapshot.js +279 -0
  44. package/lib/CLI/scripts/sight-compare/types.d.ts +87 -0
  45. package/lib/CLI/scripts/sight-compare/types.js +2 -0
  46. package/lib/CLI/scripts/sight-ota.d.ts +18 -0
  47. package/lib/CLI/scripts/sight-ota.js +260 -0
  48. package/lib/CLI/scripts/sight-session.d.ts +9 -2
  49. package/lib/CLI/scripts/sight-session.js +58 -20
  50. package/lib/CLI/scripts/upload-cli.d.ts +12 -2
  51. package/lib/CLI/scripts/upload-cli.js +74 -11
  52. package/lib/CLI/serverUrl.d.ts +3 -0
  53. package/lib/CLI/serverUrl.js +31 -0
  54. package/lib/bundleInfo.d.ts +2 -0
  55. package/lib/bundleInfo.js +16 -1
  56. package/lib/context.js +12 -2
  57. package/lib/fs/bundlePointer.d.ts +1 -17
  58. package/lib/fs/bundlePointer.js +5 -93
  59. package/lib/install/bundleInstallShared.js +4 -4
  60. package/lib/manager/downloadAndInstall.js +25 -22
  61. package/lib/manager/reporting.d.ts +8 -1
  62. package/lib/manager/reporting.js +17 -22
  63. package/lib/manager/rollbackState.d.ts +18 -54
  64. package/lib/manager/rollbackState.js +115 -216
  65. package/lib/manager/updateCheck.js +9 -3
  66. package/lib/manager/updateState.d.ts +2 -1
  67. package/lib/manager/updateState.js +59 -6
  68. package/lib/metro.d.ts +1 -1
  69. package/lib/metro.js +4 -3
  70. package/lib/native/bundleDropNative.d.ts +62 -0
  71. package/lib/native/bundleDropNative.js +266 -1
  72. package/lib/patch-engine/installFromPatchSet.js +2 -2
  73. package/lib/runtime/service.js +29 -71
  74. package/lib/runtime-delivery/bootstrapConfig.d.ts +29 -11
  75. package/lib/runtime-delivery/bootstrapConfig.js +83 -22
  76. package/lib/runtime-delivery/manifestState.d.ts +3 -1
  77. package/lib/runtime-delivery/manifestState.js +22 -1
  78. package/lib/runtime-delivery/manifestVerifier.js +7 -1
  79. package/lib/scripts/bundle.d.ts +12 -2
  80. package/lib/scripts/bundle.js +74 -21
  81. package/lib/scripts/download-bundle.d.ts +1 -0
  82. package/lib/scripts/download-bundle.js +2 -2
  83. package/lib/scripts/resolveModule.d.ts +2 -0
  84. package/lib/scripts/resolveModule.js +5 -0
  85. package/package.json +5 -2
  86. package/plugin/xcodeBuildPhase.js +2 -1
@@ -1,6 +1,8 @@
1
1
  export declare const RUNTIME_DELIVERY_BOOTSTRAP_SCHEMA_VERSION = 1;
2
2
  export declare const RUNTIME_DELIVERY_BOOTSTRAP_PATH: string;
3
- export declare const RUNTIME_DELIVERY_BOOTSTRAP_GITIGNORE_MARKER = "!.bundle-drop/runtime-delivery.generated.json";
3
+ export declare const LEGACY_RUNTIME_DELIVERY_BOOTSTRAP_PATH: string;
4
+ export declare const RUNTIME_DELIVERY_BOOTSTRAP_GITIGNORE_MARKER = "!.bundle-drop/runtime-delivery.lock.json";
5
+ export declare const LEGACY_RUNTIME_DELIVERY_BOOTSTRAP_GITIGNORE_MARKER = "!.bundle-drop/runtime-delivery.generated.json";
4
6
  export type RuntimeDeliveryPublicKey = {
5
7
  kty: 'EC';
6
8
  crv: 'P-256';
@@ -19,32 +21,48 @@ export type RuntimeDeliveryProjectIdentity = {
19
21
  projectId?: string;
20
22
  orgId?: string;
21
23
  };
22
- export type GeneratedRuntimeDeliveryBootstrap = {
24
+ export type RuntimeDeliveryBootstrapLockfile = {
23
25
  schemaVersion: typeof RUNTIME_DELIVERY_BOOTSTRAP_SCHEMA_VERSION;
24
26
  project: RuntimeDeliveryProjectIdentity;
25
27
  runtimeDelivery: RuntimeDeliveryConfig;
26
28
  };
29
+ export type RuntimeDeliveryBootstrapSource = 'lock' | 'legacy' | 'matching-dual';
30
+ export type RuntimeDeliveryBootstrapReadResult = {
31
+ bootstrap: RuntimeDeliveryBootstrapLockfile;
32
+ source: RuntimeDeliveryBootstrapSource;
33
+ };
27
34
  /**
28
35
  * Accepts the current backend-authorized trust shape and the temporary legacy
29
36
  * wire shape. Explicit legacy non-authoritative modes must never create a
30
37
  * package-managed bootstrap.
31
38
  */
32
39
  export declare function normalizeRuntimeDeliveryBootstrap(value: unknown): RuntimeDeliveryConfig | undefined;
33
- export declare function createGeneratedRuntimeDeliveryBootstrap(params: {
40
+ export declare function createRuntimeDeliveryBootstrapLockfile(params: {
34
41
  identity: RuntimeDeliveryProjectIdentity;
35
42
  runtimeDelivery: unknown;
36
- }): GeneratedRuntimeDeliveryBootstrap | undefined;
37
- export declare function parseGeneratedRuntimeDeliveryBootstrap(value: unknown, expectedIdentity?: RuntimeDeliveryProjectIdentity): GeneratedRuntimeDeliveryBootstrap;
43
+ }): RuntimeDeliveryBootstrapLockfile | undefined;
44
+ export declare function parseRuntimeDeliveryBootstrapLockfile(value: unknown, expectedIdentity?: RuntimeDeliveryProjectIdentity): RuntimeDeliveryBootstrapLockfile;
38
45
  export declare function runtimeDeliveryBootstrapPath(projectRoot: string): string;
46
+ export declare function legacyRuntimeDeliveryBootstrapPath(projectRoot: string): string;
39
47
  export declare function addRuntimeDeliveryBootstrapGitignoreRules(content: string): string;
40
- export declare function readGeneratedRuntimeDeliveryBootstrap(params: {
48
+ export declare function readRuntimeDeliveryLockfile(params: {
49
+ projectRoot: string;
50
+ expectedIdentity?: RuntimeDeliveryProjectIdentity;
51
+ }): RuntimeDeliveryBootstrapLockfile | null;
52
+ export declare function inspectRuntimeDeliveryBootstrap(params: {
53
+ projectRoot: string;
54
+ expectedIdentity?: RuntimeDeliveryProjectIdentity;
55
+ }): RuntimeDeliveryBootstrapReadResult | null;
56
+ export declare function readRuntimeDeliveryBootstrap(params: {
41
57
  projectRoot: string;
42
58
  expectedIdentity?: RuntimeDeliveryProjectIdentity;
43
- }): GeneratedRuntimeDeliveryBootstrap | null;
44
- export declare function serializeGeneratedRuntimeDeliveryBootstrap(bootstrap: GeneratedRuntimeDeliveryBootstrap): string;
45
- export declare function writeGeneratedRuntimeDeliveryBootstrap(params: {
59
+ }): RuntimeDeliveryBootstrapLockfile | null;
60
+ export declare function serializeRuntimeDeliveryBootstrapLockfile(bootstrap: RuntimeDeliveryBootstrapLockfile): string;
61
+ export declare function writeRuntimeDeliveryBootstrapLockfile(params: {
46
62
  projectRoot: string;
47
- bootstrap: GeneratedRuntimeDeliveryBootstrap;
63
+ bootstrap: RuntimeDeliveryBootstrapLockfile;
48
64
  }): Promise<string>;
49
- export declare function removeGeneratedRuntimeDeliveryBootstrap(projectRoot: string): Promise<string | null>;
65
+ export declare function removeRuntimeDeliveryBootstrapLockfile(projectRoot: string): Promise<string | null>;
66
+ export declare function removeLegacyRuntimeDeliveryBootstrap(projectRoot: string): Promise<string | null>;
67
+ export declare function removeAllRuntimeDeliveryBootstraps(projectRoot: string): Promise<string[]>;
50
68
  export declare function ensureRuntimeDeliveryBootstrapGitignore(projectRoot: string): Promise<string>;
@@ -3,23 +3,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.RUNTIME_DELIVERY_BOOTSTRAP_GITIGNORE_MARKER = exports.RUNTIME_DELIVERY_BOOTSTRAP_PATH = exports.RUNTIME_DELIVERY_BOOTSTRAP_SCHEMA_VERSION = void 0;
6
+ exports.LEGACY_RUNTIME_DELIVERY_BOOTSTRAP_GITIGNORE_MARKER = exports.RUNTIME_DELIVERY_BOOTSTRAP_GITIGNORE_MARKER = exports.LEGACY_RUNTIME_DELIVERY_BOOTSTRAP_PATH = exports.RUNTIME_DELIVERY_BOOTSTRAP_PATH = exports.RUNTIME_DELIVERY_BOOTSTRAP_SCHEMA_VERSION = void 0;
7
7
  exports.normalizeRuntimeDeliveryBootstrap = normalizeRuntimeDeliveryBootstrap;
8
- exports.createGeneratedRuntimeDeliveryBootstrap = createGeneratedRuntimeDeliveryBootstrap;
9
- exports.parseGeneratedRuntimeDeliveryBootstrap = parseGeneratedRuntimeDeliveryBootstrap;
8
+ exports.createRuntimeDeliveryBootstrapLockfile = createRuntimeDeliveryBootstrapLockfile;
9
+ exports.parseRuntimeDeliveryBootstrapLockfile = parseRuntimeDeliveryBootstrapLockfile;
10
10
  exports.runtimeDeliveryBootstrapPath = runtimeDeliveryBootstrapPath;
11
+ exports.legacyRuntimeDeliveryBootstrapPath = legacyRuntimeDeliveryBootstrapPath;
11
12
  exports.addRuntimeDeliveryBootstrapGitignoreRules = addRuntimeDeliveryBootstrapGitignoreRules;
12
- exports.readGeneratedRuntimeDeliveryBootstrap = readGeneratedRuntimeDeliveryBootstrap;
13
- exports.serializeGeneratedRuntimeDeliveryBootstrap = serializeGeneratedRuntimeDeliveryBootstrap;
14
- exports.writeGeneratedRuntimeDeliveryBootstrap = writeGeneratedRuntimeDeliveryBootstrap;
15
- exports.removeGeneratedRuntimeDeliveryBootstrap = removeGeneratedRuntimeDeliveryBootstrap;
13
+ exports.readRuntimeDeliveryLockfile = readRuntimeDeliveryLockfile;
14
+ exports.inspectRuntimeDeliveryBootstrap = inspectRuntimeDeliveryBootstrap;
15
+ exports.readRuntimeDeliveryBootstrap = readRuntimeDeliveryBootstrap;
16
+ exports.serializeRuntimeDeliveryBootstrapLockfile = serializeRuntimeDeliveryBootstrapLockfile;
17
+ exports.writeRuntimeDeliveryBootstrapLockfile = writeRuntimeDeliveryBootstrapLockfile;
18
+ exports.removeRuntimeDeliveryBootstrapLockfile = removeRuntimeDeliveryBootstrapLockfile;
19
+ exports.removeLegacyRuntimeDeliveryBootstrap = removeLegacyRuntimeDeliveryBootstrap;
20
+ exports.removeAllRuntimeDeliveryBootstraps = removeAllRuntimeDeliveryBootstraps;
16
21
  exports.ensureRuntimeDeliveryBootstrapGitignore = ensureRuntimeDeliveryBootstrapGitignore;
17
22
  const fs_extra_1 = __importDefault(require("fs-extra"));
18
23
  const path_1 = __importDefault(require("path"));
24
+ const util_1 = require("util");
19
25
  const safe_file_transaction_1 = require("../CLI/scripts/safe-file-transaction");
20
26
  exports.RUNTIME_DELIVERY_BOOTSTRAP_SCHEMA_VERSION = 1;
21
- exports.RUNTIME_DELIVERY_BOOTSTRAP_PATH = path_1.default.join('.bundle-drop', 'runtime-delivery.generated.json');
22
- exports.RUNTIME_DELIVERY_BOOTSTRAP_GITIGNORE_MARKER = '!.bundle-drop/runtime-delivery.generated.json';
27
+ exports.RUNTIME_DELIVERY_BOOTSTRAP_PATH = path_1.default.join('.bundle-drop', 'runtime-delivery.lock.json');
28
+ exports.LEGACY_RUNTIME_DELIVERY_BOOTSTRAP_PATH = path_1.default.join('.bundle-drop', 'runtime-delivery.generated.json');
29
+ exports.RUNTIME_DELIVERY_BOOTSTRAP_GITIGNORE_MARKER = '!.bundle-drop/runtime-delivery.lock.json';
30
+ exports.LEGACY_RUNTIME_DELIVERY_BOOTSTRAP_GITIGNORE_MARKER = '!.bundle-drop/runtime-delivery.generated.json';
23
31
  const RUNTIME_DELIVERY_BOOTSTRAP_GITIGNORE_BLOCK = [
24
32
  '# Bundle Drop: commit the public trust bootstrap; ignore generated runtime artifacts.',
25
33
  '!.bundle-drop/',
@@ -97,7 +105,7 @@ function normalizeRuntimeDeliveryBootstrap(value) {
97
105
  publicKeys,
98
106
  };
99
107
  }
100
- function createGeneratedRuntimeDeliveryBootstrap(params) {
108
+ function createRuntimeDeliveryBootstrapLockfile(params) {
101
109
  const runtimeDelivery = normalizeRuntimeDeliveryBootstrap(params.runtimeDelivery);
102
110
  const serverUrl = normalizeHttpUrl(params.identity.serverUrl);
103
111
  const orgSlug = params.identity.orgSlug.trim();
@@ -119,7 +127,7 @@ function createGeneratedRuntimeDeliveryBootstrap(params) {
119
127
  runtimeDelivery,
120
128
  };
121
129
  }
122
- function parseGeneratedRuntimeDeliveryBootstrap(value, expectedIdentity) {
130
+ function parseRuntimeDeliveryBootstrapLockfile(value, expectedIdentity) {
123
131
  if (!isRecord(value) || value.schemaVersion !== exports.RUNTIME_DELIVERY_BOOTSTRAP_SCHEMA_VERSION) {
124
132
  throw new Error(`Runtime delivery bootstrap must use schemaVersion ${exports.RUNTIME_DELIVERY_BOOTSTRAP_SCHEMA_VERSION}.`);
125
133
  }
@@ -136,7 +144,7 @@ function parseGeneratedRuntimeDeliveryBootstrap(value, expectedIdentity) {
136
144
  !value.project.orgId.trim()))) {
137
145
  throw new Error('Runtime delivery bootstrap contains an invalid stable project identity.');
138
146
  }
139
- const bootstrap = createGeneratedRuntimeDeliveryBootstrap({
147
+ const bootstrap = createRuntimeDeliveryBootstrapLockfile({
140
148
  identity: {
141
149
  serverUrl: typeof value.project.serverUrl === 'string' ? value.project.serverUrl : '',
142
150
  orgSlug: typeof value.project.orgSlug === 'string' ? value.project.orgSlug : '',
@@ -170,14 +178,26 @@ function parseGeneratedRuntimeDeliveryBootstrap(value, expectedIdentity) {
170
178
  function runtimeDeliveryBootstrapPath(projectRoot) {
171
179
  return path_1.default.join(projectRoot, exports.RUNTIME_DELIVERY_BOOTSTRAP_PATH);
172
180
  }
181
+ function legacyRuntimeDeliveryBootstrapPath(projectRoot) {
182
+ return path_1.default.join(projectRoot, exports.LEGACY_RUNTIME_DELIVERY_BOOTSTRAP_PATH);
183
+ }
184
+ const RUNTIME_DELIVERY_MANAGED_GITIGNORE_LINES = new Set([
185
+ '# Bundle Drop: commit the public trust bootstrap; ignore generated runtime artifacts.',
186
+ '!.bundle-drop/',
187
+ '.bundle-drop/*',
188
+ exports.RUNTIME_DELIVERY_BOOTSTRAP_GITIGNORE_MARKER,
189
+ exports.LEGACY_RUNTIME_DELIVERY_BOOTSTRAP_GITIGNORE_MARKER,
190
+ ]);
173
191
  function addRuntimeDeliveryBootstrapGitignoreRules(content) {
174
- if (content.includes(exports.RUNTIME_DELIVERY_BOOTSTRAP_GITIGNORE_MARKER))
175
- return content;
176
- const prefix = content.trimEnd();
192
+ const prefix = content
193
+ .split('\n')
194
+ .filter(line => !RUNTIME_DELIVERY_MANAGED_GITIGNORE_LINES.has(line.trim()))
195
+ .join('\n')
196
+ .trimEnd();
177
197
  return `${prefix}${prefix ? '\n\n' : ''}${RUNTIME_DELIVERY_BOOTSTRAP_GITIGNORE_BLOCK}\n`;
178
198
  }
179
- function readGeneratedRuntimeDeliveryBootstrap(params) {
180
- const bootstrapPath = runtimeDeliveryBootstrapPath(params.projectRoot);
199
+ function readRuntimeDeliveryBootstrapFile(params) {
200
+ const bootstrapPath = path_1.default.join(params.projectRoot, params.relativePath);
181
201
  if (!fs_extra_1.default.existsSync(bootstrapPath))
182
202
  return null;
183
203
  let value;
@@ -187,23 +207,64 @@ function readGeneratedRuntimeDeliveryBootstrap(params) {
187
207
  catch {
188
208
  throw new Error(`Runtime delivery bootstrap is not valid JSON: ${bootstrapPath}`);
189
209
  }
190
- return parseGeneratedRuntimeDeliveryBootstrap(value, params.expectedIdentity);
210
+ return parseRuntimeDeliveryBootstrapLockfile(value, params.expectedIdentity);
211
+ }
212
+ function readRuntimeDeliveryLockfile(params) {
213
+ return readRuntimeDeliveryBootstrapFile({
214
+ ...params,
215
+ relativePath: exports.RUNTIME_DELIVERY_BOOTSTRAP_PATH,
216
+ });
191
217
  }
192
- function serializeGeneratedRuntimeDeliveryBootstrap(bootstrap) {
218
+ function inspectRuntimeDeliveryBootstrap(params) {
219
+ const current = readRuntimeDeliveryLockfile(params);
220
+ const legacy = readRuntimeDeliveryBootstrapFile({
221
+ ...params,
222
+ relativePath: exports.LEGACY_RUNTIME_DELIVERY_BOOTSTRAP_PATH,
223
+ });
224
+ if (current && legacy) {
225
+ if (!(0, util_1.isDeepStrictEqual)(current, legacy)) {
226
+ throw new Error('Runtime delivery lockfile and legacy bootstrap differ. Run `bundle-drop sync` to repair them.');
227
+ }
228
+ return { bootstrap: current, source: 'matching-dual' };
229
+ }
230
+ if (current)
231
+ return { bootstrap: current, source: 'lock' };
232
+ if (legacy)
233
+ return { bootstrap: legacy, source: 'legacy' };
234
+ return null;
235
+ }
236
+ function readRuntimeDeliveryBootstrap(params) {
237
+ return inspectRuntimeDeliveryBootstrap(params)?.bootstrap ?? null;
238
+ }
239
+ function serializeRuntimeDeliveryBootstrapLockfile(bootstrap) {
193
240
  return `${JSON.stringify(bootstrap, null, 2)}\n`;
194
241
  }
195
- async function writeGeneratedRuntimeDeliveryBootstrap(params) {
242
+ async function writeRuntimeDeliveryBootstrapLockfile(params) {
196
243
  const bootstrapPath = runtimeDeliveryBootstrapPath(params.projectRoot);
197
- (0, safe_file_transaction_1.writeProjectFileAtomically)(params.projectRoot, exports.RUNTIME_DELIVERY_BOOTSTRAP_PATH, serializeGeneratedRuntimeDeliveryBootstrap(params.bootstrap));
244
+ (0, safe_file_transaction_1.writeProjectFileAtomically)(params.projectRoot, exports.RUNTIME_DELIVERY_BOOTSTRAP_PATH, serializeRuntimeDeliveryBootstrapLockfile(params.bootstrap));
198
245
  return bootstrapPath;
199
246
  }
200
- async function removeGeneratedRuntimeDeliveryBootstrap(projectRoot) {
247
+ async function removeRuntimeDeliveryBootstrapLockfile(projectRoot) {
201
248
  const bootstrapPath = runtimeDeliveryBootstrapPath(projectRoot);
202
249
  if (!(0, safe_file_transaction_1.inspectProjectFile)(projectRoot, exports.RUNTIME_DELIVERY_BOOTSTRAP_PATH).exists)
203
250
  return null;
204
251
  (0, safe_file_transaction_1.removeProjectFile)(projectRoot, exports.RUNTIME_DELIVERY_BOOTSTRAP_PATH);
205
252
  return bootstrapPath;
206
253
  }
254
+ async function removeLegacyRuntimeDeliveryBootstrap(projectRoot) {
255
+ const bootstrapPath = legacyRuntimeDeliveryBootstrapPath(projectRoot);
256
+ if (!(0, safe_file_transaction_1.inspectProjectFile)(projectRoot, exports.LEGACY_RUNTIME_DELIVERY_BOOTSTRAP_PATH).exists)
257
+ return null;
258
+ (0, safe_file_transaction_1.removeProjectFile)(projectRoot, exports.LEGACY_RUNTIME_DELIVERY_BOOTSTRAP_PATH);
259
+ return bootstrapPath;
260
+ }
261
+ async function removeAllRuntimeDeliveryBootstraps(projectRoot) {
262
+ const removed = await Promise.all([
263
+ removeRuntimeDeliveryBootstrapLockfile(projectRoot),
264
+ removeLegacyRuntimeDeliveryBootstrap(projectRoot),
265
+ ]);
266
+ return removed.filter((file) => Boolean(file));
267
+ }
207
268
  async function ensureRuntimeDeliveryBootstrapGitignore(projectRoot) {
208
269
  const gitignorePath = path_1.default.join(projectRoot, '.gitignore');
209
270
  const original = fs_extra_1.default.existsSync(gitignorePath)
@@ -5,5 +5,7 @@ export type VerifiedLaneState = {
5
5
  revokedHashes: string[];
6
6
  verifiedAt: string;
7
7
  };
8
+ export type PersistVerifiedRuntimeRevocations = (revokedHashes: string[]) => Promise<void>;
8
9
  export declare function readVerifiedLaneState(identity: RuntimeDeliveryLaneIdentity): Promise<VerifiedLaneState | null>;
9
- export declare function recordVerifiedLaneManifest(manifest: RuntimeDeliveryLaneManifest, payloadSha256: string): Promise<void>;
10
+ export declare function readVerifiedRuntimeRevokedHashes(identity: RuntimeDeliveryLaneIdentity): Promise<string[]>;
11
+ export declare function recordVerifiedLaneManifest(manifest: RuntimeDeliveryLaneManifest, payloadSha256: string, persistRuntimeRevocations?: PersistVerifiedRuntimeRevocations): Promise<void>;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.readVerifiedLaneState = readVerifiedLaneState;
7
+ exports.readVerifiedRuntimeRevokedHashes = readVerifiedRuntimeRevokedHashes;
7
8
  exports.recordVerifiedLaneManifest = recordVerifiedLaneManifest;
8
9
  const context_1 = require("../context");
9
10
  const fsUtils_1 = require("../fs/fsUtils");
@@ -59,6 +60,19 @@ function laneStateKey(identity) {
59
60
  .map(value => encodeURIComponent(value))
60
61
  .join('/');
61
62
  }
63
+ function belongsToRuntime(laneKey, identity) {
64
+ const parts = laneKey.split('/');
65
+ return parts.length === 4 &&
66
+ parts[0] === encodeURIComponent(identity.projectSlug) &&
67
+ parts[2] === encodeURIComponent(identity.platform) &&
68
+ parts[3] === encodeURIComponent(identity.runtimeVersion);
69
+ }
70
+ function verifiedRuntimeRevokedHashes(state, identity) {
71
+ const revokedHashes = Object.entries(state.lanes)
72
+ .filter(([key]) => belongsToRuntime(key, identity))
73
+ .flatMap(([, lane]) => lane.revokedHashes);
74
+ return Array.from(new Set(revokedHashes)).sort();
75
+ }
62
76
  async function readState() {
63
77
  if (!await fs_1.default.exists(STATE_PATH))
64
78
  return { schemaVersion: 1, lanes: {} };
@@ -75,7 +89,11 @@ async function readVerifiedLaneState(identity) {
75
89
  const state = await readState();
76
90
  return state.lanes[laneStateKey(identity)] || null;
77
91
  }
78
- async function recordVerifiedLaneManifest(manifest, payloadSha256) {
92
+ async function readVerifiedRuntimeRevokedHashes(identity) {
93
+ const state = await readState();
94
+ return verifiedRuntimeRevokedHashes(state, identity);
95
+ }
96
+ async function recordVerifiedLaneManifest(manifest, payloadSha256, persistRuntimeRevocations) {
79
97
  const mutation = stateMutation.then(async () => {
80
98
  const identity = manifest;
81
99
  const key = laneStateKey(identity);
@@ -95,6 +113,9 @@ async function recordVerifiedLaneManifest(manifest, payloadSha256) {
95
113
  revokedHashes: [...manifest.revokedHashes],
96
114
  verifiedAt: new Date().toISOString(),
97
115
  };
116
+ if (persistRuntimeRevocations) {
117
+ await persistRuntimeRevocations(verifiedRuntimeRevokedHashes(state, identity));
118
+ }
98
119
  await (0, fsUtils_1.atomicWriteJson)(STATE_PATH, state);
99
120
  });
100
121
  stateMutation = mutation.then(() => undefined, () => undefined);
@@ -7,6 +7,7 @@ exports.RuntimeDeliveryManifestError = exports.MAX_RUNTIME_MANIFEST_BYTES = void
7
7
  exports.verifyRuntimeDeliveryManifest = verifyRuntimeDeliveryManifest;
8
8
  exports.verifyRuntimeDeliverySignedPayload = verifyRuntimeDeliverySignedPayload;
9
9
  const fs_1 = __importDefault(require("../native/fs"));
10
+ const rollbackState_1 = require("../manager/rollbackState");
10
11
  const encoding_1 = require("./encoding");
11
12
  const manifestState_1 = require("./manifestState");
12
13
  const types_1 = require("./types");
@@ -293,7 +294,12 @@ async function verifyRuntimeDeliveryManifest(serializedJws, expectedIdentity, pu
293
294
  previousState.payloadSha256 !== payloadSha256) {
294
295
  throw new RuntimeDeliveryManifestError('generation_equivocation', 'Runtime manifest generation equivocation detected');
295
296
  }
296
- await (0, manifestState_1.recordVerifiedLaneManifest)(manifest, payloadSha256);
297
+ await (0, manifestState_1.recordVerifiedLaneManifest)(manifest, payloadSha256, async (runtimeRevokedHashes) => {
298
+ const persisted = await (0, rollbackState_1.syncVerifiedRevokedHashes)(runtimeRevokedHashes);
299
+ if (!persisted) {
300
+ throw new Error('Native startup recovery rejected the verified revocation set');
301
+ }
302
+ });
297
303
  return manifest;
298
304
  }
299
305
  async function verifyRuntimeDeliverySignedPayload(serializedJws, expectedType, publicKeys) {
@@ -1,11 +1,21 @@
1
1
  #!/usr/bin/env node
2
+ import { spawnSync } from 'child_process';
2
3
  import { findProjectRoot } from './projectRoot';
4
+ import { type ModuleResolver } from './resolveModule';
3
5
  export { findProjectRoot };
4
- export declare function runBundleScript(options?: {
6
+ type SpawnProcess = typeof spawnSync;
7
+ type BundleScriptOptions = {
5
8
  platform?: string;
6
9
  cwd?: string;
7
10
  sourcemap?: boolean;
8
- }): {
11
+ packageRoot?: string;
12
+ spawnProcess?: SpawnProcess;
13
+ resolveModule?: ModuleResolver;
14
+ };
15
+ export declare const buildHermesFlags: (hermescPath: string, generateSourceMap: boolean, spawnProcess: SpawnProcess) => string[];
16
+ export declare const detectHermesFromNativeProject: (projectRoot: string, platform: string) => boolean | undefined;
17
+ export declare const shouldCompileHermesBytecode: (cfg: Record<string, unknown>, platform: string, projectRoot: string) => boolean;
18
+ export declare function runBundleScript(options?: BundleScriptOptions): {
9
19
  outputDir: string;
10
20
  bundlePath: string;
11
21
  sourceMapPath?: string;
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  };
35
35
  })();
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.findProjectRoot = void 0;
37
+ exports.shouldCompileHermesBytecode = exports.detectHermesFromNativeProject = exports.buildHermesFlags = exports.findProjectRoot = void 0;
38
38
  exports.runBundleScript = runBundleScript;
39
39
  const child_process_1 = require("child_process");
40
40
  const fs = __importStar(require("fs"));
@@ -43,9 +43,31 @@ const bundleManifest_1 = require("../manifest/bundleManifest");
43
43
  const canonicalArtifact_1 = require("./canonicalArtifact");
44
44
  const projectRoot_1 = require("./projectRoot");
45
45
  Object.defineProperty(exports, "findProjectRoot", { enumerable: true, get: function () { return projectRoot_1.findProjectRoot; } });
46
+ const resolveModule_1 = require("./resolveModule");
46
47
  const SENTRY_HERMES_OTA_DOCS_URL = 'https://bundledrop.app/docs/observability#sentry-and-hermes-ota-builds';
47
48
  const SENTRY_DEBUG_ID_MARKERS = ['//# debugId=', 'sentry-dbid-'];
48
- const getPackageRoot = () => process.env.BUNDLE_DROP_PACKAGE_ROOT_OVERRIDE || path.resolve(__dirname, '..', '..');
49
+ const runProcess = (spawnProcess, executable, args, options) => {
50
+ const result = spawnProcess(executable, args, {
51
+ ...options,
52
+ shell: false,
53
+ });
54
+ if (result.error)
55
+ throw result.error;
56
+ if (result.status !== 0) {
57
+ const detail = typeof result.stderr === 'string' ? result.stderr.trim() : '';
58
+ throw new Error(detail || `${path.basename(executable)} exited with status ${result.status}`);
59
+ }
60
+ return result;
61
+ };
62
+ const assertGeneratedPath = (targetPath, outputDir) => {
63
+ const relative = path.relative(path.resolve(outputDir), path.resolve(targetPath));
64
+ const escapesOutput = relative === '..' ||
65
+ relative.startsWith(`..${path.sep}`) ||
66
+ path.isAbsolute(relative);
67
+ if (escapesOutput) {
68
+ throw new Error(`Generated artifact path escaped the package output directory: ${targetPath}`);
69
+ }
70
+ };
49
71
  const readTextIfExists = (filePath) => {
50
72
  if (!fs.existsSync(filePath))
51
73
  return null;
@@ -84,17 +106,21 @@ const readIosProjectSettings = (projectRoot) => {
84
106
  .filter((content) => Boolean(content));
85
107
  return contents.length ? contents.join('\n') : null;
86
108
  };
87
- const readHermesHelp = (hermescPath) => {
109
+ const readHermesHelp = (hermescPath, spawnProcess) => {
88
110
  try {
89
- return String((0, child_process_1.execSync)(`"${hermescPath}" -help`, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }));
111
+ const result = runProcess(spawnProcess, hermescPath, ['-help'], {
112
+ encoding: 'utf8',
113
+ stdio: ['ignore', 'pipe', 'pipe'],
114
+ });
115
+ return String(result.stdout || '');
90
116
  }
91
117
  catch {
92
118
  return '';
93
119
  }
94
120
  };
95
121
  const hermesHelpIncludesFlag = (help, flag) => new RegExp(`(?:^|\\n)\\s*${flag.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?:\\s|=)`).test(help);
96
- const buildHermesFlags = (hermescPath, generateSourceMap) => {
97
- const help = readHermesHelp(hermescPath);
122
+ const buildHermesFlags = (hermescPath, generateSourceMap, spawnProcess) => {
123
+ const help = readHermesHelp(hermescPath, spawnProcess);
98
124
  const flags = ['-emit-binary'];
99
125
  if (hermesHelpIncludesFlag(help, '-O')) {
100
126
  flags.push('-O');
@@ -107,6 +133,7 @@ const buildHermesFlags = (hermescPath, generateSourceMap) => {
107
133
  }
108
134
  return flags;
109
135
  };
136
+ exports.buildHermesFlags = buildHermesFlags;
110
137
  const promoteHermesBytecode = (hbcPath, bundlePath) => {
111
138
  if (!fs.existsSync(hbcPath)) {
112
139
  throw new Error(`Hermes compiler did not write bytecode output at ${hbcPath}`);
@@ -154,12 +181,13 @@ const detectHermesFromNativeProject = (projectRoot, platform) => {
154
181
  /\bUSE_HERMES\s*=\s*false\s*;/,
155
182
  ]);
156
183
  };
184
+ exports.detectHermesFromNativeProject = detectHermesFromNativeProject;
157
185
  const shouldCompileHermesBytecode = (cfg, platform, projectRoot) => {
158
186
  const explicit = readPlatformSetting(cfg.hermesBytecode, platform) ??
159
187
  readPlatformSetting(cfg.hermes, platform);
160
188
  if (typeof explicit === 'boolean')
161
189
  return explicit;
162
- const detected = detectHermesFromNativeProject(projectRoot, platform);
190
+ const detected = (0, exports.detectHermesFromNativeProject)(projectRoot, platform);
163
191
  if (detected !== undefined)
164
192
  return detected;
165
193
  if (explicit === 'auto') {
@@ -167,8 +195,11 @@ const shouldCompileHermesBytecode = (cfg, platform, projectRoot) => {
167
195
  }
168
196
  return false;
169
197
  };
170
- function runBundleScript(options) {
171
- const packageRoot = getPackageRoot();
198
+ exports.shouldCompileHermesBytecode = shouldCompileHermesBytecode;
199
+ function runBundleScript(options = {}) {
200
+ const packageRoot = options.packageRoot || path.resolve(__dirname, '..', '..');
201
+ const spawnProcess = options.spawnProcess || child_process_1.spawnSync;
202
+ const resolveModule = options.resolveModule || resolveModule_1.resolveModuleFrom;
172
203
  const platform = options?.platform || process.argv[2] || 'ios';
173
204
  if (!['ios', 'android'].includes(platform)) {
174
205
  console.error('❌ Please provide platform: ios or android');
@@ -203,24 +234,46 @@ function runBundleScript(options) {
203
234
  console.error('❌ BUNDLE_DROP_APP_VERSION is required so bundle-manifest.json can include the app version');
204
235
  process.exit(1);
205
236
  }
206
- const hermesEnabled = shouldCompileHermesBytecode(cfg, platform, projectRoot);
237
+ const hermesEnabled = (0, exports.shouldCompileHermesBytecode)(cfg, platform, projectRoot);
207
238
  [bundlePath, zipPath, metadataPath, manifestPath, sourceMapPath].forEach(file => {
239
+ assertGeneratedPath(file, outputDir);
208
240
  if (fs.existsSync(file))
209
241
  fs.unlinkSync(file);
210
242
  });
243
+ assertGeneratedPath(assetsDir, outputDir);
211
244
  if (fs.existsSync(assetsDir))
212
245
  fs.rmSync(assetsDir, { recursive: true, force: true });
213
246
  fs.mkdirSync(outputDir, { recursive: true });
214
247
  fs.mkdirSync(assetsDir, { recursive: true });
215
248
  console.log(`📦 Bundling React Native code for platform: ${platform}...`);
216
- const sourcemapFlag = generateSourceMap ? ` \\\n --sourcemap-output "${sourceMapPath}"` : '';
217
- (0, child_process_1.execSync)(`npx react-native bundle \
218
- --platform ${platform} \
219
- --dev false \
220
- --entry-file index.js \
221
- --bundle-output "${bundlePath}" \
222
- --assets-dest "${assetsDir}" \
223
- --reset-cache${sourcemapFlag}`, {
249
+ const reactNativePackageJson = resolveModule('react-native/package.json', [
250
+ projectRoot,
251
+ packageRoot,
252
+ __dirname,
253
+ ]);
254
+ const reactNativeCli = path.join(path.dirname(reactNativePackageJson), 'cli.js');
255
+ if (!fs.existsSync(reactNativeCli)) {
256
+ throw new Error(`React Native CLI entrypoint is missing: ${reactNativeCli}`);
257
+ }
258
+ const reactNativeArgs = [
259
+ reactNativeCli,
260
+ 'bundle',
261
+ '--platform',
262
+ platform,
263
+ '--dev',
264
+ 'false',
265
+ '--entry-file',
266
+ 'index.js',
267
+ '--bundle-output',
268
+ bundlePath,
269
+ '--assets-dest',
270
+ assetsDir,
271
+ '--reset-cache',
272
+ ];
273
+ if (generateSourceMap) {
274
+ reactNativeArgs.push('--sourcemap-output', sourceMapPath);
275
+ }
276
+ runProcess(spawnProcess, process.execPath, reactNativeArgs, {
224
277
  stdio: 'inherit',
225
278
  env: {
226
279
  ...process.env,
@@ -244,8 +297,8 @@ function runBundleScript(options) {
244
297
  const hbcPath = bundlePath + '.hbc';
245
298
  try {
246
299
  console.log(`🔥 Compiling to Hermes bytecode (${platform})...`);
247
- const hermesFlags = buildHermesFlags(hermescPath, generateSourceMap).join(' ');
248
- (0, child_process_1.execSync)(`"${hermescPath}" ${hermesFlags} -out "${hbcPath}" "${bundlePath}"`, { stdio: ['ignore', 'ignore', 'ignore'] });
300
+ const hermesFlags = (0, exports.buildHermesFlags)(hermescPath, generateSourceMap, spawnProcess);
301
+ runProcess(spawnProcess, hermescPath, [...hermesFlags, '-out', hbcPath, bundlePath], { stdio: ['ignore', 'ignore', 'ignore'] });
249
302
  promoteHermesBytecode(hbcPath, bundlePath);
250
303
  console.log('✅ Hermes bytecode compiled');
251
304
  }
@@ -259,7 +312,7 @@ function runBundleScript(options) {
259
312
  if (fs.existsSync(composeScript)) {
260
313
  try {
261
314
  const composedPath = sourceMapPath + '.composed';
262
- (0, child_process_1.execSync)(`node "${composeScript}" "${sourceMapPath}" "${hermesMapPath}" -o "${composedPath}"`, { stdio: ['ignore', 'ignore', 'ignore'] });
315
+ runProcess(spawnProcess, process.execPath, [composeScript, sourceMapPath, hermesMapPath, '-o', composedPath], { stdio: ['ignore', 'ignore', 'ignore'] });
263
316
  fs.renameSync(composedPath, sourceMapPath);
264
317
  console.log('✅ Source maps composed');
265
318
  }
@@ -2,4 +2,5 @@
2
2
  export declare function runDownloadBundle(options?: {
3
3
  argv?: string[];
4
4
  cwd?: string;
5
+ packageRoot?: string;
5
6
  }): Promise<string>;
@@ -41,9 +41,9 @@ exports.runDownloadBundle = runDownloadBundle;
41
41
  const axios_1 = __importDefault(require("axios"));
42
42
  const fs = __importStar(require("fs"));
43
43
  const path = __importStar(require("path"));
44
- const getPackageRoot = () => process.env.BUNDLE_DROP_PACKAGE_ROOT_OVERRIDE || path.resolve(__dirname, '..', '..');
45
44
  async function runDownloadBundle(options) {
46
- const outputDir = path.join(getPackageRoot(), 'dist');
45
+ const packageRoot = options?.packageRoot || path.resolve(__dirname, '..', '..');
46
+ const outputDir = path.join(packageRoot, 'dist');
47
47
  const argv = options?.argv || process.argv;
48
48
  const platform = argv[2];
49
49
  if (!platform || !['ios', 'android'].includes(platform)) {
@@ -0,0 +1,2 @@
1
+ export type ModuleResolver = (moduleId: string, searchPaths: string[]) => string;
2
+ export declare const resolveModuleFrom: ModuleResolver;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveModuleFrom = void 0;
4
+ const resolveModuleFrom = (moduleId, searchPaths) => require.resolve(moduleId, { paths: searchPaths });
5
+ exports.resolveModuleFrom = resolveModuleFrom;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gfean/react-native-bundle-drop",
3
- "version": "0.6.0",
4
- "nativeVersion": "0.5.0",
3
+ "version": "0.8.0",
4
+ "nativeVersion": "0.6.0",
5
5
  "description": "Over-the-air updates for Expo and bare React Native apps, with channels, staged rollouts, patch delivery, and rollback.",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -47,6 +47,9 @@
47
47
  "test:expo:plugin": "node --test plugin/__tests__/*.test.js",
48
48
  "package:check": "node scripts/check-package-contents.cjs",
49
49
  "audit:production": "yarn npm audit --environment production --recursive --severity high",
50
+ "codeql:local:fast": "node scripts/run-codeql-local.cjs fast",
51
+ "codeql:local:full": "node scripts/run-codeql-local.cjs full",
52
+ "codeql:local:compare": "node scripts/run-codeql-local.cjs compare",
50
53
  "verify:quick": "yarn build && yarn coverage:gate && yarn test:expo:plugin && yarn package:check",
51
54
  "verify:native": "yarn test:android && yarn test:ios",
52
55
  "verify:release": "yarn verify:quick && yarn verify:native && yarn audit:production",
@@ -28,7 +28,8 @@ function updatePhase(project, phaseUuid) {
28
28
  const phase = project.hash.project.objects.PBXShellScriptBuildPhase[phaseUuid];
29
29
  phase.name = `"${PHASE_NAME}"`;
30
30
  phase.shellPath = '/bin/sh';
31
- phase.shellScript = `"${SHELL_SCRIPT.replace(/"/g, '\\"')}"`;
31
+ const escapedShellScript = SHELL_SCRIPT.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
32
+ phase.shellScript = `"${escapedShellScript}"`;
32
33
  }
33
34
 
34
35
  function movePhaseToEnd(target, phaseUuid) {