native-update 1.3.0 → 1.3.2

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 (66) hide show
  1. package/Readme.md +5 -5
  2. package/cli/index.js +5 -6
  3. package/cli/node_modules/.yarn-integrity +16 -0
  4. package/cli/node_modules/commander/LICENSE +22 -0
  5. package/cli/node_modules/commander/Readme.md +1148 -0
  6. package/cli/node_modules/commander/esm.mjs +16 -0
  7. package/cli/node_modules/commander/index.js +26 -0
  8. package/cli/node_modules/commander/lib/argument.js +145 -0
  9. package/cli/node_modules/commander/lib/command.js +2179 -0
  10. package/cli/node_modules/commander/lib/error.js +43 -0
  11. package/cli/node_modules/commander/lib/help.js +462 -0
  12. package/cli/node_modules/commander/lib/option.js +329 -0
  13. package/cli/node_modules/commander/lib/suggestSimilar.js +100 -0
  14. package/cli/node_modules/commander/package-support.json +16 -0
  15. package/cli/node_modules/commander/package.json +80 -0
  16. package/cli/node_modules/commander/typings/esm.d.mts +3 -0
  17. package/cli/node_modules/commander/typings/index.d.ts +884 -0
  18. package/cli/yarn.lock +8 -0
  19. package/dist/esm/__tests__/delta-processor.test.d.ts +1 -0
  20. package/dist/esm/__tests__/delta-processor.test.js +77 -0
  21. package/dist/esm/__tests__/delta-processor.test.js.map +1 -0
  22. package/dist/esm/__tests__/firestore-schema.test.d.ts +1 -0
  23. package/dist/esm/__tests__/firestore-schema.test.js +74 -0
  24. package/dist/esm/__tests__/firestore-schema.test.js.map +1 -0
  25. package/dist/esm/__tests__/manifest-reader.test.d.ts +1 -0
  26. package/dist/esm/__tests__/manifest-reader.test.js +271 -0
  27. package/dist/esm/__tests__/manifest-reader.test.js.map +1 -0
  28. package/dist/esm/__tests__/rollout-checker.test.d.ts +1 -0
  29. package/dist/esm/__tests__/rollout-checker.test.js +210 -0
  30. package/dist/esm/__tests__/rollout-checker.test.js.map +1 -0
  31. package/dist/esm/core/config.d.ts +26 -0
  32. package/dist/esm/core/config.js +6 -0
  33. package/dist/esm/core/config.js.map +1 -1
  34. package/dist/esm/firestore/firestore-client.d.ts +109 -0
  35. package/dist/esm/firestore/firestore-client.js +260 -0
  36. package/dist/esm/firestore/firestore-client.js.map +1 -0
  37. package/dist/esm/firestore/index.d.ts +11 -0
  38. package/dist/esm/firestore/index.js +11 -0
  39. package/dist/esm/firestore/index.js.map +1 -0
  40. package/dist/esm/firestore/manifest-reader.d.ts +87 -0
  41. package/dist/esm/firestore/manifest-reader.js +294 -0
  42. package/dist/esm/firestore/manifest-reader.js.map +1 -0
  43. package/dist/esm/firestore/schema.d.ts +504 -0
  44. package/dist/esm/firestore/schema.js +69 -0
  45. package/dist/esm/firestore/schema.js.map +1 -0
  46. package/dist/esm/live-update/delta-processor.d.ts +94 -0
  47. package/dist/esm/live-update/delta-processor.js +212 -0
  48. package/dist/esm/live-update/delta-processor.js.map +1 -0
  49. package/dist/esm/live-update/rollout-checker.d.ts +86 -0
  50. package/dist/esm/live-update/rollout-checker.js +305 -0
  51. package/dist/esm/live-update/rollout-checker.js.map +1 -0
  52. package/dist/esm/live-update/version-manager.d.ts +12 -0
  53. package/dist/esm/live-update/version-manager.js +67 -0
  54. package/dist/esm/live-update/version-manager.js.map +1 -1
  55. package/dist/plugin.cjs.js +1 -1
  56. package/dist/plugin.cjs.js.map +1 -1
  57. package/dist/plugin.esm.js +1 -1
  58. package/dist/plugin.esm.js.map +1 -1
  59. package/dist/plugin.js +1 -1
  60. package/dist/plugin.js.map +1 -1
  61. package/docs/QUICK_START.md +3 -3
  62. package/docs/README.md +4 -4
  63. package/docs/api/API.md +4 -3
  64. package/docs/getting-started/installation.md +2 -2
  65. package/docs/play-console-rejection-rules.json +428 -0
  66. package/package.json +20 -18
@@ -0,0 +1,504 @@
1
+ /**
2
+ * Firestore Schema Types
3
+ *
4
+ * These interfaces define the structure of all Firestore documents
5
+ * used by the native-update plugin for the free backend architecture.
6
+ *
7
+ * Collections:
8
+ * - manifests/{appId}_{channel} - Update manifests (1 read per update check)
9
+ * - apps/{appId} - App registry (admin only)
10
+ * - builds/{buildId} - Build archive (admin only)
11
+ * - deltas/{appId}_{fromVersion}_{toVersion} - Delta patch registry
12
+ * - analytics_batch/{batchId} - Batched analytics
13
+ */
14
+ /**
15
+ * Firestore Timestamp type (compatible with Firebase SDK)
16
+ */
17
+ export interface FirestoreTimestamp {
18
+ seconds: number;
19
+ nanoseconds: number;
20
+ }
21
+ /**
22
+ * Convert FirestoreTimestamp to JavaScript Date
23
+ */
24
+ export declare function timestampToDate(timestamp: FirestoreTimestamp): Date;
25
+ /**
26
+ * Convert JavaScript Date to FirestoreTimestamp
27
+ */
28
+ export declare function dateToTimestamp(date: Date): FirestoreTimestamp;
29
+ /**
30
+ * Manifest Document - The ONLY document clients read for update checks
31
+ *
32
+ * Collection: manifests/{appId}_{channel}
33
+ * Example ID: "com.myapp.app_production"
34
+ *
35
+ * Design: Single document per app+channel to minimize Firestore reads
36
+ */
37
+ export interface ManifestDocument {
38
+ /** App identifier (e.g., "com.myapp.app") */
39
+ appId: string;
40
+ /** Update channel */
41
+ channel: 'production' | 'staging' | 'development';
42
+ /** Current version information */
43
+ current: ManifestCurrentVersion;
44
+ /** Available delta patches from previous versions */
45
+ deltas: Record<string, ManifestDelta>;
46
+ /** Staged rollout configuration */
47
+ rollout: RolloutConfig;
48
+ /** Previous versions for rollback */
49
+ previousVersions: ManifestPreviousVersion[];
50
+ /** Last update timestamp */
51
+ updatedAt: FirestoreTimestamp;
52
+ /** User who last updated */
53
+ updatedBy: string;
54
+ }
55
+ /**
56
+ * Current version info in manifest
57
+ */
58
+ export interface ManifestCurrentVersion {
59
+ /** Semantic version (e.g., "1.2.0") */
60
+ version: string;
61
+ /** Unique bundle identifier */
62
+ bundleId: string;
63
+ /** Google Drive direct download URL */
64
+ bundleUrl: string;
65
+ /** Google Drive URL for file manifest JSON */
66
+ manifestUrl: string;
67
+ /** SHA-256 checksum of the full bundle */
68
+ checksum: string;
69
+ /** Optional RSA-PSS signature (base64) */
70
+ signature?: string;
71
+ /** Bundle size in bytes */
72
+ size: number;
73
+ /** Release notes for this version */
74
+ releaseNotes: string;
75
+ /** Release date */
76
+ releaseDate: FirestoreTimestamp;
77
+ /** Force all users to update */
78
+ mandatory: boolean;
79
+ /** Minimum native app version required */
80
+ minNativeVersion: string;
81
+ }
82
+ /**
83
+ * Delta patch info for a specific source version
84
+ */
85
+ export interface ManifestDelta {
86
+ /** Google Drive URL for delta patch file */
87
+ patchUrl: string;
88
+ /** Size of the patch file in bytes */
89
+ patchSize: number;
90
+ /** SHA-256 checksum of the patch file */
91
+ patchChecksum: string;
92
+ /** SHA-256 checksum of the result after applying patch */
93
+ targetChecksum: string;
94
+ }
95
+ /**
96
+ * Previous version info for rollback
97
+ */
98
+ export interface ManifestPreviousVersion {
99
+ /** Version string */
100
+ version: string;
101
+ /** Google Drive download URL */
102
+ bundleUrl: string;
103
+ /** SHA-256 checksum */
104
+ checksum: string;
105
+ /** Bundle size in bytes */
106
+ size: number;
107
+ }
108
+ /**
109
+ * Staged rollout configuration
110
+ */
111
+ export interface RolloutConfig {
112
+ /** Whether rollout is enabled */
113
+ enabled: boolean;
114
+ /** Current rollout percentage (0-100) */
115
+ percentage: number;
116
+ /** When the rollout started */
117
+ startTime: FirestoreTimestamp;
118
+ /** When the rollout ends (null = indefinite) */
119
+ endTime: FirestoreTimestamp | null;
120
+ /** Target user segments */
121
+ targetSegments?: RolloutTargetSegments;
122
+ /** Rollout schedule configuration */
123
+ schedule?: RolloutSchedule;
124
+ }
125
+ /**
126
+ * Target segments for rollout
127
+ */
128
+ export interface RolloutTargetSegments {
129
+ /** Target platforms */
130
+ platforms?: ('ios' | 'android' | 'web')[];
131
+ /** Minimum app version to receive update */
132
+ minAppVersion?: string;
133
+ /** Maximum app version to receive update */
134
+ maxAppVersion?: string;
135
+ /** Specific device IDs to target */
136
+ deviceIds?: string[];
137
+ /** ISO country codes to target */
138
+ regions?: string[];
139
+ }
140
+ /**
141
+ * Rollout schedule configuration
142
+ */
143
+ export interface RolloutSchedule {
144
+ /** Schedule type */
145
+ type: 'immediate' | 'gradual' | 'scheduled';
146
+ /** Percentage steps for gradual rollout (e.g., [10, 25, 50, 100]) */
147
+ gradualSteps?: number[];
148
+ /** Hours between gradual steps */
149
+ gradualInterval?: number;
150
+ /** Scheduled start time (for scheduled type) */
151
+ scheduledTime?: FirestoreTimestamp;
152
+ }
153
+ /**
154
+ * App Document - App registry for admin dashboard
155
+ *
156
+ * Collection: apps/{appId}
157
+ */
158
+ export interface AppDocument {
159
+ /** App ID (document ID) */
160
+ id: string;
161
+ /** Owner user ID */
162
+ userId: string;
163
+ /** App display name */
164
+ name: string;
165
+ /** Package identifier (e.g., "com.example.app") */
166
+ packageId: string;
167
+ /** App icon URL (Google Drive or data URL) */
168
+ icon: string | null;
169
+ /** App description */
170
+ description: string;
171
+ /** Supported platforms */
172
+ platforms: ('ios' | 'android' | 'web')[];
173
+ /** Channel configurations */
174
+ channels: {
175
+ production: ChannelConfig;
176
+ staging: ChannelConfig;
177
+ development: ChannelConfig;
178
+ };
179
+ /** Google Drive folder structure */
180
+ driveFolders: {
181
+ rootFolderId: string;
182
+ productionFolderId: string;
183
+ stagingFolderId: string;
184
+ developmentFolderId: string;
185
+ };
186
+ /** Aggregated statistics */
187
+ stats: {
188
+ totalBuilds: number;
189
+ activeUsers: number;
190
+ downloadsThisMonth: number;
191
+ lastBuildDate: FirestoreTimestamp | null;
192
+ };
193
+ /** Public key for bundle verification (base64) */
194
+ publicKey?: string;
195
+ /** Creation timestamp */
196
+ createdAt: FirestoreTimestamp;
197
+ /** Last update timestamp */
198
+ updatedAt: FirestoreTimestamp;
199
+ }
200
+ /**
201
+ * Channel configuration
202
+ */
203
+ export interface ChannelConfig {
204
+ /** Whether channel is enabled */
205
+ enabled: boolean;
206
+ /** Enable automatic updates */
207
+ autoUpdate: boolean;
208
+ /** Update strategy */
209
+ updateStrategy: 'immediate' | 'background' | 'manual';
210
+ /** Require user consent before update */
211
+ requireUserConsent: boolean;
212
+ /** Minimum native version for this channel */
213
+ minNativeVersion: string | null;
214
+ /** Enable automatic rollback on errors */
215
+ autoRollbackEnabled: boolean;
216
+ /** Error percentage threshold to trigger rollback */
217
+ rollbackThreshold: number;
218
+ }
219
+ /**
220
+ * Build Document - Complete build history
221
+ *
222
+ * Collection: builds/{buildId}
223
+ */
224
+ export interface BuildDocument {
225
+ /** Build ID (document ID) */
226
+ id: string;
227
+ /** Owner user ID */
228
+ userId: string;
229
+ /** App ID this build belongs to */
230
+ appId: string;
231
+ /** Semantic version */
232
+ version: string;
233
+ /** Build number (auto-incremented) */
234
+ buildNumber: number;
235
+ /** Update channel */
236
+ channel: 'production' | 'staging' | 'development';
237
+ /** Target platform */
238
+ platform: 'ios' | 'android' | 'web' | 'universal';
239
+ /** Original file name */
240
+ fileName: string;
241
+ /** File size in bytes */
242
+ fileSize: number;
243
+ /** MIME type */
244
+ mimeType: string;
245
+ /** SHA-256 checksum */
246
+ checksum: string;
247
+ /** RSA-PSS signature (base64) */
248
+ signature: string | null;
249
+ /** Google Drive file ID */
250
+ driveFileId: string;
251
+ /** Google Drive direct download URL */
252
+ driveFileUrl: string;
253
+ /** Google Drive folder ID */
254
+ driveFolderId: string;
255
+ /** File manifest for delta calculation */
256
+ fileManifest: FileManifestEntry[];
257
+ /** Google Drive ID of manifest JSON file */
258
+ manifestDriveId: string;
259
+ /** Release notes */
260
+ releaseNotes: string;
261
+ /** Release type */
262
+ releaseType: 'major' | 'minor' | 'patch' | 'hotfix';
263
+ /** Pre-release flag */
264
+ isPreRelease: boolean;
265
+ /** Minimum native app version */
266
+ minNativeVersion: string;
267
+ /** Upload timestamp */
268
+ uploadedAt: FirestoreTimestamp;
269
+ /** User who uploaded */
270
+ uploadedBy: string;
271
+ /** Upload duration in milliseconds */
272
+ uploadDuration: number;
273
+ /** Build status */
274
+ status: 'uploading' | 'processing' | 'active' | 'archived' | 'failed';
275
+ /** Processing steps status */
276
+ processingSteps: {
277
+ uploaded: boolean;
278
+ manifestGenerated: boolean;
279
+ deltasGenerated: boolean;
280
+ published: boolean;
281
+ };
282
+ /** Analytics (updated periodically) */
283
+ analytics: {
284
+ downloads: number;
285
+ installs: number;
286
+ rollbacks: number;
287
+ errors: number;
288
+ lastDownload: FirestoreTimestamp | null;
289
+ };
290
+ /** Last update timestamp */
291
+ updatedAt: FirestoreTimestamp;
292
+ }
293
+ /**
294
+ * File manifest entry for delta calculation
295
+ */
296
+ export interface FileManifestEntry {
297
+ /** Relative path within bundle */
298
+ path: string;
299
+ /** SHA-256 checksum of file content */
300
+ checksum: string;
301
+ /** File size in bytes */
302
+ size: number;
303
+ }
304
+ /**
305
+ * Delta Document - Pre-computed delta patches
306
+ *
307
+ * Collection: deltas/{appId}_{fromVersion}_{toVersion}
308
+ * Example ID: "com.myapp.app_1.0.0_1.1.0"
309
+ */
310
+ export interface DeltaDocument {
311
+ /** App ID */
312
+ appId: string;
313
+ /** Source version */
314
+ fromVersion: string;
315
+ /** Target version */
316
+ toVersion: string;
317
+ /** Channel */
318
+ channel: 'production' | 'staging' | 'development';
319
+ /** Google Drive file ID for patch */
320
+ patchDriveId: string;
321
+ /** Google Drive download URL */
322
+ patchUrl: string;
323
+ /** Patch file size in bytes */
324
+ patchSize: number;
325
+ /** SHA-256 checksum of patch file */
326
+ patchChecksum: string;
327
+ /** SHA-256 checksum of source bundle */
328
+ sourceChecksum: string;
329
+ /** SHA-256 checksum after applying patch */
330
+ targetChecksum: string;
331
+ /** Generation timestamp */
332
+ generatedAt: FirestoreTimestamp;
333
+ /** Generation duration in milliseconds */
334
+ generationDuration: number;
335
+ /** Diff algorithm used */
336
+ algorithm: 'bsdiff' | 'vcdiff';
337
+ /** Compression ratio (patchSize / fullSize) */
338
+ compressionRatio: number;
339
+ /** Delta status */
340
+ status: 'generating' | 'ready' | 'failed';
341
+ }
342
+ /**
343
+ * Analytics Batch Document - Batched analytics events
344
+ *
345
+ * Collection: analytics_batch/{batchId}
346
+ *
347
+ * Design: Clients batch events locally and write in bulk
348
+ * to minimize Firestore write operations
349
+ */
350
+ export interface AnalyticsBatchDocument {
351
+ /** App ID */
352
+ appId: string;
353
+ /** Channel */
354
+ channel: 'production' | 'staging' | 'development';
355
+ /** Batch window start */
356
+ windowStart: FirestoreTimestamp;
357
+ /** Batch window end */
358
+ windowEnd: FirestoreTimestamp;
359
+ /** Aggregated event counts */
360
+ events: {
361
+ updateChecks: number;
362
+ downloads: number;
363
+ installs: number;
364
+ rollbacks: number;
365
+ errors: number;
366
+ };
367
+ /** Per-version statistics */
368
+ versionStats: Record<string, {
369
+ downloads: number;
370
+ installs: number;
371
+ errors: number;
372
+ }>;
373
+ /** Per-platform statistics */
374
+ platformStats: {
375
+ ios: {
376
+ downloads: number;
377
+ installs: number;
378
+ };
379
+ android: {
380
+ downloads: number;
381
+ installs: number;
382
+ };
383
+ web: {
384
+ downloads: number;
385
+ installs: number;
386
+ };
387
+ };
388
+ /** Sampled error details */
389
+ errorSamples: ErrorSample[];
390
+ /** Creation timestamp */
391
+ createdAt: FirestoreTimestamp;
392
+ }
393
+ /**
394
+ * Sampled error for analytics
395
+ */
396
+ export interface ErrorSample {
397
+ /** Error code */
398
+ code: string;
399
+ /** Error message */
400
+ message: string;
401
+ /** Occurrence count */
402
+ count: number;
403
+ /** Last occurrence time */
404
+ lastOccurrence: FirestoreTimestamp;
405
+ }
406
+ /**
407
+ * Device information used for rollout eligibility checks
408
+ */
409
+ export interface DeviceInfo {
410
+ /** Unique device identifier */
411
+ deviceId: string;
412
+ /** Device platform */
413
+ platform: 'ios' | 'android' | 'web';
414
+ /** Native app version */
415
+ appVersion: string;
416
+ /** Current bundle version */
417
+ bundleVersion: string;
418
+ /** OS version */
419
+ osVersion: string;
420
+ /** ISO region/country code */
421
+ region?: string;
422
+ /** Device locale */
423
+ locale: string;
424
+ }
425
+ /**
426
+ * Response from update check (parsed from ManifestDocument)
427
+ */
428
+ export interface UpdateCheckResponse {
429
+ /** Whether an update is available */
430
+ updateAvailable: boolean;
431
+ /** Latest version info */
432
+ version?: string;
433
+ /** Bundle download URL */
434
+ bundleUrl?: string;
435
+ /** Minimum native app version required */
436
+ minNativeVersion?: string;
437
+ /** Release notes */
438
+ releaseNotes?: string;
439
+ /** Bundle signature */
440
+ signature?: string;
441
+ /** Bundle checksum */
442
+ checksum?: string;
443
+ /** Whether update is mandatory */
444
+ mandatory?: boolean;
445
+ /** Bundle size in bytes */
446
+ size?: number;
447
+ /** Delta patch info if available */
448
+ delta?: {
449
+ available: boolean;
450
+ patchUrl?: string;
451
+ patchSize?: number;
452
+ patchChecksum?: string;
453
+ targetChecksum?: string;
454
+ };
455
+ /** Rollout eligibility */
456
+ rolloutEligible?: boolean;
457
+ /** Reason if not eligible */
458
+ rolloutReason?: string;
459
+ }
460
+ /**
461
+ * Firestore configuration for the plugin
462
+ */
463
+ export interface FirestoreConfig {
464
+ /** Firebase project ID */
465
+ projectId: string;
466
+ /** Firestore database ID (default: "(default)") */
467
+ databaseId?: string;
468
+ /** App ID for update checks */
469
+ appId: string;
470
+ /** Update channel */
471
+ channel: 'production' | 'staging' | 'development';
472
+ /** Cache duration for manifests in milliseconds (default: 5 minutes) */
473
+ cacheDuration?: number;
474
+ /** Enable offline persistence */
475
+ enableOffline?: boolean;
476
+ }
477
+ /**
478
+ * Firestore collection paths
479
+ */
480
+ export declare const COLLECTIONS: {
481
+ readonly MANIFESTS: "manifests";
482
+ readonly APPS: "apps";
483
+ readonly BUILDS: "builds";
484
+ readonly DELTAS: "deltas";
485
+ readonly ANALYTICS_BATCH: "analytics_batch";
486
+ readonly DRIVE_TOKENS: "drive_tokens";
487
+ readonly USERS: "users";
488
+ };
489
+ /**
490
+ * Generate manifest document ID
491
+ */
492
+ export declare function getManifestId(appId: string, channel: string): string;
493
+ /**
494
+ * Generate delta document ID
495
+ */
496
+ export declare function getDeltaId(appId: string, fromVersion: string, toVersion: string): string;
497
+ /**
498
+ * Validate semantic version format
499
+ */
500
+ export declare function isValidVersion(version: string): boolean;
501
+ /**
502
+ * Validate SHA-256 checksum format
503
+ */
504
+ export declare function isValidChecksum(checksum: string): boolean;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Firestore Schema Types
3
+ *
4
+ * These interfaces define the structure of all Firestore documents
5
+ * used by the native-update plugin for the free backend architecture.
6
+ *
7
+ * Collections:
8
+ * - manifests/{appId}_{channel} - Update manifests (1 read per update check)
9
+ * - apps/{appId} - App registry (admin only)
10
+ * - builds/{buildId} - Build archive (admin only)
11
+ * - deltas/{appId}_{fromVersion}_{toVersion} - Delta patch registry
12
+ * - analytics_batch/{batchId} - Batched analytics
13
+ */
14
+ /**
15
+ * Convert FirestoreTimestamp to JavaScript Date
16
+ */
17
+ export function timestampToDate(timestamp) {
18
+ return new Date(timestamp.seconds * 1000 + timestamp.nanoseconds / 1000000);
19
+ }
20
+ /**
21
+ * Convert JavaScript Date to FirestoreTimestamp
22
+ */
23
+ export function dateToTimestamp(date) {
24
+ const ms = date.getTime();
25
+ return {
26
+ seconds: Math.floor(ms / 1000),
27
+ nanoseconds: (ms % 1000) * 1000000,
28
+ };
29
+ }
30
+ // ============================================
31
+ // COLLECTION HELPERS
32
+ // ============================================
33
+ /**
34
+ * Firestore collection paths
35
+ */
36
+ export const COLLECTIONS = {
37
+ MANIFESTS: 'manifests',
38
+ APPS: 'apps',
39
+ BUILDS: 'builds',
40
+ DELTAS: 'deltas',
41
+ ANALYTICS_BATCH: 'analytics_batch',
42
+ DRIVE_TOKENS: 'drive_tokens',
43
+ USERS: 'users',
44
+ };
45
+ /**
46
+ * Generate manifest document ID
47
+ */
48
+ export function getManifestId(appId, channel) {
49
+ return `${appId}_${channel}`;
50
+ }
51
+ /**
52
+ * Generate delta document ID
53
+ */
54
+ export function getDeltaId(appId, fromVersion, toVersion) {
55
+ return `${appId}_${fromVersion}_${toVersion}`;
56
+ }
57
+ /**
58
+ * Validate semantic version format
59
+ */
60
+ export function isValidVersion(version) {
61
+ return /^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?$/.test(version);
62
+ }
63
+ /**
64
+ * Validate SHA-256 checksum format
65
+ */
66
+ export function isValidChecksum(checksum) {
67
+ return /^[a-f0-9]{64}$/i.test(checksum);
68
+ }
69
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/firestore/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,SAA6B;IAC3D,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,WAAW,GAAG,OAAO,CAAC,CAAC;AAC9E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,IAAU;IACxC,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC1B,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC;QAC9B,WAAW,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO;KACnC,CAAC;AACJ,CAAC;AAknBD,+CAA+C;AAC/C,qBAAqB;AACrB,+CAA+C;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,SAAS,EAAE,WAAW;IACtB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,eAAe,EAAE,iBAAiB;IAClC,YAAY,EAAE,cAAc;IAC5B,KAAK,EAAE,OAAO;CACN,CAAC;AAEX;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAa,EACb,OAAe;IAEf,OAAO,GAAG,KAAK,IAAI,OAAO,EAAE,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CACxB,KAAa,EACb,WAAmB,EACnB,SAAiB;IAEjB,OAAO,GAAG,KAAK,IAAI,WAAW,IAAI,SAAS,EAAE,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,OAAO,kCAAkC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC1D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Delta Processor
3
+ *
4
+ * Handles delta/patch-based updates for reduced download sizes.
5
+ * Uses a simple file-level patching strategy that works in JavaScript.
6
+ *
7
+ * For production, a WASM-based bsdiff/bspatch implementation can be added
8
+ * for better performance on binary files.
9
+ */
10
+ import type { UpdateCheckResponse } from '../firestore/schema';
11
+ /**
12
+ * Delta patch information
13
+ */
14
+ export interface DeltaPatchInfo {
15
+ /** Whether delta is available for current version */
16
+ available: boolean;
17
+ /** Patch download URL */
18
+ patchUrl?: string;
19
+ /** Patch size in bytes */
20
+ patchSize?: number;
21
+ /** Checksum of the patch file */
22
+ patchChecksum?: string;
23
+ /** Expected checksum after applying patch */
24
+ targetChecksum?: string;
25
+ }
26
+ /**
27
+ * Delta download result
28
+ */
29
+ export interface DeltaDownloadResult {
30
+ /** Whether delta was used */
31
+ usedDelta: boolean;
32
+ /** The final bundle data */
33
+ bundleData: ArrayBuffer;
34
+ /** Checksum of the bundle */
35
+ checksum: string;
36
+ /** Download size (delta or full) */
37
+ downloadSize: number;
38
+ /** Time taken in milliseconds */
39
+ duration: number;
40
+ }
41
+ /**
42
+ * Delta processor for applying patch updates
43
+ */
44
+ export declare class DeltaProcessor {
45
+ private readonly logger;
46
+ private readonly configManager;
47
+ constructor();
48
+ /**
49
+ * Download update with delta support
50
+ * Falls back to full download if delta fails
51
+ */
52
+ downloadWithDelta(updateInfo: UpdateCheckResponse, currentBundleData: ArrayBuffer | null, onProgress?: (percent: number) => void): Promise<DeltaDownloadResult>;
53
+ /**
54
+ * Download a delta patch file
55
+ */
56
+ private downloadPatch;
57
+ /**
58
+ * Download full bundle
59
+ */
60
+ private downloadFull;
61
+ /**
62
+ * Apply a delta patch to create new bundle
63
+ *
64
+ * This is a simplified patch format using JSON metadata + file-level changes.
65
+ * For production binary patching, a WASM bspatch implementation would be used.
66
+ */
67
+ private applyPatch;
68
+ /**
69
+ * Apply file-level patch (JSON format)
70
+ */
71
+ private applyFileLevelPatch;
72
+ /**
73
+ * Apply binary patch (bsdiff format)
74
+ *
75
+ * NOTE: This is a placeholder. For production, use WASM-compiled bspatch.
76
+ */
77
+ private applyBinaryPatch;
78
+ /**
79
+ * Calculate SHA-256 checksum
80
+ */
81
+ calculateChecksum(data: ArrayBuffer): Promise<string>;
82
+ /**
83
+ * Verify checksum matches
84
+ */
85
+ verifyChecksum(data: ArrayBuffer, expectedChecksum: string): Promise<boolean>;
86
+ /**
87
+ * Check if delta updates are enabled
88
+ */
89
+ isDeltaEnabled(): boolean;
90
+ }
91
+ /**
92
+ * Create delta processor instance
93
+ */
94
+ export declare function createDeltaProcessor(): DeltaProcessor;