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