native-update 3.1.0 → 3.1.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 (64) hide show
  1. package/AI-INTEGRATION-GUIDE.md +88 -58
  2. package/Readme.md +57 -88
  3. package/cli/AGENTS.md +9 -0
  4. package/cli/CLAUDE.md +9 -0
  5. package/cli/package.json +2 -2
  6. package/dist/esm/app-update/app-update-checker.d.ts +19 -0
  7. package/dist/esm/app-update/app-update-checker.js +19 -0
  8. package/dist/esm/background-update/background-scheduler.d.ts +21 -0
  9. package/dist/esm/background-update/background-scheduler.js +47 -24
  10. package/dist/esm/core/update-check.d.ts +89 -0
  11. package/dist/esm/core/update-check.js +86 -0
  12. package/dist/esm/definitions.d.ts +11 -1
  13. package/dist/esm/live-update/version-manager.js +43 -27
  14. package/dist/esm/plugin.js +14 -20
  15. package/dist/esm/types/rollout.d.ts +9 -3
  16. package/dist/plugin.cjs.js +1 -1
  17. package/dist/plugin.esm.js +1 -1
  18. package/dist/plugin.js +2 -2
  19. package/docs/AGENTS.md +9 -0
  20. package/docs/CHANGELOG.md +51 -0
  21. package/docs/CLAUDE.md +9 -0
  22. package/docs/DEPLOY_NOTES.md +116 -0
  23. package/docs/MANUAL-TASKS.md +18 -5
  24. package/docs/api/background-update-api.md +14 -1
  25. package/docs/features/e2e-full-verification/00-overview.md +99 -0
  26. package/docs/features/e2e-full-verification/00-tracker.json +284 -0
  27. package/docs/features/e2e-full-verification/phase01-backend-schema-fixes.md +183 -0
  28. package/docs/features/e2e-full-verification/phase02-test-auth.md +176 -0
  29. package/docs/features/e2e-full-verification/phase03-api-test-coverage.md +63 -0
  30. package/docs/features/e2e-full-verification/phase04-frontend-package-contract-audit.md +73 -0
  31. package/docs/features/e2e-full-verification/phase05-browser-e2e-matrix.md +69 -0
  32. package/docs/features/e2e-full-verification/phase06-deploy-prod-smoke.md +51 -0
  33. package/docs/features/e2e-full-verification/results/phase01-drift-report.md +50 -0
  34. package/docs/features/e2e-full-verification/results/phase03-coverage-matrix.md +215 -0
  35. package/docs/features/e2e-full-verification/results/phase04-frontend-contract.md +139 -0
  36. package/docs/features/e2e-full-verification/results/phase05-e2e-results.md +99 -0
  37. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-01-dashboard.png +0 -0
  38. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-02-signup.png +0 -0
  39. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-03-settings-persisted.png +0 -0
  40. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-04a-app-created.png +0 -0
  41. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-04b-duplicate-bundle-422.png +0 -0
  42. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-05-plan-limit-403.png +0 -0
  43. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-08a-upload-graceful-fail.png +0 -0
  44. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-08b-builds-list.png +0 -0
  45. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-10-rollout-25pct.png +0 -0
  46. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-11-analytics.png +0 -0
  47. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-12-drive-disconnected.png +0 -0
  48. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-13-pricing.png +0 -0
  49. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-14-isolation-403.png +0 -0
  50. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-15a-admin-overview.png +0 -0
  51. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-15b-regular-user-admin-redirect.png +0 -0
  52. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-16a-delete-dialog.png +0 -0
  53. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-17-mobile-375.png +0 -0
  54. package/docs/features/e2e-full-verification/results/route-list.json +1 -0
  55. package/docs/features/queues-and-emails/00-overview.md +41 -0
  56. package/docs/features/queues-and-emails/00-tracker.json +99 -0
  57. package/docs/features/queues-and-emails/phase01-foundation.md +15 -0
  58. package/docs/features/queues-and-emails/phase02-queued-jobs.md +19 -0
  59. package/docs/features/queues-and-emails/phase03-transactional-emails.md +16 -0
  60. package/docs/features/queues-and-emails/phase04-quota-ops.md +17 -0
  61. package/docs/features/queues-and-emails/phase05-async-build-processing-DECISION.md +16 -0
  62. package/docs/features/queues-and-emails/phase06-verify-deploy.md +17 -0
  63. package/docs/server-requirements.md +41 -11
  64. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  import { BackgroundUpdateType, UpdateErrorCode } from '../definitions';
2
2
  import { Logger } from '../core/logger';
3
3
  import { ConfigManager } from '../core/config';
4
+ import { checkForUpdate } from '../core/update-check';
4
5
  export class BackgroundScheduler {
5
6
  constructor() {
6
7
  this.config = null;
@@ -97,6 +98,27 @@ export class BackgroundScheduler {
97
98
  notificationSent,
98
99
  };
99
100
  }
101
+ /**
102
+ * Check whether a newer NATIVE app-store binary is available.
103
+ *
104
+ * Primary path: the platform `AppUpdateManager` (Play Core / App Store).
105
+ *
106
+ * Fallback path: a GET to `{serverUrl}/app-version`. This is a
107
+ * deliberate **custom-backend extension point**, NOT part of the Native
108
+ * Update (Laravel) backend — that backend ships OTA bundles, it has no
109
+ * concept of the store binary version. A self-hoster who wants
110
+ * server-driven native-update prompts implements this endpoint:
111
+ *
112
+ * ```
113
+ * GET {serverUrl}/app-version
114
+ * X-Current-Version: <installed app version>
115
+ * X-Platform: ios | android | web
116
+ * → 200 { "version": "2.1.0", "priority": 3 } // or { "latestVersion": … }
117
+ * ```
118
+ *
119
+ * If the endpoint is absent the fallback just fails closed
120
+ * (updateAvailable=false). See `docs/api/background-update-api.md`.
121
+ */
100
122
  async checkAppUpdate() {
101
123
  // Use AppUpdateManager if available
102
124
  if (this.deps.appUpdateManager) {
@@ -107,7 +129,7 @@ export class BackgroundScheduler {
107
129
  this.logger.error('Failed to check app update via manager', error);
108
130
  }
109
131
  }
110
- // Fallback: Check via server if configured
132
+ // Fallback: optional custom `/app-version` endpoint (see method JSDoc).
111
133
  const serverUrl = this.configManager.get('baseUrl') || this.configManager.get('serverUrl');
112
134
  if (serverUrl) {
113
135
  try {
@@ -145,6 +167,7 @@ export class BackgroundScheduler {
145
167
  };
146
168
  }
147
169
  async checkLiveUpdate() {
170
+ var _a;
148
171
  // Get current bundle version
149
172
  let currentVersion = '1.0.0';
150
173
  if (this.deps.bundleManager) {
@@ -154,7 +177,7 @@ export class BackgroundScheduler {
154
177
  currentVersion = activeBundle.version;
155
178
  }
156
179
  }
157
- catch (_a) {
180
+ catch (_b) {
158
181
  // Use default version
159
182
  }
160
183
  }
@@ -175,31 +198,31 @@ export class BackgroundScheduler {
175
198
  this.logger.error('Failed to check live update via VersionManager', error);
176
199
  }
177
200
  }
178
- // Fallback: Check via server if configured
201
+ // Fallback: check the Native Update backend directly via the shared
202
+ // /v1/updates/check contract (same endpoint plugin.checkForUpdate() and
203
+ // VersionManager use). The old `/updates/latest` path was never served
204
+ // by the backend, so this fallback previously always failed silently.
179
205
  const serverUrl = this.configManager.get('baseUrl') || this.configManager.get('serverUrl');
180
- if (serverUrl) {
206
+ const apiKey = this.configManager.get('apiKey');
207
+ if (serverUrl && apiKey) {
181
208
  try {
182
- const response = await fetch(`${serverUrl}/updates/latest`, {
183
- method: 'GET',
184
- headers: {
185
- 'Content-Type': 'application/json',
186
- 'X-Current-Version': currentVersion,
187
- },
209
+ const channel = this.configManager.get('channel') || 'production';
210
+ const data = await checkForUpdate(serverUrl, {
211
+ apiKey,
212
+ channel,
213
+ currentVersion,
214
+ deviceId: 'web-client',
215
+ platform: this.getPlatform(),
216
+ appVersion: currentVersion,
188
217
  });
189
- if (response.ok) {
190
- const data = await response.json();
191
- const latestVersion = data.version || data.latestVersion;
192
- const updateAvailable = latestVersion &&
193
- this.compareVersions(currentVersion, latestVersion) < 0;
194
- return {
195
- available: updateAvailable,
196
- version: latestVersion,
197
- url: updateAvailable ? data.url : undefined,
198
- notes: data.notes || data.releaseNotes,
199
- size: data.size,
200
- checksum: data.checksum,
201
- };
202
- }
218
+ return {
219
+ available: data.available,
220
+ version: data.version,
221
+ url: data.available ? data.downloadUrl : undefined,
222
+ notes: (_a = data.releaseNotes) !== null && _a !== void 0 ? _a : undefined,
223
+ size: data.size,
224
+ checksum: data.checksum,
225
+ };
203
226
  }
204
227
  catch (error) {
205
228
  this.logger.error('Failed to check live update via server', error);
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Single source of truth for the Native Update backend update-check
3
+ * contract.
4
+ *
5
+ * Every "does the Laravel backend have a newer bundle for me?" call in the
6
+ * plugin funnels through {@link checkForUpdate} so the wire shape — path,
7
+ * headers, query, and response fields — is defined in exactly one place.
8
+ * Before this helper existed, three modules each rolled their own request
9
+ * against paths the backend does not serve (`/check`, `/updates/latest`),
10
+ * so background + version-manager update checks silently never worked.
11
+ *
12
+ * ## Wire contract (implemented by `UpdateController@check` in the backend)
13
+ *
14
+ * ```
15
+ * GET {baseUrl}/v1/updates/check?channel={channel}
16
+ * X-API-Key: nu_app_… (required; ValidateApiKey middleware → 401 without it)
17
+ * X-Device-ID: stable per-device hash (required; 400 without it)
18
+ * X-Current-Version: the currently-installed bundle version
19
+ * X-Platform: ios | android | web
20
+ * X-App-Version: native app version (optional)
21
+ * ```
22
+ *
23
+ * Response (200):
24
+ * ```jsonc
25
+ * // no update:
26
+ * { "available": false, "message": "…" }
27
+ * // update available:
28
+ * {
29
+ * "available": true,
30
+ * "version": "1.2.3",
31
+ * "bundleId": "…uuid…",
32
+ * "downloadUrl": "https://…signed…",
33
+ * "checksum": "…sha256…",
34
+ * "signature": "…|null",
35
+ * "size": 123456,
36
+ * "mandatory": false,
37
+ * "releaseNotes": "…|null",
38
+ * "minNativeVersion": "…|null",
39
+ * "expiresAt": "ISO-8601"
40
+ * }
41
+ * ```
42
+ *
43
+ * Custom backends must return these exact field names — see
44
+ * `docs/server-requirements.md`.
45
+ */
46
+ /** Request inputs for a single backend update check. */
47
+ export interface UpdateCheckRequest {
48
+ /** API key issued by the dashboard; sent as `X-API-Key`. Required. */
49
+ apiKey: string;
50
+ /** Release channel (`production` | `staging` | `development`). */
51
+ channel: string;
52
+ /** Currently-installed bundle version; sent as `X-Current-Version`. */
53
+ currentVersion: string;
54
+ /** Stable device identifier; sent as `X-Device-ID`. Required by the backend. */
55
+ deviceId: string;
56
+ /** Device platform (`ios` | `android` | `web`); sent as `X-Platform`. */
57
+ platform: string;
58
+ /** Native app version; sent as `X-App-Version` when present. */
59
+ appVersion?: string;
60
+ /** Optional abort signal so callers can time the request out. */
61
+ signal?: AbortSignal;
62
+ }
63
+ /**
64
+ * Normalized response from `GET {baseUrl}/v1/updates/check`. Field names
65
+ * mirror the backend JSON verbatim (already camelCase on the wire).
66
+ */
67
+ export interface BackendUpdateCheckResponse {
68
+ available: boolean;
69
+ version?: string;
70
+ bundleId?: string;
71
+ downloadUrl?: string;
72
+ checksum?: string;
73
+ signature?: string | null;
74
+ size?: number;
75
+ mandatory?: boolean;
76
+ releaseNotes?: string | null;
77
+ minNativeVersion?: string | null;
78
+ expiresAt?: string;
79
+ message?: string;
80
+ }
81
+ /**
82
+ * Perform one update check against the Native Update backend.
83
+ *
84
+ * Returns `{ available: false }` for any non-2xx response (the backend
85
+ * uses 200 for "no update" and reserves 4xx for auth/validation failures,
86
+ * which are non-actionable for an update check). Network failures reject —
87
+ * callers decide whether to swallow or surface them.
88
+ */
89
+ export declare function checkForUpdate(baseUrl: string, req: UpdateCheckRequest): Promise<BackendUpdateCheckResponse>;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Single source of truth for the Native Update backend update-check
3
+ * contract.
4
+ *
5
+ * Every "does the Laravel backend have a newer bundle for me?" call in the
6
+ * plugin funnels through {@link checkForUpdate} so the wire shape — path,
7
+ * headers, query, and response fields — is defined in exactly one place.
8
+ * Before this helper existed, three modules each rolled their own request
9
+ * against paths the backend does not serve (`/check`, `/updates/latest`),
10
+ * so background + version-manager update checks silently never worked.
11
+ *
12
+ * ## Wire contract (implemented by `UpdateController@check` in the backend)
13
+ *
14
+ * ```
15
+ * GET {baseUrl}/v1/updates/check?channel={channel}
16
+ * X-API-Key: nu_app_… (required; ValidateApiKey middleware → 401 without it)
17
+ * X-Device-ID: stable per-device hash (required; 400 without it)
18
+ * X-Current-Version: the currently-installed bundle version
19
+ * X-Platform: ios | android | web
20
+ * X-App-Version: native app version (optional)
21
+ * ```
22
+ *
23
+ * Response (200):
24
+ * ```jsonc
25
+ * // no update:
26
+ * { "available": false, "message": "…" }
27
+ * // update available:
28
+ * {
29
+ * "available": true,
30
+ * "version": "1.2.3",
31
+ * "bundleId": "…uuid…",
32
+ * "downloadUrl": "https://…signed…",
33
+ * "checksum": "…sha256…",
34
+ * "signature": "…|null",
35
+ * "size": 123456,
36
+ * "mandatory": false,
37
+ * "releaseNotes": "…|null",
38
+ * "minNativeVersion": "…|null",
39
+ * "expiresAt": "ISO-8601"
40
+ * }
41
+ * ```
42
+ *
43
+ * Custom backends must return these exact field names — see
44
+ * `docs/server-requirements.md`.
45
+ */
46
+ /**
47
+ * Perform one update check against the Native Update backend.
48
+ *
49
+ * Returns `{ available: false }` for any non-2xx response (the backend
50
+ * uses 200 for "no update" and reserves 4xx for auth/validation failures,
51
+ * which are non-actionable for an update check). Network failures reject —
52
+ * callers decide whether to swallow or surface them.
53
+ */
54
+ export async function checkForUpdate(baseUrl, req) {
55
+ var _a, _b, _c;
56
+ const url = `${baseUrl.replace(/\/$/, '')}/v1/updates/check?channel=${encodeURIComponent(req.channel)}`;
57
+ const headers = {
58
+ 'Content-Type': 'application/json',
59
+ 'X-API-Key': req.apiKey,
60
+ 'X-Device-ID': req.deviceId,
61
+ 'X-Current-Version': req.currentVersion,
62
+ 'X-Platform': req.platform,
63
+ };
64
+ if (req.appVersion) {
65
+ headers['X-App-Version'] = req.appVersion;
66
+ }
67
+ const response = await fetch(url, { method: 'GET', headers, signal: req.signal });
68
+ if (!response.ok) {
69
+ return { available: false };
70
+ }
71
+ const data = (await response.json());
72
+ return {
73
+ available: Boolean(data.available),
74
+ version: data.version,
75
+ bundleId: data.bundleId,
76
+ downloadUrl: data.downloadUrl,
77
+ checksum: data.checksum,
78
+ signature: (_a = data.signature) !== null && _a !== void 0 ? _a : undefined,
79
+ size: data.size,
80
+ mandatory: data.mandatory,
81
+ releaseNotes: (_b = data.releaseNotes) !== null && _b !== void 0 ? _b : undefined,
82
+ minNativeVersion: (_c = data.minNativeVersion) !== null && _c !== void 0 ? _c : undefined,
83
+ expiresAt: data.expiresAt,
84
+ message: data.message,
85
+ };
86
+ }
@@ -197,6 +197,12 @@ export interface UpdateConfig {
197
197
  }
198
198
  export interface LiveUpdateConfig {
199
199
  appId: string;
200
+ /**
201
+ * Base URL of the Native Update backend. OTA update checks are issued as
202
+ * `GET {serverUrl}/v1/updates/check` (API-key auth via `X-API-Key`); the
203
+ * self-host contract for that endpoint is in `docs/server-requirements.md`.
204
+ * Must be HTTPS in production (the plugin rejects non-HTTPS base URLs).
205
+ */
200
206
  serverUrl?: string;
201
207
  channel?: string;
202
208
  autoUpdate?: boolean;
@@ -703,7 +709,11 @@ export interface PluginInitConfig {
703
709
  */
704
710
  enableLogging?: boolean;
705
711
  /**
706
- * Server URL for update checks
712
+ * Base URL of the Native Update backend for OTA update checks.
713
+ * The plugin appends the versioned path: `GET {serverUrl}/v1/updates/check`
714
+ * with `X-API-Key` / `X-Device-ID` / `X-Current-Version` / `X-Platform`
715
+ * headers. See `docs/server-requirements.md` for the full wire contract
716
+ * (and `core/update-check.ts`, the single implementation of it).
707
717
  */
708
718
  serverUrl?: string;
709
719
  /**
@@ -2,6 +2,7 @@ import { ConfigManager } from '../core/config';
2
2
  import { Logger } from '../core/logger';
3
3
  import { SecurityValidator } from '../core/security';
4
4
  import { ValidationError, ErrorCode } from '../core/errors';
5
+ import { checkForUpdate } from '../core/update-check';
5
6
  /**
6
7
  * Manages version checking and comparison
7
8
  */
@@ -79,6 +80,7 @@ export class VersionManager {
79
80
  * Check for latest version from server
80
81
  */
81
82
  async checkForUpdates(serverUrl, channel, currentVersion, appId) {
83
+ var _a;
82
84
  // Validate inputs
83
85
  this.securityValidator.validateUrl(serverUrl);
84
86
  this.securityValidator.validateVersion(currentVersion);
@@ -97,46 +99,60 @@ export class VersionManager {
97
99
  });
98
100
  return cached.data;
99
101
  }
102
+ // The Native Update backend serves update checks at
103
+ // `/v1/updates/check` (API-key auth), NOT `/check`. Route through the
104
+ // shared helper so this path matches plugin.checkForUpdate() exactly.
105
+ // Without an API key the backend returns 401, so bail early with null.
106
+ const apiKey = this.configManager.get('apiKey');
107
+ if (!apiKey) {
108
+ this.logger.warn('VersionManager.checkForUpdates: no apiKey configured — the Native Update backend requires X-API-Key');
109
+ return null;
110
+ }
100
111
  try {
101
- const url = new URL(`${serverUrl}/check`);
102
- url.searchParams.append('channel', channel);
103
- url.searchParams.append('version', currentVersion);
104
- url.searchParams.append('appId', appId);
105
- url.searchParams.append('platform', 'web'); // Will be overridden by native platforms
106
- const response = await fetch(url.toString(), {
107
- method: 'GET',
108
- headers: {
109
- 'Content-Type': 'application/json',
110
- 'X-App-Version': currentVersion,
111
- 'X-App-Id': appId,
112
- },
112
+ const data = await checkForUpdate(serverUrl, {
113
+ apiKey,
114
+ channel,
115
+ currentVersion,
116
+ // JS-layer fallback identity; native background checks run through
117
+ // the native scheduler with the real device id + platform.
118
+ deviceId: 'web-client',
119
+ platform: 'web',
120
+ appVersion: currentVersion,
113
121
  signal: AbortSignal.timeout(this.configManager.get('downloadTimeout')),
114
122
  });
115
- if (!response.ok) {
116
- throw new Error(`Version check failed: ${response.status}`);
123
+ const latest = {
124
+ available: data.available,
125
+ version: data.version,
126
+ url: data.downloadUrl,
127
+ mandatory: data.mandatory,
128
+ notes: (_a = data.releaseNotes) !== null && _a !== void 0 ? _a : undefined,
129
+ size: data.size,
130
+ checksum: data.checksum,
131
+ };
132
+ // No update is a normal, non-error outcome — return it as-is.
133
+ if (!latest.available) {
134
+ return latest;
117
135
  }
118
- const data = await response.json();
119
- // Validate response
120
- if (!data.version) {
136
+ // Validate the actionable fields before we cache/return them.
137
+ if (!latest.version) {
121
138
  throw new ValidationError(ErrorCode.INVALID_BUNDLE_FORMAT, 'No version in server response');
122
139
  }
123
- this.securityValidator.validateVersion(data.version);
124
- // Additional validation
125
- if (data.bundleUrl) {
126
- this.securityValidator.validateUrl(data.bundleUrl);
140
+ this.securityValidator.validateVersion(latest.version);
141
+ if (latest.url) {
142
+ this.securityValidator.validateUrl(latest.url);
127
143
  }
128
- if (data.minAppVersion) {
129
- this.securityValidator.validateVersion(data.minAppVersion);
144
+ if (data.minNativeVersion) {
145
+ this.securityValidator.validateVersion(data.minNativeVersion);
130
146
  }
131
147
  // Cache the result
132
- await this.cacheVersionInfo(cacheKey, channel, data);
148
+ await this.cacheVersionInfo(cacheKey, channel, latest);
133
149
  this.logger.info('Version check completed', {
134
150
  channel,
135
151
  currentVersion,
136
- latestVersion: data.version,
137
- updateAvailable: this.isNewerVersion(data.version, currentVersion),
152
+ latestVersion: latest.version,
153
+ updateAvailable: this.isNewerVersion(latest.version, currentVersion),
138
154
  });
139
- return data;
155
+ return latest;
140
156
  }
141
157
  catch (error) {
142
158
  this.logger.error('Failed to check for updates', error);
@@ -2,6 +2,7 @@ import { registerPlugin } from '@capacitor/core';
2
2
  import { SyncStatus, BundleStatus, UpdateErrorCode } from './definitions';
3
3
  import { PluginManager } from './core/plugin-manager';
4
4
  import { NativeUpdateError, ErrorCode } from './core/errors';
5
+ import { checkForUpdate } from './core/update-check';
5
6
  /**
6
7
  * Web implementation of the Native Update Plugin
7
8
  */
@@ -275,6 +276,7 @@ class NativeUpdatePluginWeb {
275
276
  * Check for available updates (convenience wrapper around getLatest + current version)
276
277
  */
277
278
  async checkForUpdate() {
279
+ var _a, _b;
278
280
  const bundleManager = this.pluginManager.getBundleManager();
279
281
  const configManager = this.pluginManager.getConfigManager();
280
282
  try {
@@ -297,25 +299,17 @@ class NativeUpdatePluginWeb {
297
299
  }
298
300
  const channel = configManager.get('channel') || 'production';
299
301
  const deviceInfo = this.getDeviceInfo(currentVersion);
300
- const url = `${baseUrl.replace(/\/$/, '')}/v1/updates/check?channel=${encodeURIComponent(channel)}`;
301
- const response = await fetch(url, {
302
- method: 'GET',
303
- headers: {
304
- 'Content-Type': 'application/json',
305
- 'X-API-Key': apiKey,
306
- 'X-Device-ID': deviceInfo.deviceId,
307
- 'X-Current-Version': currentVersion,
308
- 'X-Platform': deviceInfo.platform,
309
- 'X-App-Version': deviceInfo.appVersion,
310
- },
302
+ // Delegate the wire contract to the shared helper so plugin.ts,
303
+ // version-manager, and background-scheduler all hit the same
304
+ // /v1/updates/check endpoint with identical headers.
305
+ const data = await checkForUpdate(baseUrl, {
306
+ apiKey,
307
+ channel,
308
+ currentVersion,
309
+ deviceId: deviceInfo.deviceId,
310
+ platform: deviceInfo.platform,
311
+ appVersion: deviceInfo.appVersion,
311
312
  });
312
- if (!response.ok) {
313
- return {
314
- available: false,
315
- currentVersion,
316
- };
317
- }
318
- const data = await response.json();
319
313
  if (!data.available) {
320
314
  return {
321
315
  available: false,
@@ -328,10 +322,10 @@ class NativeUpdatePluginWeb {
328
322
  latestVersion: data.version,
329
323
  url: data.downloadUrl,
330
324
  mandatory: data.mandatory,
331
- notes: data.releaseNotes,
325
+ notes: (_a = data.releaseNotes) !== null && _a !== void 0 ? _a : undefined,
332
326
  size: data.size,
333
327
  checksum: data.checksum,
334
- signature: data.signature,
328
+ signature: (_b = data.signature) !== null && _b !== void 0 ? _b : undefined,
335
329
  };
336
330
  }
337
331
  catch (error) {
@@ -59,9 +59,15 @@ export interface DeviceInfo {
59
59
  locale: string;
60
60
  }
61
61
  /**
62
- * Normalized response from `GET /v1/updates/check`. The Laravel
63
- * backend returns this exact shape (snake_case fields are mapped on
64
- * the wire — this interface is the camelCase local form).
62
+ * Extended, delta-aware LOCAL model of an update check, used by the
63
+ * delta-update pipeline (`delta-processor.ts`).
64
+ *
65
+ * NOTE: this is NOT the raw wire shape. The backend `GET /v1/updates/check`
66
+ * returns `available` / `downloadUrl` / `releaseNotes` (see
67
+ * {@link BackendUpdateCheckResponse} in `core/update-check.ts`), whereas
68
+ * this interface uses `updateAvailable` / `bundleUrl` and adds the
69
+ * client-computed `delta` / `rolloutEligible` fields. Map from the wire
70
+ * response into this shape when driving a delta update.
65
71
  */
66
72
  export interface UpdateCheckResponse {
67
73
  updateAvailable: boolean;