native-update-capacitor 0.0.0-stage → 4.3.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 (139) hide show
  1. package/AI-INTEGRATION-GUIDE.md +578 -0
  2. package/LICENSE +25 -0
  3. package/NativeUpdate.podspec +19 -0
  4. package/README.md +574 -2
  5. package/android/build.gradle +125 -0
  6. package/android/consumer-rules.pro +9 -0
  7. package/android/gradle/wrapper/gradle-wrapper.properties +8 -0
  8. package/android/gradle.properties +17 -0
  9. package/android/manifest-additions.xml +28 -0
  10. package/android/proguard-rules.pro +26 -0
  11. package/android/settings.gradle +2 -0
  12. package/android/src/main/AndroidManifest.xml +13 -0
  13. package/android/src/main/java/com/aoneahsan/nativeupdate/AppReviewPlugin.kt +159 -0
  14. package/android/src/main/java/com/aoneahsan/nativeupdate/AppUpdatePlugin.kt +314 -0
  15. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundNotificationManager.kt +406 -0
  16. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateManager.kt +48 -0
  17. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdatePlugin.kt +343 -0
  18. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateWorker.kt +236 -0
  19. package/android/src/main/java/com/aoneahsan/nativeupdate/JsonOptional.kt +26 -0
  20. package/android/src/main/java/com/aoneahsan/nativeupdate/LiveUpdatePlugin.kt +1249 -0
  21. package/android/src/main/java/com/aoneahsan/nativeupdate/NativeUpdatePlugin.kt +404 -0
  22. package/android/src/main/java/com/aoneahsan/nativeupdate/NotificationActionReceiver.kt +107 -0
  23. package/android/src/main/java/com/aoneahsan/nativeupdate/SecurityManager.kt +240 -0
  24. package/android/variables.gradle +5 -0
  25. package/cli/commands/backend-create.js +623 -0
  26. package/cli/commands/bundle-create.js +145 -0
  27. package/cli/commands/bundle-sign.js +64 -0
  28. package/cli/commands/bundle-verify.js +58 -0
  29. package/cli/commands/init.js +146 -0
  30. package/cli/commands/keys-generate.js +58 -0
  31. package/cli/commands/monitor.js +89 -0
  32. package/cli/commands/remote-shared.js +262 -0
  33. package/cli/commands/remote.js +622 -0
  34. package/cli/commands/server-start.js +96 -0
  35. package/cli/index.js +605 -0
  36. package/cli/package.json +21 -0
  37. package/dist/esm/app-review/app-review-manager.d.ts +24 -0
  38. package/dist/esm/app-review/app-review-manager.js +194 -0
  39. package/dist/esm/app-review/index.d.ts +5 -0
  40. package/dist/esm/app-review/index.js +5 -0
  41. package/dist/esm/app-review/platform-review-handler.d.ts +20 -0
  42. package/dist/esm/app-review/platform-review-handler.js +137 -0
  43. package/dist/esm/app-review/review-conditions-checker.d.ts +22 -0
  44. package/dist/esm/app-review/review-conditions-checker.js +154 -0
  45. package/dist/esm/app-review/review-rate-limiter.d.ts +23 -0
  46. package/dist/esm/app-review/review-rate-limiter.js +163 -0
  47. package/dist/esm/app-review/types.d.ts +41 -0
  48. package/dist/esm/app-review/types.js +1 -0
  49. package/dist/esm/app-update/app-update-checker.d.ts +58 -0
  50. package/dist/esm/app-update/app-update-checker.js +227 -0
  51. package/dist/esm/app-update/app-update-installer.d.ts +20 -0
  52. package/dist/esm/app-update/app-update-installer.js +134 -0
  53. package/dist/esm/app-update/app-update-manager.d.ts +28 -0
  54. package/dist/esm/app-update/app-update-manager.js +198 -0
  55. package/dist/esm/app-update/app-update-notifier.d.ts +14 -0
  56. package/dist/esm/app-update/app-update-notifier.js +99 -0
  57. package/dist/esm/app-update/index.d.ts +6 -0
  58. package/dist/esm/app-update/index.js +6 -0
  59. package/dist/esm/app-update/platform-app-update.d.ts +19 -0
  60. package/dist/esm/app-update/platform-app-update.js +138 -0
  61. package/dist/esm/app-update/types.d.ts +58 -0
  62. package/dist/esm/app-update/types.js +11 -0
  63. package/dist/esm/background-update/background-scheduler.d.ts +63 -0
  64. package/dist/esm/background-update/background-scheduler.js +332 -0
  65. package/dist/esm/background-update/index.d.ts +3 -0
  66. package/dist/esm/background-update/index.js +2 -0
  67. package/dist/esm/background-update/notification-manager.d.ts +29 -0
  68. package/dist/esm/background-update/notification-manager.js +88 -0
  69. package/dist/esm/config/support.d.ts +9 -0
  70. package/dist/esm/config/support.js +9 -0
  71. package/dist/esm/core/analytics.d.ts +83 -0
  72. package/dist/esm/core/analytics.js +151 -0
  73. package/dist/esm/core/cache-manager.d.ts +72 -0
  74. package/dist/esm/core/cache-manager.js +274 -0
  75. package/dist/esm/core/config.d.ts +69 -0
  76. package/dist/esm/core/config.js +107 -0
  77. package/dist/esm/core/errors.d.ts +56 -0
  78. package/dist/esm/core/errors.js +85 -0
  79. package/dist/esm/core/event-emitter.d.ts +30 -0
  80. package/dist/esm/core/event-emitter.js +80 -0
  81. package/dist/esm/core/logger.d.ts +21 -0
  82. package/dist/esm/core/logger.js +108 -0
  83. package/dist/esm/core/performance.d.ts +53 -0
  84. package/dist/esm/core/performance.js +153 -0
  85. package/dist/esm/core/plugin-manager.d.ts +88 -0
  86. package/dist/esm/core/plugin-manager.js +224 -0
  87. package/dist/esm/core/security.d.ts +123 -0
  88. package/dist/esm/core/security.js +361 -0
  89. package/dist/esm/core/update-check.d.ts +121 -0
  90. package/dist/esm/core/update-check.js +127 -0
  91. package/dist/esm/definitions.d.ts +872 -0
  92. package/dist/esm/definitions.js +104 -0
  93. package/dist/esm/index.d.ts +14 -0
  94. package/dist/esm/index.js +18 -0
  95. package/dist/esm/live-update/bundle-manager.d.ts +102 -0
  96. package/dist/esm/live-update/bundle-manager.js +344 -0
  97. package/dist/esm/live-update/certificate-pinning.d.ts +38 -0
  98. package/dist/esm/live-update/certificate-pinning.js +77 -0
  99. package/dist/esm/live-update/delta-processor.d.ts +84 -0
  100. package/dist/esm/live-update/delta-processor.js +257 -0
  101. package/dist/esm/live-update/download-manager.d.ts +106 -0
  102. package/dist/esm/live-update/download-manager.js +412 -0
  103. package/dist/esm/live-update/rollout-checker.d.ts +86 -0
  104. package/dist/esm/live-update/rollout-checker.js +304 -0
  105. package/dist/esm/live-update/update-manager.d.ts +63 -0
  106. package/dist/esm/live-update/update-manager.js +321 -0
  107. package/dist/esm/live-update/version-manager.d.ts +93 -0
  108. package/dist/esm/live-update/version-manager.js +390 -0
  109. package/dist/esm/plugin.d.ts +3 -0
  110. package/dist/esm/plugin.js +848 -0
  111. package/dist/esm/security/crypto.d.ts +88 -0
  112. package/dist/esm/security/crypto.js +228 -0
  113. package/dist/esm/security/validator.d.ts +60 -0
  114. package/dist/esm/security/validator.js +142 -0
  115. package/dist/esm/types/app-identity.d.ts +36 -0
  116. package/dist/esm/types/app-identity.js +1 -0
  117. package/dist/esm/types/rollout.d.ts +91 -0
  118. package/dist/esm/types/rollout.js +25 -0
  119. package/dist/esm/web.d.ts +130 -0
  120. package/dist/esm/web.js +981 -0
  121. package/dist/plugin.cjs +1 -0
  122. package/dist/plugin.esm.js +1 -0
  123. package/dist/plugin.js +2 -0
  124. package/docs/CHANGELOG.md +993 -0
  125. package/docs/KNOWN_LIMITATIONS.md +235 -0
  126. package/docs/MIGRATION.md +391 -0
  127. package/docs/protocol/CLIENT-PROTOCOL.md +178 -0
  128. package/docs/server-requirements.md +211 -0
  129. package/ios/Plugin/AppReview/AppReviewPlugin.swift +158 -0
  130. package/ios/Plugin/AppUpdate/AppUpdatePlugin.swift +249 -0
  131. package/ios/Plugin/BackgroundUpdate/BackgroundNotificationManager.swift +333 -0
  132. package/ios/Plugin/BackgroundUpdate/BackgroundUpdatePlugin.swift +464 -0
  133. package/ios/Plugin/Info.plist +43 -0
  134. package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +1286 -0
  135. package/ios/Plugin/LiveUpdate/WebViewConfiguration.swift +45 -0
  136. package/ios/Plugin/NativeUpdatePlugin.m +53 -0
  137. package/ios/Plugin/NativeUpdatePlugin.swift +315 -0
  138. package/ios/Plugin/Security/SecurityManager.swift +289 -0
  139. package/package.json +135 -4
package/cli/index.js ADDED
@@ -0,0 +1,605 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Native Update CLI
5
+ *
6
+ * Provides command-line tools for managing Capacitor Native Update plugin
7
+ * Can be used with npx, global install, or local install
8
+ */
9
+
10
+ import { Command } from 'commander';
11
+ import chalk from 'chalk';
12
+ import { fileURLToPath } from 'url';
13
+ import { dirname, join } from 'path';
14
+ import fs from 'fs/promises';
15
+
16
+ const __filename = fileURLToPath(import.meta.url);
17
+ const __dirname = dirname(__filename);
18
+ const packagePath = join(__dirname, '..', 'package.json');
19
+ const packageJson = JSON.parse(await fs.readFile(packagePath, 'utf-8'));
20
+
21
+ const program = new Command();
22
+
23
+ program
24
+ .name('native-update')
25
+ // Positional options: program-level flags (e.g. the root `-V, --version`)
26
+ // must come BEFORE a subcommand. Anything after `bundle create …` belongs
27
+ // to the leaf command — so `bundle create ./www --version 1.2.0` reaches the
28
+ // leaf's own `--version <version>` option instead of triggering the root
29
+ // version display. Every parent command below enables this too so the flag
30
+ // is passed all the way down the program → bundle → create chain.
31
+ .enablePositionalOptions()
32
+ .description(`CLI tools for Capacitor Native Update plugin
33
+
34
+ ${chalk.bold('Quick Start:')}
35
+ ${chalk.gray('npx native-update init --example')} # Initialize with examples
36
+ ${chalk.gray('npx native-update backend create express')} # Create backend server
37
+ ${chalk.gray('npx native-update bundle create ./www')} # Create update bundle
38
+
39
+ ${chalk.bold('Documentation:')}
40
+ ${chalk.blue('https://nativeupdate.aoneahsan.com/docs')}`)
41
+ .version(packageJson.version)
42
+ .configureHelp({
43
+ sortSubcommands: true,
44
+ subcommandTerm: (cmd) => cmd.name() + ' ' + cmd.aliases().join(', ')
45
+ });
46
+
47
+ // Bundle Management Commands
48
+ const bundleCmd = program
49
+ .command('bundle')
50
+ .enablePositionalOptions()
51
+ .description('Bundle management commands');
52
+
53
+ bundleCmd
54
+ .command('create <webDir>')
55
+ .alias('create-bundle')
56
+ .description(`Create an update bundle from your web directory
57
+
58
+ ${chalk.bold('Examples:')}
59
+ ${chalk.gray('# Create bundle from default build directory')}
60
+ ${chalk.green('npx native-update bundle create ./www')}
61
+
62
+ ${chalk.gray('# Create with specific version and channel')}
63
+ ${chalk.green('npx native-update bundle create ./dist --version 1.2.0 --channel staging')}
64
+
65
+ ${chalk.gray('# Add metadata like release notes')}
66
+ ${chalk.green(`npx native-update bundle create ./www --metadata '{"releaseNotes":"Bug fixes"}'`)}`)
67
+ .option('-o, --output <path>', 'Output directory for the bundle', './update-bundles')
68
+ .option('-v, --version <version>', 'Bundle version (defaults to package.json version)')
69
+ .option('-c, --channel <channel>', 'Release channel', 'production')
70
+ .option('-m, --metadata <json>', 'Additional metadata as JSON string')
71
+ .action(async (webDir, options) => {
72
+ const { createBundle } = await import('./commands/bundle-create.js');
73
+ await createBundle(webDir, options);
74
+ });
75
+
76
+ bundleCmd
77
+ .command('sign <bundlePath>')
78
+ .alias('sign-bundle')
79
+ .description(`Sign an update bundle with your private key
80
+
81
+ ${chalk.bold('Examples:')}
82
+ ${chalk.gray('# Sign a bundle with your private key')}
83
+ ${chalk.green('npx native-update bundle sign ./bundle.zip --key ./keys/private.pem')}
84
+
85
+ ${chalk.gray('# Specify output path for signed bundle')}
86
+ ${chalk.green('npx native-update bundle sign ./bundle.zip --key private.pem --output ./signed-bundle.zip')}`)
87
+ .requiredOption('-k, --key <path>', 'Path to private key file')
88
+ .option('-o, --output <path>', 'Output path for signed bundle')
89
+ .action(async (bundlePath, options) => {
90
+ const { signBundle } = await import('./commands/bundle-sign.js');
91
+ await signBundle(bundlePath, options);
92
+ });
93
+
94
+ bundleCmd
95
+ .command('verify <bundlePath>')
96
+ .alias('verify-bundle')
97
+ .description(`Verify a signed bundle with public key
98
+
99
+ ${chalk.bold('Example:')}
100
+ ${chalk.green('npx native-update bundle verify ./signed-bundle.zip --key ./keys/public.pem')}`)
101
+ .requiredOption('-k, --key <path>', 'Path to public key file')
102
+ .action(async (bundlePath, options) => {
103
+ const { verifyBundle } = await import('./commands/bundle-verify.js');
104
+ await verifyBundle(bundlePath, options);
105
+ });
106
+
107
+ // Key Management Commands
108
+ const keysCmd = program
109
+ .command('keys')
110
+ .enablePositionalOptions()
111
+ .description('Key management commands');
112
+
113
+ keysCmd
114
+ .command('generate')
115
+ .alias('generate-keys')
116
+ .description(`Generate a new key pair for bundle signing
117
+
118
+ ${chalk.bold('Examples:')}
119
+ ${chalk.gray('# Generate default RSA 2048-bit keys')}
120
+ ${chalk.green('npx native-update keys generate')}
121
+
122
+ ${chalk.gray('# Generate strong RSA 4096-bit keys for production')}
123
+ ${chalk.green('npx native-update keys generate --type rsa --size 4096 --output ./my-keys')}`)
124
+ .option('-o, --output <dir>', 'Output directory for keys', './keys')
125
+ .option('-t, --type <type>', 'Key type (rsa)', 'rsa')
126
+ .option('-s, --size <size>', 'RSA key size (2048 or 4096)', '2048')
127
+ .action(async (options) => {
128
+ const { generateKeys } = await import('./commands/keys-generate.js');
129
+ await generateKeys(options);
130
+ });
131
+
132
+ // Server Commands
133
+ const serverCmd = program
134
+ .command('server')
135
+ .enablePositionalOptions()
136
+ .description('Development server commands');
137
+
138
+ serverCmd
139
+ .command('start')
140
+ .alias('start-server')
141
+ .description('Start a local update server for testing')
142
+ .option('-p, --port <port>', 'Server port', '3000')
143
+ .option('-d, --dir <dir>', 'Directory containing update bundles', './update-bundles')
144
+ .option('--cors', 'Enable CORS for testing', true)
145
+ .action(async (options) => {
146
+ const { startServer } = await import('./commands/server-start.js');
147
+ await startServer(options);
148
+ });
149
+
150
+ // Init Commands
151
+ program
152
+ .command('init')
153
+ .description(`Initialize native-update in your project
154
+
155
+ ${chalk.bold('Examples:')}
156
+ ${chalk.gray('# Basic initialization')}
157
+ ${chalk.green('npx native-update init')}
158
+
159
+ ${chalk.gray('# Initialize with example code and configuration')}
160
+ ${chalk.green('npx native-update init --example')}
161
+
162
+ ${chalk.gray('# Initialize for Firebase backend')}
163
+ ${chalk.green('npx native-update init --backend firebase --example')}`)
164
+ .option('--example', 'Include example configuration')
165
+ .option('--backend <type>', 'Backend type (firebase, express, custom)', 'custom')
166
+ .action(async (options) => {
167
+ const { init } = await import('./commands/init.js');
168
+ await init(options);
169
+ });
170
+
171
+ // Backend Commands
172
+ const backendCmd = program
173
+ .command('backend')
174
+ .enablePositionalOptions()
175
+ .description('Backend template commands');
176
+
177
+ backendCmd
178
+ .command('create <type>')
179
+ .alias('create-backend')
180
+ .description(`Create a backend template (express, firebase, vercel)
181
+
182
+ ${chalk.bold('Examples:')}
183
+ ${chalk.gray('# Create Express.js backend with admin dashboard')}
184
+ ${chalk.green('npx native-update backend create express --with-admin')}
185
+
186
+ ${chalk.gray('# Create Firebase Functions backend with monitoring')}
187
+ ${chalk.green('npx native-update backend create firebase --with-monitoring')}
188
+
189
+ ${chalk.gray('# Create Vercel serverless backend')}
190
+ ${chalk.green('npx native-update backend create vercel --output my-backend')}`)
191
+ .option('-o, --output <dir>', 'Output directory', './native-update-backend')
192
+ .option('--with-monitoring', 'Include monitoring setup', false)
193
+ .option('--with-admin', 'Include admin dashboard', false)
194
+ .action(async (type, options) => {
195
+ const { createBackend } = await import('./commands/backend-create.js');
196
+ await createBackend(type, options);
197
+ });
198
+
199
+ // ---------------------------------------------------------------------------
200
+ // Public Management API commands (access token → nativeupdatebe.aoneahsan.com)
201
+ //
202
+ // Auth for all of these: NATIVE_UPDATE_TOKEN (preferred — a --token flag lands
203
+ // in shell history and `ps` output) or --token. Server: NATIVE_UPDATE_SERVER or
204
+ // --server, defaulting to the hosted backend.
205
+ //
206
+ // Every parent below calls .enablePositionalOptions() for the same reason
207
+ // `bundle` does: without it the root's `-V, --version` swallows a leaf's own
208
+ // `--version <v>` flag and prints the CLI version instead of deploying.
209
+ // ---------------------------------------------------------------------------
210
+
211
+ const remoteAuthOptions = (cmd) =>
212
+ cmd
213
+ .option('-t, --token <token>', 'Access token (or set NATIVE_UPDATE_TOKEN)')
214
+ .option('-s, --server <url>', 'Backend base URL (or set NATIVE_UPDATE_SERVER)');
215
+
216
+ // deploy — upload a bundle and publish it
217
+ remoteAuthOptions(
218
+ program
219
+ .command('deploy <webDirOrZip>')
220
+ .description(`Upload a bundle to your app and publish it
221
+
222
+ ${chalk.bold('Examples:')}
223
+ ${chalk.gray('# Deploy a built web directory (zipped for you)')}
224
+ ${chalk.green('npx native-update deploy ./dist --app com.example.app --version 1.2.0')}
225
+
226
+ ${chalk.gray('# Block until the release is actually live (recommended in CI)')}
227
+ ${chalk.green('npx native-update deploy ./dist --app com.example.app --wait')}
228
+
229
+ ${chalk.gray('# Staged rollout with release notes')}
230
+ ${chalk.green('npx native-update deploy ./bundle.zip --app 12 --version 1.2.0 --rollout 10 --notes "Bug fixes"')}`)
231
+ .requiredOption('-a, --app <appIdOrNumericId>', 'App to deploy to (app_id like com.example.app, or numeric id)')
232
+ .option('-v, --version <version>', 'Bundle version (defaults to ./package.json version)')
233
+ .option('-c, --channel <channel>', 'Release channel', 'production')
234
+ .option('-n, --notes <text>', 'Release notes')
235
+ .option('-r, --rollout <percent>', 'Initial rollout percentage (1-100)')
236
+ .option('--min-native <version>', 'Minimum native app version required')
237
+ .option(
238
+ '--payload-type <type>',
239
+ 'web_bundle (Capacitor / React Native code) or assets (files a native Android or Flutter app reads)',
240
+ 'web_bundle'
241
+ )
242
+ .option('--signature <file>', 'Detached signature from `bundle sign` (auto-detects a sibling .sig)')
243
+ .option('-w, --wait', 'Wait for processing to finish (exit non-zero if it fails)', false)
244
+ ).action(async (target, options) => {
245
+ const { deploy } = await import('./commands/remote.js');
246
+ await deploy(target, options);
247
+ });
248
+
249
+ // apps
250
+ const appsCmd = program
251
+ .command('apps')
252
+ .enablePositionalOptions()
253
+ .description('Manage the apps your access token can reach');
254
+
255
+ remoteAuthOptions(appsCmd.command('list').description('List apps this token can manage')).action(
256
+ async (options) => {
257
+ const { appsList } = await import('./commands/remote.js');
258
+ await appsList(options);
259
+ }
260
+ );
261
+
262
+ remoteAuthOptions(
263
+ appsCmd
264
+ .command('create')
265
+ .description('Create a new app (an explicitly-scoped token gains it automatically)')
266
+ .requiredOption('--name <name>', 'App display name')
267
+ .option('--bundle-id <id>', 'Reverse-DNS package id (e.g. com.example.app)')
268
+ .option('--platform <platform>', 'ios | android | both', 'both')
269
+ .option('--description <text>', 'Optional description')
270
+ ).action(async (options) => {
271
+ const { appsCreate } = await import('./commands/remote.js');
272
+ await appsCreate(options);
273
+ });
274
+
275
+ remoteAuthOptions(appsCmd.command('show <app>').description('Show one app')).action(
276
+ async (app, options) => {
277
+ const { appsShow } = await import('./commands/remote.js');
278
+ await appsShow(app, options);
279
+ }
280
+ );
281
+
282
+ remoteAuthOptions(
283
+ appsCmd
284
+ .command('update <app>')
285
+ .description('Edit an app (name / platform / description; bundle_id is immutable)')
286
+ .option('--name <name>', 'New display name')
287
+ .option('--platform <platform>', 'ios | android | both')
288
+ .option('--description <text>', 'New description')
289
+ ).action(async (app, options) => {
290
+ const { appsUpdate } = await import('./commands/remote.js');
291
+ await appsUpdate(app, options);
292
+ });
293
+
294
+ remoteAuthOptions(
295
+ appsCmd
296
+ .command('delete <app>')
297
+ .description('Delete an app + its builds/keys (needs the apps.delete token permission)')
298
+ .option('-y, --yes', 'Confirm the deletion', false)
299
+ ).action(async (app, options) => {
300
+ const { appsDelete } = await import('./commands/remote.js');
301
+ await appsDelete(app, options);
302
+ });
303
+
304
+ // apps keys — per-app DEVICE API keys (nu_app_…). Nested under `apps` so it
305
+ // never collides with the top-level local signing `keys` command above.
306
+ const appsKeysCmd = appsCmd
307
+ .command('keys')
308
+ .enablePositionalOptions()
309
+ .description("Manage an app's device API keys (nu_app_…)");
310
+
311
+ remoteAuthOptions(appsKeysCmd.command('list <app>').description("List an app's API keys")).action(
312
+ async (app, options) => {
313
+ const { keysList } = await import('./commands/remote.js');
314
+ await keysList(app, options);
315
+ }
316
+ );
317
+
318
+ remoteAuthOptions(
319
+ appsKeysCmd.command('create <app>').description('Create an API key').option('--name <name>', 'Key name')
320
+ ).action(async (app, options) => {
321
+ const { keysCreate } = await import('./commands/remote.js');
322
+ await keysCreate(app, options);
323
+ });
324
+
325
+ remoteAuthOptions(appsKeysCmd.command('show <app> <key>').description('Show one API key')).action(
326
+ async (app, key, options) => {
327
+ const { keysShow } = await import('./commands/remote.js');
328
+ await keysShow(app, key, options);
329
+ }
330
+ );
331
+
332
+ remoteAuthOptions(
333
+ appsKeysCmd.command('rotate <app> <key>').description('Rotate a key (old one stops working)')
334
+ ).action(async (app, key, options) => {
335
+ const { keysRotate } = await import('./commands/remote.js');
336
+ await keysRotate(app, key, options);
337
+ });
338
+
339
+ remoteAuthOptions(
340
+ appsKeysCmd.command('reveal <app> <key>').description('Re-print a recoverable key')
341
+ ).action(async (app, key, options) => {
342
+ const { keysReveal } = await import('./commands/remote.js');
343
+ await keysReveal(app, key, options);
344
+ });
345
+
346
+ remoteAuthOptions(appsKeysCmd.command('revoke <app> <key>').description('Revoke a key')).action(
347
+ async (app, key, options) => {
348
+ const { keysRevoke } = await import('./commands/remote.js');
349
+ await keysRevoke(app, key, options);
350
+ }
351
+ );
352
+
353
+ remoteAuthOptions(
354
+ appsKeysCmd.command('deprecate <app> <key>').description('Deprecate a key (still works, usage logged)')
355
+ ).action(async (app, key, options) => {
356
+ const { keysDeprecate } = await import('./commands/remote.js');
357
+ await keysDeprecate(app, key, options);
358
+ });
359
+
360
+ remoteAuthOptions(
361
+ appsKeysCmd
362
+ .command('restrict <app> <key>')
363
+ .description('Set client restrictions from a JSON payload ({} clears them)')
364
+ .requiredOption('--json <json>', 'Restrictions JSON (origins/android/ios)')
365
+ ).action(async (app, key, options) => {
366
+ const { keysRestrict } = await import('./commands/remote.js');
367
+ await keysRestrict(app, key, options);
368
+ });
369
+
370
+ remoteAuthOptions(
371
+ appsKeysCmd
372
+ .command('delete <app> <key>')
373
+ .description('Permanently delete a key (needs the keys.delete permission)')
374
+ .option('-y, --yes', 'Confirm the deletion', false)
375
+ ).action(async (app, key, options) => {
376
+ const { keysDelete } = await import('./commands/remote.js');
377
+ await keysDelete(app, key, options);
378
+ });
379
+
380
+ // apps signing — bundle signing keys (public key + fingerprint only)
381
+ const appsSigningCmd = appsCmd
382
+ .command('signing')
383
+ .enablePositionalOptions()
384
+ .description('Manage an app\'s bundle signing key');
385
+
386
+ remoteAuthOptions(appsSigningCmd.command('show <app>').description('Show the active signing key')).action(
387
+ async (app, options) => {
388
+ const { signingShow } = await import('./commands/remote.js');
389
+ await signingShow(app, options);
390
+ }
391
+ );
392
+
393
+ remoteAuthOptions(
394
+ appsSigningCmd.command('create <app>').description('Create the signing key').option('--name <name>', 'Key name')
395
+ ).action(async (app, options) => {
396
+ const { signingCreate } = await import('./commands/remote.js');
397
+ await signingCreate(app, options);
398
+ });
399
+
400
+ remoteAuthOptions(
401
+ appsSigningCmd.command('rotate <app>').description('Rotate the signing key').option('--name <name>', 'Key name')
402
+ ).action(async (app, options) => {
403
+ const { signingRotate } = await import('./commands/remote.js');
404
+ await signingRotate(app, options);
405
+ });
406
+
407
+ // apps keystore — a private .zip backup of your app-signing keystore
408
+ const appsKeystoreCmd = appsCmd
409
+ .command('keystore')
410
+ .enablePositionalOptions()
411
+ .description('Private .zip backup of your app-signing keystore');
412
+
413
+ remoteAuthOptions(
414
+ appsKeystoreCmd.command('upload <app> <zipPath>').description('Upload/replace the keystore backup (.zip)')
415
+ ).action(async (app, zipPath, options) => {
416
+ const { keystoreUpload } = await import('./commands/remote.js');
417
+ await keystoreUpload(app, zipPath, options);
418
+ });
419
+
420
+ remoteAuthOptions(appsKeystoreCmd.command('info <app>').description('Show backup metadata')).action(
421
+ async (app, options) => {
422
+ const { keystoreInfo } = await import('./commands/remote.js');
423
+ await keystoreInfo(app, options);
424
+ }
425
+ );
426
+
427
+ remoteAuthOptions(
428
+ appsKeystoreCmd
429
+ .command('download <app>')
430
+ .description('Download the keystore backup')
431
+ .option('-o, --output <file>', 'Output file (default: keystore-<app>.zip)')
432
+ ).action(async (app, options) => {
433
+ const { keystoreDownload } = await import('./commands/remote.js');
434
+ await keystoreDownload(app, options);
435
+ });
436
+
437
+ remoteAuthOptions(
438
+ appsKeystoreCmd
439
+ .command('delete <app>')
440
+ .description('Delete the keystore backup')
441
+ .option('-y, --yes', 'Confirm the deletion', false)
442
+ ).action(async (app, options) => {
443
+ const { keystoreDelete } = await import('./commands/remote.js');
444
+ await keystoreDelete(app, options);
445
+ });
446
+
447
+ // builds
448
+ const buildsCmd = program
449
+ .command('builds')
450
+ .enablePositionalOptions()
451
+ .description('Manage builds over the public API');
452
+
453
+ remoteAuthOptions(
454
+ buildsCmd
455
+ .command('list <app>')
456
+ .description('List builds for an app')
457
+ .option('-c, --channel <channel>', 'Filter by channel (production|staging|development)')
458
+ .option('--status <status>', 'Filter by status (active|processing|paused|archived|failed)')
459
+ .option('-p, --page <page>', 'Page number')
460
+ ).action(async (app, options) => {
461
+ const { buildsList } = await import('./commands/remote.js');
462
+ await buildsList(app, options);
463
+ });
464
+
465
+ remoteAuthOptions(
466
+ buildsCmd
467
+ .command('promote <app> <build>')
468
+ .description('Promote a build into another channel (zero-copy)')
469
+ .requiredOption('--to <channel>', 'Target channel (production|staging|development)')
470
+ ).action(async (app, build, options) => {
471
+ const { buildsPromote } = await import('./commands/remote.js');
472
+ await buildsPromote(app, build, options);
473
+ });
474
+
475
+ remoteAuthOptions(
476
+ buildsCmd
477
+ .command('rollout <app> <build>')
478
+ .description('Set a build\'s rollout percentage')
479
+ .requiredOption('--percent <n>', 'Rollout percentage (0-100)')
480
+ ).action(async (app, build, options) => {
481
+ const { buildsRollout } = await import('./commands/remote.js');
482
+ await buildsRollout(app, build, options);
483
+ });
484
+
485
+ remoteAuthOptions(
486
+ buildsCmd
487
+ .command('status <app> <build>')
488
+ .description('Pause, resume, or archive a build')
489
+ .requiredOption('--set <status>', 'New status (active|paused|archived)')
490
+ ).action(async (app, build, options) => {
491
+ const { buildsStatus } = await import('./commands/remote.js');
492
+ await buildsStatus(app, build, options);
493
+ });
494
+
495
+ remoteAuthOptions(
496
+ buildsCmd
497
+ .command('delete <app> <build>')
498
+ .description('Delete a build (needs a token with the builds.delete permission)')
499
+ .option('-y, --yes', 'Confirm the deletion', false)
500
+ ).action(async (app, build, options) => {
501
+ const { buildsDelete } = await import('./commands/remote.js');
502
+ await buildsDelete(app, build, options);
503
+ });
504
+
505
+ // jobs
506
+ const jobsCmd = program
507
+ .command('jobs')
508
+ .enablePositionalOptions()
509
+ .description('Inspect queued work (bundle processing)');
510
+
511
+ remoteAuthOptions(
512
+ jobsCmd
513
+ .command('status <jobId>')
514
+ .description('Show a job\'s status')
515
+ .option('-w, --wait', 'Poll until the job finishes', false)
516
+ ).action(async (jobId, options) => {
517
+ const { jobsStatus } = await import('./commands/remote.js');
518
+ await jobsStatus(jobId, options);
519
+ });
520
+
521
+ // token
522
+ const tokenCmd = program
523
+ .command('token')
524
+ .enablePositionalOptions()
525
+ .description('Inspect your access token');
526
+
527
+ remoteAuthOptions(
528
+ tokenCmd.command('info').description('Show what this token is and which apps it can manage')
529
+ ).action(async (options) => {
530
+ const { tokenInfo } = await import('./commands/remote.js');
531
+ await tokenInfo(options);
532
+ });
533
+
534
+ // Monitoring Commands
535
+ program
536
+ .command('monitor')
537
+ .description('Monitor update deployments')
538
+ .option('-s, --server <url>', 'Backend server URL')
539
+ .option('-k, --key <key>', 'API key for authentication')
540
+ .action(async (options) => {
541
+ const { monitor } = await import('./commands/monitor.js');
542
+ await monitor(options);
543
+ });
544
+
545
+ // Add helpful examples
546
+ program.on('--help', () => {
547
+ console.log('');
548
+ console.log('Examples:');
549
+ console.log('');
550
+ console.log(' Quick Start:');
551
+ console.log(' $ npx native-update init --example');
552
+ console.log(' $ npx native-update backend create express --with-admin');
553
+ console.log('');
554
+ console.log(' Bundle Management:');
555
+ console.log(' $ npx native-update bundle create ./www');
556
+ console.log(' $ npx native-update bundle sign ./bundle.zip --key ./keys/private.pem');
557
+ console.log(' $ npx native-update bundle verify ./bundle.zip --key ./keys/public.pem');
558
+ console.log('');
559
+ console.log(' Key Management:');
560
+ console.log(' $ npx native-update keys generate --type rsa --size 4096');
561
+ console.log('');
562
+ console.log(' Development:');
563
+ console.log(' $ npx native-update server start --port 3000');
564
+ console.log(' $ npx native-update monitor --server http://localhost:3000');
565
+ console.log('');
566
+ console.log(' Backend Templates:');
567
+ console.log(' $ npx native-update backend create express');
568
+ console.log(' $ npx native-update backend create firebase --with-monitoring');
569
+ console.log(' $ npx native-update backend create vercel --with-admin');
570
+ console.log('');
571
+ console.log(chalk.bold('Resources:'));
572
+ console.log(' Website: ' + chalk.blue('https://nativeupdate.aoneahsan.com'));
573
+ console.log(' Documentation: ' + chalk.blue('https://nativeupdate.aoneahsan.com/docs'));
574
+ console.log(' NPM Package: ' + chalk.blue('https://www.npmjs.com/package/native-update'));
575
+ console.log('');
576
+ console.log(chalk.bold('Support:'));
577
+ console.log(' Email: ' + chalk.blue('aoneahsan@gmail.com'));
578
+ console.log(' Author: Ahsan Mahmood (' + chalk.blue('https://aoneahsan.com') + ')');
579
+ });
580
+
581
+ // Error handling
582
+ program.exitOverride();
583
+
584
+ try {
585
+ await program.parseAsync(process.argv);
586
+ } catch (error) {
587
+ // With exitOverride(), Commander throws for normal help/version output too
588
+ // (exitCode 0). Those are successful displays, not errors — exit quietly.
589
+ if (
590
+ error.code === 'commander.helpDisplayed' ||
591
+ error.code === 'commander.help' ||
592
+ error.code === 'commander.version'
593
+ ) {
594
+ process.exit(0);
595
+ }
596
+ if (error.code === 'commander.missingArgument') {
597
+ console.error(chalk.red(`Error: ${error.message}`));
598
+ } else if (error.code === 'commander.unknownCommand') {
599
+ console.error(chalk.red(`Error: Unknown command`));
600
+ program.outputHelp();
601
+ } else {
602
+ console.error(chalk.red(`Error: ${error.message}`));
603
+ }
604
+ process.exit(error.exitCode ?? 1);
605
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "native-update-cli",
3
+ "private": true,
4
+ "packageManager": "yarn@4.18.1",
5
+ "description": "CLI for Native Update. No version field on purpose: the CLI ships inside the native-update npm package and reads its version from the ROOT package.json (single source of truth) via cli/index.js.",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=24.16.0"
9
+ },
10
+ "bin": {
11
+ "native-update": "./index.js"
12
+ },
13
+ "dependencies": {
14
+ "archiver": "^8.0.0",
15
+ "chalk": "^6.0.1",
16
+ "commander": "^15.1.0",
17
+ "express": "^5.3.0",
18
+ "ora": "^10.0.0",
19
+ "prompts": "^2.4.2"
20
+ }
21
+ }
@@ -0,0 +1,24 @@
1
+ import { PluginConfig } from '../core/config';
2
+ import { ReviewConditions, ReviewRequestOptions } from './types';
3
+ import { AppReviewPlugin, ReviewResult, CanRequestReviewResult } from '../definitions';
4
+ import { PluginListenerHandle } from '@capacitor/core';
5
+ export declare class AppReviewManager implements AppReviewPlugin {
6
+ private config;
7
+ private logger;
8
+ private conditionsChecker;
9
+ private rateLimiter;
10
+ private platformHandler;
11
+ private listeners;
12
+ constructor(config: PluginConfig);
13
+ requestReview(options?: ReviewRequestOptions): Promise<ReviewResult>;
14
+ canRequestReview(): Promise<CanRequestReviewResult>;
15
+ openStoreReview(): Promise<void>;
16
+ private getStoreReviewUrl;
17
+ resetReviewPrompts(): Promise<void>;
18
+ setReviewConditions(conditions: ReviewConditions): Promise<void>;
19
+ trackSignificantEvent(eventName: string): Promise<void>;
20
+ getReviewMetrics(): Promise<Record<string, unknown>>;
21
+ addListener(eventName: string, listenerFunc: (data: unknown) => void): PluginListenerHandle;
22
+ removeAllListeners(eventName?: string): void;
23
+ private emit;
24
+ }