@hot-updater/apple-helper 1.2.0-rc.2 → 1.2.0-rc.21

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/dist/index.d.mts CHANGED
@@ -6,13 +6,13 @@ import { NativeBuildIosScheme } from "@hot-updater/plugin-core";
6
6
  declare const ASC_INTEGRATIONS_URL = "https://appstoreconnect.apple.com/access/integrations/api";
7
7
  /** A team API key's role, as App Store Connect names it. */
8
8
  type AscApiKeyRole = "ADMIN" | "APP_MANAGER" | "DEVELOPER";
9
- /** The App Store Connect team an Apple Account signed in to. */
9
+ /** An App Store Connect team an Apple Account is in. */
10
10
  interface AscTeam {
11
11
  readonly appleId?: string;
12
12
  /** The team ID to pass as `teamId` to issue the key in this team. */
13
13
  readonly teamId?: string;
14
- /** The Apple Developer team ID, as Xcode's DEVELOPMENT_TEAM names it. */
15
- readonly developerTeamId?: string;
14
+ /** The team's name, as App Store Connect shows it. */
15
+ readonly name?: string;
16
16
  }
17
17
  interface IssueAscApiKeyRequest {
18
18
  /** The key's name in App Store Connect. */
@@ -23,15 +23,16 @@ interface IssueAscApiKeyRequest {
23
23
  /** The team to issue the key in; else the one the sign-in lands in. */
24
24
  readonly teamId?: string;
25
25
  /**
26
- * Sees the team the sign-in landed in, when `teamId` is unset, and
27
- * returns another team's ID to issue the key there instead.
26
+ * Sees the teams the Apple Account is in and the one the sign-in landed
27
+ * in, when `teamId` is unset, and returns another team's ID to issue the
28
+ * key there instead.
28
29
  */
29
- readonly chooseTeam?: (team: AscTeam) => Promise<string | undefined>;
30
+ readonly chooseTeam?: (teams: readonly AscTeam[], current: AscTeam) => Promise<string | undefined>;
30
31
  }
31
32
  /**
32
33
  * An App Store Connect team API key, just issued, with its one-time private
33
- * key and the signed-in session it was issued in. `dispose` ends that
34
- * session and deletes everything the sign-in kept; `revoke` works until then.
34
+ * key and the signed-in session it was issued in, which lives only in
35
+ * memory. `dispose` drops that session; `revoke` works until then.
35
36
  */
36
37
  interface IssuedAscApiKey {
37
38
  /** The `.p8` private key, a PEM. */
@@ -53,8 +54,8 @@ interface IssuedAscApiKey {
53
54
  */
54
55
  type IssueAscApiKey = (request: IssueAscApiKeyRequest) => Promise<IssuedAscApiKey>;
55
56
  /**
56
- * Hot Updater's sign-in, the one place that picks how it is done: asc, the
57
- * open-source App Store Connect CLI. Another implementation of
57
+ * Hot Updater's sign-in, the one place that picks how it is done: App Store
58
+ * Connect's own web sign-in, with no other tool. Another implementation of
58
59
  * `IssueAscApiKey` replaces it here without touching its callers.
59
60
  */
60
61
  declare const issueAscApiKey: IssueAscApiKey;
@@ -71,36 +72,6 @@ declare const enrichNativeBuildIosScheme: ({ scheme, hotUpdaterSchemeName }: {
71
72
  hotUpdaterSchemeName: string;
72
73
  }) => Promise<EnrichedNativeBuildIosScheme>;
73
74
  //#endregion
74
- //#region src/buildIos.d.ts
75
- /**
76
- * Builds a simulator `.app` for a `simulator` scheme, and otherwise archives
77
- * and exports an `.ipa`, or returns the `.xcarchive` of a scheme it cannot
78
- * export: one with neither `exportOptionsPlist` nor `signing.ascApiKey`.
79
- *
80
- * The artifact is in a temporary `buildDirectory`, which `dispose` removes
81
- * once the caller has copied it out. A failed build removes it, and every
82
- * other directory the build used, itself.
83
- */
84
- declare const buildIos: ({ schemeConfig, minBundleId, credentials }: {
85
- schemeConfig: EnrichedNativeBuildIosScheme;
86
- /** The MIN_BUNDLE_ID the build compiles in. */
87
- minBundleId?: string;
88
- /** Resolves the scheme's `signing` key, when a device build signs with one. */
89
- credentials?: Pick<CredentialResolver, "resolve">;
90
- }) => Promise<{
91
- buildDirectory: string;
92
- buildArtifactPath: string;
93
- /** What the built app reports, from its Info.plist. */
94
- builtApp?: {
95
- appVersion: string | null;
96
- channel: string | null;
97
- /** The app's `CFBundleVersion`. */
98
- buildNumber: string | null;
99
- };
100
- /** Removes `buildDirectory`, once the artifact is copied out of it. */
101
- dispose: () => Promise<void>;
102
- }>;
103
- //#endregion
104
75
  //#region src/uploadToTestFlight.d.ts
105
76
  type AppStoreConnectApiKey = Credentials["asc-api-key"];
106
77
  /**
@@ -186,12 +157,309 @@ declare const uploadToTestFlight: ({ ipaPath, apiKey, fetch, pollIntervalMs, pro
186
157
  processingTimeoutMs?: number;
187
158
  }) => Promise<UploadToTestFlightResult>;
188
159
  //#endregion
160
+ //#region src/asc/devices.d.ts
161
+ /** A device an Apple account has registered. */
162
+ interface AscDevice {
163
+ readonly id: string;
164
+ readonly name: string;
165
+ readonly udid: string;
166
+ /** `ENABLED`, or `DISABLED`, which no new profile includes. */
167
+ readonly status: string;
168
+ /** `IPHONE`, `IPAD`, and so on. */
169
+ readonly deviceClass: string | null;
170
+ }
171
+ /** Every iPhone and iPad the Apple account has registered. */
172
+ declare const listAscDevices: ({ apiKey, fetch }: {
173
+ apiKey: AppStoreConnectApiKey;
174
+ fetch?: typeof globalThis.fetch;
175
+ }) => Promise<AscDevice[]>;
176
+ /** What adding one device came to. */
177
+ type AscDeviceOutcome = {
178
+ readonly udid: string;
179
+ readonly outcome: "registered" | "already-registered" | "disabled";
180
+ readonly device: AscDevice;
181
+ } | {
182
+ readonly udid: string;
183
+ readonly outcome: "refused";
184
+ /** Apple's own words. */
185
+ readonly reason: string;
186
+ /** Whether the refusal is the account's yearly limit of devices. */
187
+ readonly limitReached: boolean;
188
+ };
189
+ /**
190
+ * Registers devices with the Apple account, each at most once: a device that
191
+ * is already there succeeds and changes nothing, so running it again is safe,
192
+ * and so is a race with another run, which App Store Connect answers with 409.
193
+ * A disabled device stays disabled, since its slot is already spent and someone
194
+ * chose to disable it. It only registers: Xcode adds a registered device to the
195
+ * profile at the next export, so an `.ipa` signed before never gains it.
196
+ */
197
+ declare const addAscDevices: ({ devices, apiKey, fetch }: {
198
+ devices: readonly {
199
+ readonly udid: string;
200
+ readonly name: string;
201
+ }[];
202
+ apiKey: AppStoreConnectApiKey;
203
+ fetch?: typeof globalThis.fetch;
204
+ }) => Promise<AscDeviceOutcome[]>;
205
+ //#endregion
206
+ //#region src/sandboxTestFlight.d.ts
207
+ /** What a sandbox build must fit in App Store Connect. */
208
+ interface AppStoreTrain {
209
+ /**
210
+ * The highest version Apple approved, such as `1.6.2`, or null with none.
211
+ * Apple takes builds only of a version higher than this: anything else
212
+ * fails after the whole upload, with 90186 and 90062.
213
+ */
214
+ readonly highestClosedVersion: string | null;
215
+ /** The highest integer build number of the app's builds, or null. */
216
+ readonly highestBuildNumber: number | null;
217
+ }
218
+ /** What an archive of a sandbox scheme takes from App Store Connect. */
219
+ interface SandboxArchivePlan {
220
+ /** Read before the build, or undefined when it can't reach the store. */
221
+ readonly train?: AppStoreTrain;
222
+ /** Which version an update targets: a closed train raises only under fingerprint. */
223
+ readonly updateStrategy: "fingerprint" | "appVersion";
224
+ }
225
+ /**
226
+ * What a sandbox device build needs from App Store Connect, read before the
227
+ * build. An export for elsewhere has no train, and without an API key it
228
+ * can't be read: the store would say so after the upload. What a closed train
229
+ * does to the build waits for the archive (`patchSandboxArchive`): only the
230
+ * archived app holds the version an `xcconfig` or `extraParams` settled on,
231
+ * which the project's files don't.
232
+ */
233
+ declare const prepareSandboxArchive: ({ schemeConfig, apiKey, updateStrategy, fetch }: {
234
+ schemeConfig: EnrichedNativeBuildIosScheme;
235
+ apiKey?: AppStoreConnectApiKey;
236
+ updateStrategy: "fingerprint" | "appVersion";
237
+ fetch?: typeof globalThis.fetch;
238
+ }) => Promise<SandboxArchivePlan>;
239
+ /** Whether Apple refuses a build of `version`, as `train` says. */
240
+ declare const isVersionTrainClosed: (version: string, { highestClosedVersion }: AppStoreTrain) => boolean;
241
+ /**
242
+ * Refuses, before the upload, a sandbox `.ipa` Xcode didn't mark for internal
243
+ * testing only: App Store Connect would let it reach App Store review.
244
+ */
245
+ declare const assertIpaIsInternalOnly: (ipaPath: string) => Promise<void>;
246
+ /**
247
+ * What a tester can do with a build: `processing` until App Store Connect has
248
+ * processed it, `missing-compliance` until someone answers export compliance,
249
+ * and `ready` once it installs. `failed` and `expired` never install.
250
+ */
251
+ type TestFlightBuildState = "processing" | "ready" | "missing-compliance" | "failed" | "expired";
252
+ /** A build App Store Connect lists, as one read of `/v1/builds` says. */
253
+ interface TestFlightBuildStatus {
254
+ readonly buildId: string;
255
+ /** The audience App Store Connect holds it for, or null until it says. */
256
+ readonly audience: string | null;
257
+ readonly state: TestFlightBuildState;
258
+ /**
259
+ * Set when a `missing-compliance` build has its answer and Apple is reviewing
260
+ * it, so nobody needs to answer it again.
261
+ */
262
+ readonly inExportComplianceReview?: boolean;
263
+ /** When TestFlight stops offering it, or null until it says. */
264
+ readonly expiresAtMs: number | null;
265
+ }
266
+ /**
267
+ * Fails unless App Store Connect holds the uploaded sandbox build for internal
268
+ * testing only, as `buildAudienceType` says once the build is listed, and
269
+ * returns what that read says of it.
270
+ */
271
+ declare const assertBuildIsInternalOnly: ({ ipaPath, apiKey, fetch, pollIntervalMs, timeoutMs }: {
272
+ ipaPath: string;
273
+ apiKey: AppStoreConnectApiKey;
274
+ fetch?: typeof globalThis.fetch;
275
+ pollIntervalMs?: number;
276
+ timeoutMs?: number;
277
+ }) => Promise<TestFlightBuildStatus & {
278
+ appId: string;
279
+ testFlightUrl: string;
280
+ }>;
281
+ /** An internal TestFlight group of an app. */
282
+ interface InternalBetaGroup {
283
+ readonly id: string;
284
+ readonly name: string;
285
+ /** A group that takes every build needs no build added to it. */
286
+ readonly hasAccessToAllBuilds: boolean;
287
+ }
288
+ /**
289
+ * The internal TestFlight group named `name`, read before anything is built.
290
+ * An external group is refused: its builds go to Beta App Review, and a sandbox
291
+ * build is for internal testing only.
292
+ */
293
+ declare const findInternalBetaGroup: ({ bundleId, name, apiKey, fetch }: {
294
+ bundleId: string;
295
+ name: string;
296
+ apiKey: AppStoreConnectApiKey;
297
+ fetch?: typeof globalThis.fetch;
298
+ }) => Promise<InternalBetaGroup>;
299
+ /**
300
+ * Adds a processed build to its internal group and sets its What to Test, which
301
+ * App Store Connect takes once the build is processed. A build still processing
302
+ * after `timeoutMs` keeps its upload: a warning says what to do by hand. Returns
303
+ * the build's state.
304
+ */
305
+ declare const distributeTestFlightBuild: ({ build: { appId, shortVersion, bundleVersion, testFlightUrl }, group, whatToTest, apiKey, fetch, pollIntervalMs, timeoutMs }: {
306
+ build: {
307
+ appId: string;
308
+ shortVersion: string;
309
+ bundleVersion: string;
310
+ testFlightUrl: string;
311
+ };
312
+ group?: InternalBetaGroup;
313
+ whatToTest?: string;
314
+ apiKey: AppStoreConnectApiKey;
315
+ fetch?: typeof globalThis.fetch;
316
+ pollIntervalMs?: number;
317
+ timeoutMs?: number;
318
+ }) => Promise<TestFlightBuildStatus | null>;
319
+ /**
320
+ * What became of a group for a build on TestFlight: `added`, in a group that
321
+ * `takes-every-build` without being asked, `pending` while the build processes,
322
+ * and `not-offered` for a build no tester could get.
323
+ */
324
+ type TestFlightGroupOutcome = "added" | "takes-every-build" | "pending" | "not-offered";
325
+ /**
326
+ * Applies an internal group to a build already on TestFlight, as an upload does,
327
+ * so a reused build reaches the group named now. One process reads the app, the
328
+ * build and the group once each. Reading a build's `betaGroups` relationship
329
+ * answered 403 when we tried it, so this doesn't check membership first: every
330
+ * run adds the build. A build not `isOffered` gets nothing: it needs a new
331
+ * build, which checks the group itself. A build still processing waits as an
332
+ * upload's does, and the next run applies the group again.
333
+ */
334
+ declare const applyTestFlightGroup: ({ bundleId, shortVersion, bundleVersion, name, isOffered, apiKey, fetch, pollIntervalMs, timeoutMs }: {
335
+ bundleId: string;
336
+ shortVersion: string;
337
+ bundleVersion: string;
338
+ name: string;
339
+ /** Whether a tester can still get the build, as its status says. */
340
+ isOffered: (status: TestFlightBuildStatus | null) => boolean;
341
+ apiKey: AppStoreConnectApiKey;
342
+ fetch?: typeof globalThis.fetch;
343
+ pollIntervalMs?: number;
344
+ timeoutMs?: number;
345
+ }) => Promise<{
346
+ testFlightUrl: string;
347
+ status: TestFlightBuildStatus | null;
348
+ outcome: TestFlightGroupOutcome;
349
+ }>;
350
+ /**
351
+ * What App Store Connect says of a build a run recorded as uploaded, which a
352
+ * later run reuses: its page, and its state and expiry, or a null status when
353
+ * it no longer lists the build.
354
+ */
355
+ declare const readTestFlightBuildStatus: ({ bundleId, shortVersion, bundleVersion, apiKey, fetch }: {
356
+ bundleId: string;
357
+ shortVersion: string | null;
358
+ bundleVersion: string;
359
+ apiKey: AppStoreConnectApiKey;
360
+ fetch?: typeof globalThis.fetch;
361
+ }) => Promise<{
362
+ testFlightUrl: string;
363
+ status: TestFlightBuildStatus | null;
364
+ }>;
365
+ //#endregion
366
+ //#region src/buildIos.d.ts
367
+ /**
368
+ * Builds a simulator `.app` for a `simulator` scheme, and otherwise archives
369
+ * and exports an `.ipa`, or returns the `.xcarchive` of a scheme it cannot
370
+ * export: one with neither `exportOptionsPlist` nor `signing.ascApiKey`.
371
+ *
372
+ * The artifact is in a temporary `buildDirectory`, which `dispose` removes
373
+ * once the caller has copied it out. A failed build removes it, and every
374
+ * other directory the build used, itself.
375
+ */
376
+ declare const buildIos: ({ schemeConfig, minBundleId, credentials, sandbox, logHeader }: {
377
+ schemeConfig: EnrichedNativeBuildIosScheme;
378
+ /** The MIN_BUNDLE_ID the build compiles in. */
379
+ minBundleId?: string;
380
+ /** Resolves the scheme's `signing` key, when a device build signs with one. */
381
+ credentials?: Pick<CredentialResolver, "resolve">;
382
+ /**
383
+ * What a `sandbox` scheme's archive takes from App Store Connect: its
384
+ * closed version train and next build number, and what a closed train does.
385
+ */
386
+ sandbox?: SandboxArchivePlan;
387
+ /** Lines the build log starts with, such as the native build key. */
388
+ logHeader?: string[];
389
+ }) => Promise<{
390
+ buildDirectory: string;
391
+ buildArtifactPath: string;
392
+ /** The build log, which an archive's export appends to, or null. */
393
+ logFilePath: string | null;
394
+ /** What the built app reports, from its Info.plist. */
395
+ builtApp?: {
396
+ appVersion: string | null;
397
+ channel: string | null;
398
+ /** The app's `CFBundleVersion`. */
399
+ buildNumber: string | null;
400
+ };
401
+ /** Removes `buildDirectory`, once the artifact is copied out of it. */
402
+ dispose: () => Promise<void>;
403
+ }>;
404
+ //#endregion
405
+ //#region src/simulator.d.ts
406
+ interface Simulator {
407
+ readonly udid: string;
408
+ readonly name: string;
409
+ /** `Booted`, `Shutdown`, and the states between them, as `simctl` says. */
410
+ readonly state: string;
411
+ }
412
+ /** Every simulator on this Mac, booted or not. */
413
+ declare const listSimulators: () => Promise<readonly Simulator[]>;
414
+ /**
415
+ * The simulator to install on: `udid`, or else the only booted one, by its
416
+ * UDID. `simctl`'s own `booted` alias picks one of several by itself.
417
+ */
418
+ declare const selectSimulator: (simulators: readonly Simulator[], udid?: string) => Simulator;
419
+ /**
420
+ * Unpacks a simulator build's `.app.zip` into `outputPath`, and returns the
421
+ * `.app` in it.
422
+ */
423
+ declare const extractSimulatorApp: ({ archivePath, outputPath }: {
424
+ readonly archivePath: string;
425
+ readonly outputPath: string;
426
+ }) => Promise<string>;
427
+ /** Installs a `.app` on a booted simulator, and opens it. */
428
+ declare const installOnSimulator: ({ udid, appPath, appId }: {
429
+ readonly udid: string;
430
+ readonly appPath: string;
431
+ /** The app's `CFBundleIdentifier`. */
432
+ readonly appId: string;
433
+ }) => Promise<void>;
434
+ //#endregion
189
435
  //#region src/types.d.ts
190
436
  /** Whether a build is for a physical device or a simulator. */
191
437
  type AppleDeviceType = "device" | "simulator";
192
438
  //#endregion
193
439
  //#region src/utils/cocoapods.d.ts
194
- declare const installPodsIfNeeded: (sourceDir: string) => Promise<void>;
440
+ /** What `installPodsIfNeeded` ran. */
441
+ interface PodInstallSteps {
442
+ /** React Native codegen, before `pod install`. */
443
+ readonly codegen: boolean;
444
+ /** `pod install`, which a project without a Podfile skips. */
445
+ readonly pods: boolean;
446
+ }
447
+ declare const installPodsIfNeeded: (sourceDir: string) => Promise<PodInstallSteps>;
448
+ //#endregion
449
+ //#region src/utils/readIpaInfo.d.ts
450
+ /**
451
+ * Whether an `.ipa`'s app answers export compliance in its Info.plist. Either
452
+ * value is an answer, so this asks only whether the key is there.
453
+ */
454
+ declare const readIpaHasExportComplianceKey: (ipaPath: string) => Promise<boolean>;
455
+ //#endregion
456
+ //#region src/utils/xcodeSigning.d.ts
457
+ /**
458
+ * Refuses a sandbox scheme's App Store Connect export that turns internal
459
+ * testing off: Apple keeps a build out of review only with it on. Another
460
+ * method's `.ipa` never reaches App Store Connect.
461
+ */
462
+ declare const assertSandboxExportOptions: (schemeName: string, exportOptionsPlist: string) => Promise<void>;
195
463
  //#endregion
196
464
  //#region src/utils/extractBuiltInBundle.d.ts
197
465
  /**
@@ -220,4 +488,4 @@ declare const archiveAppBundle: ({ appPath, outputPath }: {
220
488
  outputPath: string;
221
489
  }) => Promise<void>;
222
490
  //#endregion
223
- export { ASC_INTEGRATIONS_URL, type AppleDeviceType, type AscApiKeyRole, type AscTeam, type EnrichedNativeBuildIosScheme, type IssueAscApiKey, type IssueAscApiKeyRequest, type IssuedAscApiKey, TestFlightBuildExistsError, type UploadToTestFlightResult, archiveAppBundle, assertTestFlightExportOptions, buildIos, enrichNativeBuildIosScheme, extractAppBundle, extractBuiltInBundle, findTestFlightBuild, installPodsIfNeeded, issueAscApiKey, resolveTestFlightUploadKey, uploadToTestFlight };
491
+ export { ASC_INTEGRATIONS_URL, type AppleDeviceType, type AscApiKeyRole, type AscDevice, type AscDeviceOutcome, type AscTeam, type EnrichedNativeBuildIosScheme, type InternalBetaGroup, type IssueAscApiKey, type IssueAscApiKeyRequest, type IssuedAscApiKey, type SandboxArchivePlan, type Simulator, TestFlightBuildExistsError, type TestFlightBuildState, type TestFlightBuildStatus, type TestFlightGroupOutcome, type UploadToTestFlightResult, addAscDevices, applyTestFlightGroup, archiveAppBundle, assertBuildIsInternalOnly, assertIpaIsInternalOnly, assertSandboxExportOptions, assertTestFlightExportOptions, buildIos, distributeTestFlightBuild, enrichNativeBuildIosScheme, extractAppBundle, extractBuiltInBundle, extractSimulatorApp, findInternalBetaGroup, findTestFlightBuild, installOnSimulator, installPodsIfNeeded, isVersionTrainClosed, issueAscApiKey, listAscDevices, listSimulators, prepareSandboxArchive, readIpaHasExportComplianceKey, readTestFlightBuildStatus, resolveTestFlightUploadKey, selectSimulator, uploadToTestFlight };