@gfean/react-native-bundle-drop 0.5.1 → 0.6.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.
- package/README.md +168 -4
- package/android/build.gradle +1 -0
- package/android/src/main/java/com/bundledrop/BundleDropBoundedDownloader.kt +86 -0
- package/android/src/main/java/com/bundledrop/BundleDropModule.kt +69 -0
- package/android/src/main/java/com/bundledrop/BundleDropRuntimeCrypto.kt +81 -0
- package/ios/BundleDropBridge.m +18 -0
- package/ios/BundleDropLocator.swift +48 -2
- package/ios/BundleDropModule.swift +75 -0
- package/ios/BundleDropRuntimeCrypto.swift +45 -0
- package/lib/CLI/cli.d.ts +1 -0
- package/lib/CLI/cli.js +54 -2
- package/lib/CLI/scripts/aipowered/apply-setup-plan.js +7 -17
- package/lib/CLI/scripts/aipowered/backend-client.js +29 -4
- package/lib/CLI/scripts/aipowered/code-push-residue.d.ts +5 -0
- package/lib/CLI/scripts/aipowered/code-push-residue.js +126 -0
- package/lib/CLI/scripts/aipowered/credential-safety.d.ts +1 -0
- package/lib/CLI/scripts/aipowered/credential-safety.js +14 -0
- package/lib/CLI/scripts/aipowered/diff-preview.js +12 -4
- package/lib/CLI/scripts/aipowered/init-project-config.d.ts +4 -0
- package/lib/CLI/scripts/aipowered/init-project-config.js +221 -45
- package/lib/CLI/scripts/aipowered/scanner.d.ts +1 -0
- package/lib/CLI/scripts/aipowered/scanner.js +164 -32
- package/lib/CLI/scripts/aipowered/terminal-safety.d.ts +4 -0
- package/lib/CLI/scripts/aipowered/terminal-safety.js +124 -0
- package/lib/CLI/scripts/aipowered/validate-plan.d.ts +3 -0
- package/lib/CLI/scripts/aipowered/validate-plan.js +1080 -19
- package/lib/CLI/scripts/bare-metro-config.d.ts +1 -1
- package/lib/CLI/scripts/bare-metro-config.js +24 -32
- package/lib/CLI/scripts/doctor.js +143 -22
- package/lib/CLI/scripts/expo/configure-expo.js +51 -60
- package/lib/CLI/scripts/expo/package-manager.d.ts +2 -0
- package/lib/CLI/scripts/expo/package-manager.js +63 -25
- package/lib/CLI/scripts/init-config.d.ts +7 -7
- package/lib/CLI/scripts/init-config.js +185 -10
- package/lib/CLI/scripts/login-cli.js +29 -4
- package/lib/CLI/scripts/metro-config-authority.d.ts +8 -0
- package/lib/CLI/scripts/metro-config-authority.js +303 -0
- package/lib/CLI/scripts/native-entrypoint-authority.d.ts +2 -0
- package/lib/CLI/scripts/native-entrypoint-authority.js +378 -0
- package/lib/CLI/scripts/native-setup-contract.d.ts +2 -2
- package/lib/CLI/scripts/native-setup-contract.js +63 -33
- package/lib/CLI/scripts/native-startup-validator.d.ts +3 -0
- package/lib/CLI/scripts/native-startup-validator.js +964 -0
- package/lib/CLI/scripts/safe-file-transaction.d.ts +12 -0
- package/lib/CLI/scripts/safe-file-transaction.js +159 -0
- package/lib/api/clientApi.d.ts +3 -1
- package/lib/api/clientApi.js +14 -0
- package/lib/api/types.d.ts +39 -0
- package/lib/context.d.ts +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/lib/install/installFromZip.d.ts +3 -0
- package/lib/install/installFromZip.js +10 -1
- package/lib/loadConfig.d.ts +17 -1
- package/lib/loadConfig.js +16 -0
- package/lib/manager/downloadAndInstall.d.ts +3 -2
- package/lib/manager/downloadAndInstall.js +111 -46
- package/lib/manager/rollbackState.d.ts +3 -1
- package/lib/manager/rollbackState.js +2 -2
- package/lib/manager/updateCheck.d.ts +1 -0
- package/lib/manager/updateCheck.js +218 -78
- package/lib/metro.d.ts +8 -1
- package/lib/metro.js +68 -19
- package/lib/native/bundleDropNative.js +2 -1
- package/lib/native/fs.d.ts +6 -0
- package/lib/native/fs.js +24 -0
- package/lib/patch-engine/installFromPatchSet.d.ts +2 -0
- package/lib/patch-engine/installFromPatchSet.js +14 -3
- package/lib/patch-engine/patchTransport.d.ts +2 -0
- package/lib/patch-engine/patchTransport.js +9 -0
- package/lib/runtime/initState.d.ts +5 -0
- package/lib/runtime/initState.js +4 -0
- package/lib/runtime/service.js +60 -3
- package/lib/runtime-delivery/artifactCapability.d.ts +1 -0
- package/lib/runtime-delivery/artifactCapability.js +32 -0
- package/lib/runtime-delivery/authorityLeaseVerifier.d.ts +3 -0
- package/lib/runtime-delivery/authorityLeaseVerifier.js +106 -0
- package/lib/runtime-delivery/bootstrapConfig.d.ts +50 -0
- package/lib/runtime-delivery/bootstrapConfig.js +217 -0
- package/lib/runtime-delivery/diagnostics.d.ts +17 -0
- package/lib/runtime-delivery/diagnostics.js +58 -0
- package/lib/runtime-delivery/encoding.d.ts +5 -0
- package/lib/runtime-delivery/encoding.js +132 -0
- package/lib/runtime-delivery/heartbeat.d.ts +3 -0
- package/lib/runtime-delivery/heartbeat.js +88 -0
- package/lib/runtime-delivery/localResolver.d.ts +23 -0
- package/lib/runtime-delivery/localResolver.js +81 -0
- package/lib/runtime-delivery/manifestState.d.ts +9 -0
- package/lib/runtime-delivery/manifestState.js +102 -0
- package/lib/runtime-delivery/manifestVerifier.d.ts +13 -0
- package/lib/runtime-delivery/manifestVerifier.js +329 -0
- package/lib/runtime-delivery/runtimeDelivery.d.ts +19 -0
- package/lib/runtime-delivery/runtimeDelivery.js +375 -0
- package/lib/runtime-delivery/types.d.ts +87 -0
- package/lib/runtime-delivery/types.js +6 -0
- package/package.json +2 -2
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import CryptoKit
|
|
2
|
+
import Foundation
|
|
3
|
+
|
|
4
|
+
enum BundleDropRuntimeCrypto {
|
|
5
|
+
static func sha256String(_ value: String) -> String {
|
|
6
|
+
SHA256.hash(data: Data(value.utf8)).map { String(format: "%02x", $0) }.joined()
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static func verifyEs256Signature(
|
|
10
|
+
signingInput: String,
|
|
11
|
+
signatureBase64Url: String,
|
|
12
|
+
xBase64Url: String,
|
|
13
|
+
yBase64Url: String
|
|
14
|
+
) throws -> Bool {
|
|
15
|
+
let signatureBytes = try decodeBase64Url(signatureBase64Url)
|
|
16
|
+
let x = try decodeBase64Url(xBase64Url)
|
|
17
|
+
let y = try decodeBase64Url(yBase64Url)
|
|
18
|
+
guard signatureBytes.count == 64 else {
|
|
19
|
+
throw error("ES256 signature must be 64 bytes")
|
|
20
|
+
}
|
|
21
|
+
guard x.count == 32 && y.count == 32 else {
|
|
22
|
+
throw error("P-256 coordinates must be 32 bytes")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let publicKey = try P256.Signing.PublicKey(
|
|
26
|
+
x963Representation: Data([0x04]) + x + y
|
|
27
|
+
)
|
|
28
|
+
let signature = try P256.Signing.ECDSASignature(rawRepresentation: signatureBytes)
|
|
29
|
+
return publicKey.isValidSignature(signature, for: Data(signingInput.utf8))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private static func decodeBase64Url(_ value: String) throws -> Data {
|
|
33
|
+
var normalized = value.replacingOccurrences(of: "-", with: "+")
|
|
34
|
+
.replacingOccurrences(of: "_", with: "/")
|
|
35
|
+
normalized += String(repeating: "=", count: (4 - normalized.count % 4) % 4)
|
|
36
|
+
guard let data = Data(base64Encoded: normalized) else {
|
|
37
|
+
throw error("Invalid base64url value")
|
|
38
|
+
}
|
|
39
|
+
return data
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private static func error(_ message: String) -> NSError {
|
|
43
|
+
NSError(domain: "BundleDrop", code: 1, userInfo: [NSLocalizedDescriptionKey: message])
|
|
44
|
+
}
|
|
45
|
+
}
|
package/lib/CLI/cli.d.ts
CHANGED
package/lib/CLI/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.buildProgram = void 0;
|
|
7
|
+
exports.runCli = exports.buildProgram = void 0;
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
10
|
const commander_1 = require("commander");
|
|
@@ -183,6 +183,7 @@ ${chalk_1.default.gray('CI/CD docs →')} ${chalk_1.default.underline.gray(DOCS_
|
|
|
183
183
|
.option('--token <token>', 'Personal Access Token (alternative to `bundle-drop login`)')
|
|
184
184
|
.option('--project-type <type>', 'Force project type: expo or bare')
|
|
185
185
|
.option('--dry-run', 'Preview setup and AI context without changing files')
|
|
186
|
+
.option('--migrate-code-push', 'Explicitly remove react-native-code-push after reviewing its native migration')
|
|
186
187
|
.option('--migrate-expo-updates', 'Explicitly remove active expo-updates configuration and dependency')
|
|
187
188
|
.option('--prebuild', 'Run a layered Expo prebuild for committed native directories')
|
|
188
189
|
.option('--yes', 'Approve ordinary setup changes noninteractively')
|
|
@@ -217,6 +218,9 @@ ${chalk_1.default.gray('CI/CD docs →')} ${chalk_1.default.underline.gray(DOCS_
|
|
|
217
218
|
options: {
|
|
218
219
|
...options,
|
|
219
220
|
projectType,
|
|
221
|
+
...(configResult?.bootstrapContent
|
|
222
|
+
? { runtimeDeliveryBootstrap: { content: configResult.bootstrapContent } }
|
|
223
|
+
: {}),
|
|
220
224
|
...(!hadConfig && configResult
|
|
221
225
|
? {
|
|
222
226
|
virtualConfig: {
|
|
@@ -279,6 +283,9 @@ ${chalk_1.default.gray('CI/CD docs →')} ${chalk_1.default.underline.gray(DOCS_
|
|
|
279
283
|
options: {
|
|
280
284
|
...options,
|
|
281
285
|
projectType,
|
|
286
|
+
...(configResult?.bootstrapContent
|
|
287
|
+
? { runtimeDeliveryBootstrap: { content: configResult.bootstrapContent } }
|
|
288
|
+
: {}),
|
|
282
289
|
...(!hadConfig && configResult
|
|
283
290
|
? {
|
|
284
291
|
virtualConfig: {
|
|
@@ -295,6 +302,40 @@ ${chalk_1.default.gray('CI/CD docs →')} ${chalk_1.default.underline.gray(DOCS_
|
|
|
295
302
|
preservePendingConfig: !hadConfig && !options.dryRun,
|
|
296
303
|
});
|
|
297
304
|
});
|
|
305
|
+
program
|
|
306
|
+
.command('sync')
|
|
307
|
+
.option('--token <token>', 'Personal Access Token (alternative to `bundle-drop login`)')
|
|
308
|
+
.option('--dry-run', 'Validate and preview bootstrap synchronization without writing')
|
|
309
|
+
.description('Refresh the package-managed runtime delivery bootstrap')
|
|
310
|
+
.action(async (options) => {
|
|
311
|
+
const initConfigModule = require('../CLI/scripts/init-config');
|
|
312
|
+
if (!initConfigModule.hasExistingBundleDropConfig()) {
|
|
313
|
+
throw new Error('bundle-drop sync requires bundle.drop.config.js. Run `bundle-drop init` first.');
|
|
314
|
+
}
|
|
315
|
+
const authState = options.token ? null : readStoredAuthData();
|
|
316
|
+
const token = options.token || authState?.data?.token;
|
|
317
|
+
if (!token) {
|
|
318
|
+
throw new Error('Not authenticated. Run `bundle-drop login` or pass --token.');
|
|
319
|
+
}
|
|
320
|
+
const serverUrl = normalizeServerUrl(authState?.data?.serverUrl || authState?.data?.baseUrl || process.env.BUNDLE_DROP_SERVER_URL);
|
|
321
|
+
const result = await initConfigModule.initConfig({
|
|
322
|
+
serverUrl,
|
|
323
|
+
projects: [],
|
|
324
|
+
organizations: [],
|
|
325
|
+
authToken: token,
|
|
326
|
+
dryRun: Boolean(options.dryRun),
|
|
327
|
+
});
|
|
328
|
+
const deliveryDisabled = result?.bootstrapRetired === true;
|
|
329
|
+
if (!result?.bootstrapContent && !deliveryDisabled) {
|
|
330
|
+
throw new Error('The backend did not return a valid runtime delivery bootstrap for this project. ' +
|
|
331
|
+
'The existing bootstrap was preserved.');
|
|
332
|
+
}
|
|
333
|
+
if (options.dryRun) {
|
|
334
|
+
console.log(chalk_1.default.gray(deliveryDisabled
|
|
335
|
+
? 'Runtime delivery is disabled; the stale bootstrap would be removed. No files changed.'
|
|
336
|
+
: 'Runtime delivery bootstrap is valid. No files changed.'));
|
|
337
|
+
}
|
|
338
|
+
});
|
|
298
339
|
program
|
|
299
340
|
.command('doctor')
|
|
300
341
|
.option('--platform <platform>', 'Limit checks to ios or android')
|
|
@@ -356,6 +397,17 @@ ${chalk_1.default.bold('Examples:')}
|
|
|
356
397
|
return program;
|
|
357
398
|
};
|
|
358
399
|
exports.buildProgram = buildProgram;
|
|
400
|
+
const runCli = async (argv = process.argv) => {
|
|
401
|
+
try {
|
|
402
|
+
await (0, exports.buildProgram)().parseAsync(argv);
|
|
403
|
+
}
|
|
404
|
+
catch (error) {
|
|
405
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
406
|
+
console.error(chalk_1.default.red(`❌ ${message}`));
|
|
407
|
+
process.exitCode = 1;
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
exports.runCli = runCli;
|
|
359
411
|
if (require.main === module) {
|
|
360
|
-
(0, exports.
|
|
412
|
+
void (0, exports.runCli)();
|
|
361
413
|
}
|
|
@@ -6,26 +6,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.restoreSetupBackups = restoreSetupBackups;
|
|
7
7
|
exports.applySetupPatchPlans = applySetupPatchPlans;
|
|
8
8
|
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
9
|
const validate_plan_1 = require("./validate-plan");
|
|
10
|
+
const safe_file_transaction_1 = require("../safe-file-transaction");
|
|
12
11
|
const sha256 = (content) => crypto_1.default.createHash('sha256').update(content).digest('hex');
|
|
13
|
-
const timestamp = () => new Date().toISOString().replace(/[:.]/g, '-');
|
|
14
12
|
const isAllowedSetupFile = (projectType, filePath) => projectType === 'expo'
|
|
15
13
|
? (0, validate_plan_1.isPatchableExpoConfig)(filePath)
|
|
16
14
|
: (0, validate_plan_1.isPatchableNativeEntrypoint)(filePath);
|
|
17
15
|
function restoreSetupBackups(result) {
|
|
18
16
|
for (const relativePath of result.changedFiles) {
|
|
19
|
-
|
|
20
|
-
if (fs_extra_1.default.existsSync(backupPath)) {
|
|
21
|
-
fs_extra_1.default.copyFileSync(backupPath, path_1.default.join(result.projectRoot, relativePath));
|
|
22
|
-
}
|
|
17
|
+
(0, safe_file_transaction_1.restoreProjectFile)(result.projectRoot, result.backupDir, relativePath);
|
|
23
18
|
}
|
|
24
19
|
}
|
|
25
20
|
function applySetupPatchPlans(params) {
|
|
26
21
|
const result = {
|
|
27
22
|
projectRoot: params.projectRoot,
|
|
28
|
-
backupDir:
|
|
23
|
+
backupDir: (0, safe_file_transaction_1.createSafeBackupDirectory)(params.projectRoot, 'ai-setup'),
|
|
29
24
|
changedFiles: [],
|
|
30
25
|
};
|
|
31
26
|
try {
|
|
@@ -33,18 +28,13 @@ function applySetupPatchPlans(params) {
|
|
|
33
28
|
if (!(0, validate_plan_1.isSafeRelativePath)(change.file) || !isAllowedSetupFile(params.projectType, change.file)) {
|
|
34
29
|
throw new Error(`Refusing to write AI setup plan outside its allowlist: ${change.file}`);
|
|
35
30
|
}
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
if (sha256(original) !== change.originalSha256) {
|
|
31
|
+
const target = (0, safe_file_transaction_1.inspectProjectFile)(params.projectRoot, change.file);
|
|
32
|
+
if (!target.exists || sha256(target.content) !== change.originalSha256) {
|
|
39
33
|
throw new Error(`File changed since AI setup scan: ${change.file}`);
|
|
40
34
|
}
|
|
41
|
-
|
|
42
|
-
fs_extra_1.default.ensureDirSync(path_1.default.dirname(backupPath));
|
|
43
|
-
fs_extra_1.default.copyFileSync(targetPath, backupPath);
|
|
35
|
+
(0, safe_file_transaction_1.writeBackupFile)(result.backupDir, change.file, target.content, target.mode);
|
|
44
36
|
result.changedFiles.push(change.file);
|
|
45
|
-
|
|
46
|
-
fs_extra_1.default.writeFileSync(temporaryPath, change.updated, 'utf8');
|
|
47
|
-
fs_extra_1.default.renameSync(temporaryPath, targetPath);
|
|
37
|
+
(0, safe_file_transaction_1.writeProjectFileAtomically)(params.projectRoot, change.file, change.updated, target.mode);
|
|
48
38
|
}
|
|
49
39
|
return result;
|
|
50
40
|
}
|
|
@@ -5,7 +5,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.requestAiSetupPlan = requestAiSetupPlan;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const credential_safety_1 = require("./credential-safety");
|
|
9
|
+
const terminal_safety_1 = require("./terminal-safety");
|
|
8
10
|
const DEFAULT_AI_INIT_TIMEOUT_MS = 180000;
|
|
11
|
+
const MAX_BACKEND_DIAGNOSTIC_LENGTH = 1000;
|
|
12
|
+
const safeBackendDiagnostic = (value) => {
|
|
13
|
+
if (typeof value !== 'string')
|
|
14
|
+
return null;
|
|
15
|
+
const diagnostic = value.trim();
|
|
16
|
+
if (!diagnostic ||
|
|
17
|
+
diagnostic.length > MAX_BACKEND_DIAGNOSTIC_LENGTH ||
|
|
18
|
+
(0, credential_safety_1.findKnownBundleDropCredential)(diagnostic)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return (0, terminal_safety_1.escapeTerminalControls)(diagnostic);
|
|
22
|
+
};
|
|
23
|
+
const safeBackendDetailReason = (details) => {
|
|
24
|
+
if (!details || typeof details !== 'object' || Array.isArray(details))
|
|
25
|
+
return null;
|
|
26
|
+
const descriptor = Object.getOwnPropertyDescriptor(details, 'reason');
|
|
27
|
+
if (!descriptor || !Object.prototype.hasOwnProperty.call(descriptor, 'value'))
|
|
28
|
+
return null;
|
|
29
|
+
return safeBackendDiagnostic(descriptor.value);
|
|
30
|
+
};
|
|
9
31
|
const resolveTimeoutMs = () => {
|
|
10
32
|
const value = Number(process.env.BUNDLE_DROP_AI_INIT_TIMEOUT_MS || '');
|
|
11
33
|
return Number.isFinite(value) && value > 0 ? value : DEFAULT_AI_INIT_TIMEOUT_MS;
|
|
@@ -26,9 +48,12 @@ async function requestAiSetupPlan(params) {
|
|
|
26
48
|
if (error?.code === 'ECONNABORTED' || /timeout/i.test(String(error?.message || ''))) {
|
|
27
49
|
throw new Error('AI setup planning timed out. Try again, or increase BUNDLE_DROP_AI_INIT_TIMEOUT_MS.');
|
|
28
50
|
}
|
|
29
|
-
const
|
|
30
|
-
? raw.
|
|
31
|
-
: raw
|
|
32
|
-
|
|
51
|
+
const diagnostic = raw && typeof raw === 'object'
|
|
52
|
+
? safeBackendDetailReason(raw.details) || safeBackendDiagnostic(raw.error)
|
|
53
|
+
: safeBackendDiagnostic(raw);
|
|
54
|
+
const fallback = diagnostic || safeBackendDiagnostic(error?.message);
|
|
55
|
+
throw new Error(fallback
|
|
56
|
+
? `AI setup planning failed: ${fallback}`
|
|
57
|
+
: 'AI setup planning failed');
|
|
33
58
|
}
|
|
34
59
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds CodePush ownership outside package files and provider-patched native entrypoints.
|
|
3
|
+
* Only relative paths are returned; file contents never leave this local validation boundary.
|
|
4
|
+
*/
|
|
5
|
+
export declare function findCodePushResiduePaths(projectRoot: string): string[];
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.findCodePushResiduePaths = findCodePushResiduePaths;
|
|
7
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const MAX_VISITED_ENTRIES = 20000;
|
|
10
|
+
const MAX_CANDIDATE_FILES = 500;
|
|
11
|
+
const MAX_FILE_BYTES = 1024 * 1024;
|
|
12
|
+
const MAX_TOTAL_BYTES = 5 * 1024 * 1024;
|
|
13
|
+
const SKIPPED_DIRECTORIES = new Set([
|
|
14
|
+
'.bundle-drop',
|
|
15
|
+
'.bundledrop-backup',
|
|
16
|
+
'.expo',
|
|
17
|
+
'.git',
|
|
18
|
+
'.gradle',
|
|
19
|
+
'build',
|
|
20
|
+
'coverage',
|
|
21
|
+
'deriveddata',
|
|
22
|
+
'dist',
|
|
23
|
+
'generated',
|
|
24
|
+
'lib',
|
|
25
|
+
'node_modules',
|
|
26
|
+
'pods',
|
|
27
|
+
'vendor',
|
|
28
|
+
]);
|
|
29
|
+
const JS_SOURCE_EXTENSION = /\.(?:cjs|cts|js|jsx|mjs|mts|ts|tsx)$/i;
|
|
30
|
+
const CODE_PUSH_REFERENCE = /\b(?:react-native-code-push|code[\s_.-]*push|com\.microsoft\.codepush\.react)/i;
|
|
31
|
+
const toPosix = (filePath) => filePath.split(path_1.default.sep).join('/');
|
|
32
|
+
const isCodePushResidueCandidate = (relativePath) => {
|
|
33
|
+
const parts = relativePath.split('/');
|
|
34
|
+
const basename = parts[parts.length - 1];
|
|
35
|
+
if (JS_SOURCE_EXTENSION.test(basename))
|
|
36
|
+
return true;
|
|
37
|
+
if (parts[0] === 'android') {
|
|
38
|
+
if (/^MainApplication\.(?:java|kt)$/i.test(basename))
|
|
39
|
+
return false;
|
|
40
|
+
return /\.(?:gradle|gradle\.kts|java|kt|properties|xml)$/i.test(basename);
|
|
41
|
+
}
|
|
42
|
+
if (parts[0] === 'ios') {
|
|
43
|
+
if (/^AppDelegate\.(?:m|mm|swift)$/i.test(basename))
|
|
44
|
+
return false;
|
|
45
|
+
return basename === 'Podfile' ||
|
|
46
|
+
/\.(?:h|m|mm|pbxproj|plist|podspec|swift|xcconfig)$/i.test(basename);
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
};
|
|
50
|
+
const scanLimitError = (detail) => new Error(`CodePush residue validation could not safely complete (${detail}). ` +
|
|
51
|
+
'Clean up CodePush manually or reduce the project scan surface, then retry. No files changed.');
|
|
52
|
+
/**
|
|
53
|
+
* Finds CodePush ownership outside package files and provider-patched native entrypoints.
|
|
54
|
+
* Only relative paths are returned; file contents never leave this local validation boundary.
|
|
55
|
+
*/
|
|
56
|
+
function findCodePushResiduePaths(projectRoot) {
|
|
57
|
+
const pendingDirectories = [''];
|
|
58
|
+
const residuePaths = [];
|
|
59
|
+
let visitedEntries = 0;
|
|
60
|
+
let candidateFiles = 0;
|
|
61
|
+
let totalBytes = 0;
|
|
62
|
+
while (pendingDirectories.length) {
|
|
63
|
+
const relativeDirectory = pendingDirectories.pop();
|
|
64
|
+
const absoluteDirectory = path_1.default.join(projectRoot, relativeDirectory);
|
|
65
|
+
let entries;
|
|
66
|
+
try {
|
|
67
|
+
entries = fs_extra_1.default.readdirSync(absoluteDirectory, { withFileTypes: true });
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
throw scanLimitError(`cannot inspect ${toPosix(relativeDirectory) || '.'}`);
|
|
71
|
+
}
|
|
72
|
+
entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
73
|
+
for (const entry of entries) {
|
|
74
|
+
visitedEntries += 1;
|
|
75
|
+
if (visitedEntries > MAX_VISITED_ENTRIES) {
|
|
76
|
+
throw scanLimitError(`more than ${MAX_VISITED_ENTRIES} filesystem entries`);
|
|
77
|
+
}
|
|
78
|
+
const relativePath = relativeDirectory
|
|
79
|
+
? path_1.default.join(relativeDirectory, entry.name)
|
|
80
|
+
: entry.name;
|
|
81
|
+
const absolutePath = path_1.default.join(projectRoot, relativePath);
|
|
82
|
+
let stat;
|
|
83
|
+
try {
|
|
84
|
+
stat = fs_extra_1.default.lstatSync(absolutePath);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
throw scanLimitError(`cannot inspect ${toPosix(relativePath)}`);
|
|
88
|
+
}
|
|
89
|
+
if (SKIPPED_DIRECTORIES.has(entry.name.toLowerCase()))
|
|
90
|
+
continue;
|
|
91
|
+
if (stat.isSymbolicLink()) {
|
|
92
|
+
throw scanLimitError(`relevant project path ${toPosix(relativePath)} is a symbolic link`);
|
|
93
|
+
}
|
|
94
|
+
if (stat.isDirectory()) {
|
|
95
|
+
pendingDirectories.push(relativePath);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (!stat.isFile())
|
|
99
|
+
continue;
|
|
100
|
+
const posixPath = toPosix(relativePath);
|
|
101
|
+
if (!isCodePushResidueCandidate(posixPath))
|
|
102
|
+
continue;
|
|
103
|
+
candidateFiles += 1;
|
|
104
|
+
if (candidateFiles > MAX_CANDIDATE_FILES) {
|
|
105
|
+
throw scanLimitError(`more than ${MAX_CANDIDATE_FILES} relevant files`);
|
|
106
|
+
}
|
|
107
|
+
if (stat.size > MAX_FILE_BYTES) {
|
|
108
|
+
throw scanLimitError(`${posixPath} exceeds the per-file limit`);
|
|
109
|
+
}
|
|
110
|
+
totalBytes += stat.size;
|
|
111
|
+
if (totalBytes > MAX_TOTAL_BYTES) {
|
|
112
|
+
throw scanLimitError(`relevant files exceed ${MAX_TOTAL_BYTES} bytes`);
|
|
113
|
+
}
|
|
114
|
+
let content;
|
|
115
|
+
try {
|
|
116
|
+
content = fs_extra_1.default.readFileSync(absolutePath, 'utf8');
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
throw scanLimitError(`cannot read ${posixPath}`);
|
|
120
|
+
}
|
|
121
|
+
if (CODE_PUSH_REFERENCE.test(content))
|
|
122
|
+
residuePaths.push(posixPath);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return residuePaths.sort();
|
|
126
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const findKnownBundleDropCredential: (value: string) => string | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findKnownBundleDropCredential = void 0;
|
|
4
|
+
const BUNDLE_DROP_PROJECT_KEY = /\bbdp_proj_[A-Za-z0-9_-]{32,}\b/;
|
|
5
|
+
const BUNDLE_DROP_PERSONAL_ACCESS_TOKEN = /\bbdp_pat_[A-Za-z0-9_-]{32,}\b/;
|
|
6
|
+
const findKnownBundleDropCredential = (value) => {
|
|
7
|
+
if (BUNDLE_DROP_PROJECT_KEY.test(value))
|
|
8
|
+
return 'Bundle Drop project key';
|
|
9
|
+
if (BUNDLE_DROP_PERSONAL_ACCESS_TOKEN.test(value)) {
|
|
10
|
+
return 'Bundle Drop personal access token';
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
};
|
|
14
|
+
exports.findKnownBundleDropCredential = findKnownBundleDropCredential;
|
|
@@ -7,16 +7,24 @@ exports.buildUnifiedDiff = buildUnifiedDiff;
|
|
|
7
7
|
exports.colorizeUnifiedDiff = colorizeUnifiedDiff;
|
|
8
8
|
const diff_1 = require("diff");
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const terminal_safety_1 = require("./terminal-safety");
|
|
11
|
+
const BUNDLE_DROP_CONFIG_PATH = /^bundle\.drop\.config\.(js|cjs)$/;
|
|
12
|
+
const API_KEY_LITERAL = /(\bapiKey\s*:\s*)(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)/g;
|
|
13
|
+
const redactPreviewSecrets = (file, content) => BUNDLE_DROP_CONFIG_PATH.test(file)
|
|
14
|
+
? content.replace(API_KEY_LITERAL, '$1"<redacted>"')
|
|
15
|
+
: content;
|
|
10
16
|
function buildUnifiedDiff(params) {
|
|
11
|
-
|
|
17
|
+
const diff = params.changes
|
|
12
18
|
.map(change => {
|
|
13
|
-
const original = params.originals.get(change.file) ?? '';
|
|
14
|
-
|
|
19
|
+
const original = redactPreviewSecrets(change.file, params.originals.get(change.file) ?? '');
|
|
20
|
+
const updated = redactPreviewSecrets(change.file, change.updated);
|
|
21
|
+
return (0, diff_1.createTwoFilesPatch)(`a/${change.file}`, `b/${change.file}`, original, updated, '', '', { context: 3 });
|
|
15
22
|
})
|
|
16
23
|
.join('\n');
|
|
24
|
+
return (0, terminal_safety_1.escapeTerminalControls)(diff);
|
|
17
25
|
}
|
|
18
26
|
function colorizeUnifiedDiff(diff) {
|
|
19
|
-
return diff
|
|
27
|
+
return (0, terminal_safety_1.escapeTerminalControls)(diff)
|
|
20
28
|
.split('\n')
|
|
21
29
|
.map(line => {
|
|
22
30
|
if (line.startsWith('+++') || line.startsWith('---'))
|
|
@@ -2,6 +2,7 @@ import type { ProjectType } from '../../../expo';
|
|
|
2
2
|
export type InitProjectOptions = {
|
|
3
3
|
projectType?: ProjectType;
|
|
4
4
|
dryRun?: boolean;
|
|
5
|
+
migrateCodePush?: boolean;
|
|
5
6
|
migrateExpoUpdates?: boolean;
|
|
6
7
|
prebuild?: boolean;
|
|
7
8
|
yes?: boolean;
|
|
@@ -12,6 +13,9 @@ export type InitProjectOptions = {
|
|
|
12
13
|
projectSlug: string;
|
|
13
14
|
authToken: string;
|
|
14
15
|
};
|
|
16
|
+
runtimeDeliveryBootstrap?: {
|
|
17
|
+
content: string;
|
|
18
|
+
};
|
|
15
19
|
};
|
|
16
20
|
export declare function initProjectConfigAi(options?: InitProjectOptions): Promise<void>;
|
|
17
21
|
export default initProjectConfigAi;
|