@hot-updater/android-helper 1.2.0-rc.2 → 1.2.0-rc.20

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
@@ -4,7 +4,7 @@ import { NativeBuildAndroidScheme } from "@hot-updater/plugin-core";
4
4
  /**
5
5
  * Validated scheme filled nullish values with default values.
6
6
  */
7
- type EnrichedNativeBuildAndroidScheme = Required<Omit<NativeBuildAndroidScheme, "signing">> & Pick<NativeBuildAndroidScheme, "signing"> & {
7
+ type EnrichedNativeBuildAndroidScheme = Required<Omit<NativeBuildAndroidScheme, "signing" | "sandbox">> & Pick<NativeBuildAndroidScheme, "signing" | "sandbox"> & {
8
8
  hotUpdaterSchemeName: string;
9
9
  };
10
10
  declare const enrichNativeBuildAndroidScheme: ({ schemeConfig, hotUpdaterSchemeName }: {
@@ -13,15 +13,21 @@ declare const enrichNativeBuildAndroidScheme: ({ schemeConfig, hotUpdaterSchemeN
13
13
  }) => Promise<EnrichedNativeBuildAndroidScheme>;
14
14
  //#endregion
15
15
  //#region src/buildAndroid.d.ts
16
- declare const buildAndroid: ({ schemeConfig, minBundleId, credentials }: {
16
+ declare const buildAndroid: ({ schemeConfig, minBundleId, credentials, logHeader, minVersionCode }: {
17
17
  schemeConfig: EnrichedNativeBuildAndroidScheme;
18
18
  /** The MIN_BUNDLE_ID the build compiles in. */
19
19
  minBundleId?: string;
20
20
  /** Resolves the scheme's `signing` keystore, when it signs with one. */
21
21
  credentials?: Pick<CredentialResolver, "resolve">;
22
+ /** Lines the build log starts with, such as the native build key. */
23
+ logHeader?: string[];
24
+ /** The lowest version code a sandbox build may have. */
25
+ minVersionCode?: number;
22
26
  }) => Promise<{
23
27
  buildDirectory: string;
24
28
  buildArtifactPath: string;
29
+ /** The build log, or null without one. */
30
+ logFilePath: string | null;
25
31
  /** What the built artifact reports, or undefined without aapt2. */
26
32
  builtApp?: {
27
33
  appVersion: string | null;
@@ -32,6 +38,29 @@ declare const buildAndroid: ({ schemeConfig, minBundleId, credentials }: {
32
38
  };
33
39
  }>;
34
40
  //#endregion
41
+ //#region src/device.d.ts
42
+ interface AdbDevice {
43
+ readonly serial: string;
44
+ /** `device` when it takes commands; else `offline`, `unauthorized`, and so on. */
45
+ readonly state: string;
46
+ }
47
+ /** What `adb devices` lists. */
48
+ declare const listAdbDevices: () => Promise<readonly AdbDevice[]>;
49
+ /**
50
+ * The device to install on: `serial`, as adb's own `ANDROID_SERIAL` names it
51
+ * too, or else the only one that takes commands.
52
+ */
53
+ declare const selectAdbDevice: (devices: readonly AdbDevice[], serial?: string | undefined) => AdbDevice;
54
+ /**
55
+ * Installs an APK on a device, and opens its launcher activity. `appId` is
56
+ * the APK's own application ID, whatever suffix its build gave it.
57
+ */
58
+ declare const installOnAndroidDevice: ({ serial, apkPath, appId }: {
59
+ readonly serial: string;
60
+ readonly apkPath: string;
61
+ readonly appId: string;
62
+ }) => Promise<void>;
63
+ //#endregion
35
64
  //#region src/uploadToPlay.d.ts
36
65
  /**
37
66
  * Google Play refused the upload: it already has a bundle or APK with the
@@ -42,18 +71,81 @@ declare class PlayVersionCodeUsedError extends Error {
42
71
  readonly name = "PlayVersionCodeUsedError";
43
72
  constructor(options?: ErrorOptions);
44
73
  }
74
+ /**
75
+ * Play Console's page that invites `email` as a user. `_` stands for the
76
+ * developer account the browser is signed in to, so no ID is needed.
77
+ */
78
+ declare const playConsoleInviteUrl: (email: string) => string;
79
+ /**
80
+ * Whether a service account reaches an app in Google Play:
81
+ * - `ready`: it opened an edit of the app;
82
+ * - `denied`: Google Play refused it (401/403), so it needs a Play Console
83
+ * invite;
84
+ * - `not-found`: Google Play has no such app it can see (404), as before
85
+ * the app's first `.aab` is uploaded in Play Console;
86
+ * - `refused`: Google's token endpoint refused the key itself, such as a
87
+ * deleted key, with Google's reason.
88
+ */
89
+ type PlayAccess = {
90
+ readonly status: "ready";
91
+ } | {
92
+ readonly status: "denied";
93
+ readonly email: string;
94
+ } | {
95
+ readonly status: "not-found";
96
+ readonly email: string;
97
+ } | {
98
+ readonly status: "refused";
99
+ readonly email: string;
100
+ readonly reason: string;
101
+ };
102
+ /**
103
+ * Checks once whether the service account's key reaches `packageName`: it
104
+ * opens an edit of the app and deletes it again, which changes nothing.
105
+ * Throws only for what says nothing about access, such as a network error.
106
+ */
107
+ declare const checkPlayAccess: ({ serviceAccount: { json }, packageName, fetch }: {
108
+ serviceAccount: Credentials["play-service-account"];
109
+ packageName: string;
110
+ fetch?: typeof globalThis.fetch;
111
+ }) => Promise<PlayAccess>;
112
+ /**
113
+ * The status of the internal testing release holding `versionCode`, such as
114
+ * `completed` or `draft`, or null when the track doesn't hold it: never
115
+ * uploaded, or replaced by a newer release, which testers get instead.
116
+ */
117
+ declare const readPlayInternalRelease: ({ versionCode, packageName, serviceAccount, fetch }: {
118
+ versionCode: number;
119
+ /** The application ID the `.aab` was built with. */
120
+ packageName: string;
121
+ serviceAccount: Credentials["play-service-account"];
122
+ fetch?: typeof globalThis.fetch;
123
+ }) => Promise<string | null>;
45
124
  /**
46
125
  * Whether Google Play's internal testing track already releases the
47
- * `.aab`'s version code, as when a reused native build was uploaded
48
- * before. It reads the track in an edit it then deletes, changing nothing.
126
+ * `.aab`'s version code, as when a reused native build was uploaded before.
49
127
  */
50
- declare const findPlayInternalRelease: ({ versionCode, packageName, serviceAccount: { json }, fetch }: {
128
+ declare const findPlayInternalRelease: (options: {
51
129
  versionCode: number;
52
130
  /** The application ID the `.aab` was built with. */
53
131
  packageName: string;
54
132
  serviceAccount: Credentials["play-service-account"];
55
133
  fetch?: typeof globalThis.fetch;
56
134
  }) => Promise<boolean>;
135
+ /**
136
+ * The highest version code Google Play has taken for the app, on any track,
137
+ * or null with none: a new `.aab` needs one above it.
138
+ */
139
+ declare const readPlayHighestVersionCode: ({ packageName, serviceAccount, fetch }: {
140
+ packageName: string;
141
+ serviceAccount: Credentials["play-service-account"];
142
+ fetch?: typeof globalThis.fetch;
143
+ }) => Promise<number | null>;
144
+ /**
145
+ * The link that opts a tester in to the app's testing tracks. A build on the
146
+ * internal track installs through it, for the testers Play Console lists.
147
+ */
148
+ declare const playTestingUrl: (packageName: string) => string;
57
149
  /**
58
150
  * Throws when the `.aab` is signed with the Android debug keystore, which
59
151
  * Google Play refuses: a release build type left on `signingConfigs.debug`,
@@ -108,6 +200,17 @@ declare const extractBuiltInBundle: ({ artifactPath, outputPath }: {
108
200
  outputPath: string;
109
201
  }) => Promise<void>;
110
202
  //#endregion
203
+ //#region src/utils/sandboxGradle.d.ts
204
+ /**
205
+ * Why a sandbox build of a scheme can't work, read from the project's files
206
+ * before anything is built, or null. The init script checks again, with what
207
+ * Gradle actually resolved.
208
+ */
209
+ declare const findSandboxGradleBlocker: ({ variant, appModuleName }: {
210
+ readonly variant?: string;
211
+ readonly appModuleName?: string;
212
+ }) => string | null;
213
+ //#endregion
111
214
  //#region src/utils/readBuiltApp.d.ts
112
215
  /**
113
216
  * What the built `.apk` or `.aab` reports at runtime: the `versionName` and
@@ -143,117 +246,4 @@ declare const readBuiltVersionCode: ({ artifactPath, androidProjectPath }: {
143
246
  androidProjectPath: string;
144
247
  }) => Promise<number | undefined>;
145
248
  //#endregion
146
- //#region src/google/types.d.ts
147
- /** What stopped Hot Updater from issuing the Play service account key. */
148
- type PlayServiceAccountErrorCode =
149
- /** No OAuth client to sign in with, or Google refused it. */
150
- "sign-in-not-configured" |
151
- /** The browser sign-in was cancelled, refused, or timed out. */
152
- "sign-in-cancelled" |
153
- /** The account unticked a scope the setup needs on Google's consent screen. */
154
- "scope-not-granted" |
155
- /** The developer account ID names no Play Console account. */
156
- "developer-not-found" |
157
- /** The Google Account is no admin of the Play Console developer account. */
158
- "not-play-admin" |
159
- /** Google Play has no app with the package name in the developer account. */
160
- "app-not-found" |
161
- /** The Google Account may not create a Google Cloud project. */
162
- "project-create-denied" |
163
- /** The Google Account has no Google Cloud project quota left. */
164
- "project-quota" |
165
- /** The Google Account may not enable APIs or create service accounts in the project. */
166
- "project-access-denied" |
167
- /** Google is still enabling an API, or it is disabled in the OAuth client's project. */
168
- "api-not-enabled" |
169
- /** An organization policy (`iam.disableServiceAccountKeyCreation`) forbids keys. */
170
- "key-creation-disabled";
171
- /** A named failure of `issuePlayServiceAccount`, with what to do in its message. */
172
- declare class PlayServiceAccountError extends Error {
173
- readonly code: PlayServiceAccountErrorCode;
174
- constructor(code: PlayServiceAccountErrorCode, message: string, options?: {
175
- cause?: unknown;
176
- });
177
- }
178
- /**
179
- * A Google OAuth client of type "Desktop app". Google treats an installed
180
- * app's client secret as public, so it ships with the client ID.
181
- */
182
- interface GoogleOAuthClient {
183
- readonly clientId: string;
184
- readonly clientSecret?: string;
185
- }
186
- /** The environment variables that replace Hot Updater's Google OAuth client. */
187
- declare const GOOGLE_OAUTH_CLIENT_ENV_NAMES: {
188
- readonly clientId: "HOT_UPDATER_GOOGLE_OAUTH_CLIENT_ID";
189
- readonly clientSecret: "HOT_UPDATER_GOOGLE_OAUTH_CLIENT_SECRET";
190
- };
191
- /** The service account Hot Updater creates, `hot-updater-play@<project>.iam.gserviceaccount.com`. */
192
- declare const PLAY_SERVICE_ACCOUNT_ID = "hot-updater-play";
193
- /** Where a Play Console admin finds the developer account ID. */
194
- declare const PLAY_CONSOLE_URL = "https://play.google.com/console";
195
- //#endregion
196
- //#region src/playServiceAccount.d.ts
197
- /**
198
- * Hot Updater's Google OAuth client, a "Desktop app" client the sign-in
199
- * opens Google's consent screen for. Empty in a build that has none, where
200
- * `HOT_UPDATER_GOOGLE_OAUTH_CLIENT_ID` and `_SECRET` name one.
201
- */
202
- declare const HOT_UPDATER_GOOGLE_OAUTH_CLIENT: GoogleOAuthClient;
203
- /** A Google Cloud project the signed-in account can use. */
204
- interface GoogleCloudProject {
205
- readonly projectId: string;
206
- readonly displayName?: string;
207
- }
208
- interface IssuePlayServiceAccountRequest {
209
- /** The app's package name in Google Play, which the service account may release. */
210
- readonly packageName: string;
211
- /** The OAuth client to sign in with; Hot Updater's unless set. */
212
- readonly oauthClient?: GoogleOAuthClient;
213
- /** Sees the sign-in URL, to print it and open it in a browser. */
214
- readonly onSignInUrl: (url: string) => Promise<void> | void;
215
- /** Asks for the Play Console developer account ID, after the sign-in. */
216
- readonly askDeveloperId: () => Promise<string>;
217
- /**
218
- * Sees the account's projects when there are any, and returns the one to
219
- * create the service account in, or undefined to create a project.
220
- */
221
- readonly chooseProject: (projects: readonly GoogleCloudProject[]) => Promise<string | undefined>;
222
- /** Reports each step, such as "Creating the service account". */
223
- readonly onStep?: (message: string) => void;
224
- }
225
- /**
226
- * A Play service account's JSON key, just created, with the access token
227
- * of the sign-in it was created in. `revoke` deletes the key while the
228
- * sign-in lasts, and `dispose` ends the sign-in.
229
- */
230
- interface IssuedPlayServiceAccount {
231
- /** The JSON key file, as Google Cloud downloads it. */
232
- readonly json: string;
233
- /** The service account's email, the Play Console user it releases as. */
234
- readonly email: string;
235
- readonly projectId: string;
236
- readonly developerId: string;
237
- /** The key's ID, as Google Cloud lists it under the service account's keys. */
238
- readonly keyId: string;
239
- /** Deletes the key with the same sign-in; whether Google Cloud did. */
240
- revoke(): Promise<boolean>;
241
- /** Ends the sign-in: Google revokes its access token. */
242
- dispose(): Promise<void>;
243
- }
244
- /**
245
- * Signs in with Google and issues a service account key that releases the
246
- * app to Google Play: the developer signs in on Google's own consent
247
- * screen, in a browser, and the caller never sees the password. Nothing of
248
- * the sign-in outlives `dispose`.
249
- */
250
- type IssuePlayServiceAccount = (request: IssuePlayServiceAccountRequest) => Promise<IssuedPlayServiceAccount>;
251
- /**
252
- * Hot Updater's issuer, the one place that picks how it is done: Google's
253
- * OAuth for installed apps, then the Cloud Resource Manager, Service Usage,
254
- * IAM, and Play Developer APIs. Another implementation of
255
- * `IssuePlayServiceAccount` replaces it here without touching its callers.
256
- */
257
- declare const issuePlayServiceAccount: IssuePlayServiceAccount;
258
- //#endregion
259
- export { type EnrichedNativeBuildAndroidScheme, GOOGLE_OAUTH_CLIENT_ENV_NAMES, type GoogleCloudProject, type GoogleOAuthClient, HOT_UPDATER_GOOGLE_OAUTH_CLIENT, type IssuePlayServiceAccount, type IssuePlayServiceAccountRequest, type IssuedPlayServiceAccount, PLAY_CONSOLE_URL, PLAY_SERVICE_ACCOUNT_ID, PlayServiceAccountError, type PlayServiceAccountErrorCode, PlayVersionCodeUsedError, type UploadToPlayResult, assertPlaySigned, buildAndroid, enrichNativeBuildAndroidScheme, extractBuiltInBundle, findPlayInternalRelease, issuePlayServiceAccount, readBuiltApp, readBuiltPackageName, readBuiltVersionCode, resolvePlayUploadServiceAccount, uploadToPlay };
249
+ export { type AdbDevice, type EnrichedNativeBuildAndroidScheme, type PlayAccess, PlayVersionCodeUsedError, type UploadToPlayResult, assertPlaySigned, buildAndroid, checkPlayAccess, enrichNativeBuildAndroidScheme, extractBuiltInBundle, findPlayInternalRelease, findSandboxGradleBlocker, installOnAndroidDevice, listAdbDevices, playConsoleInviteUrl, playTestingUrl, readBuiltApp, readBuiltPackageName, readBuiltVersionCode, readPlayHighestVersionCode, readPlayInternalRelease, resolvePlayUploadServiceAccount, selectAdbDevice, uploadToPlay };
package/dist/index.d.mts CHANGED
@@ -5,7 +5,7 @@ import { NativeBuildAndroidScheme } from "@hot-updater/plugin-core";
5
5
  /**
6
6
  * Validated scheme filled nullish values with default values.
7
7
  */
8
- type EnrichedNativeBuildAndroidScheme = Required<Omit<NativeBuildAndroidScheme, "signing">> & Pick<NativeBuildAndroidScheme, "signing"> & {
8
+ type EnrichedNativeBuildAndroidScheme = Required<Omit<NativeBuildAndroidScheme, "signing" | "sandbox">> & Pick<NativeBuildAndroidScheme, "signing" | "sandbox"> & {
9
9
  hotUpdaterSchemeName: string;
10
10
  };
11
11
  declare const enrichNativeBuildAndroidScheme: ({ schemeConfig, hotUpdaterSchemeName }: {
@@ -14,15 +14,21 @@ declare const enrichNativeBuildAndroidScheme: ({ schemeConfig, hotUpdaterSchemeN
14
14
  }) => Promise<EnrichedNativeBuildAndroidScheme>;
15
15
  //#endregion
16
16
  //#region src/buildAndroid.d.ts
17
- declare const buildAndroid: ({ schemeConfig, minBundleId, credentials }: {
17
+ declare const buildAndroid: ({ schemeConfig, minBundleId, credentials, logHeader, minVersionCode }: {
18
18
  schemeConfig: EnrichedNativeBuildAndroidScheme;
19
19
  /** The MIN_BUNDLE_ID the build compiles in. */
20
20
  minBundleId?: string;
21
21
  /** Resolves the scheme's `signing` keystore, when it signs with one. */
22
22
  credentials?: Pick<CredentialResolver, "resolve">;
23
+ /** Lines the build log starts with, such as the native build key. */
24
+ logHeader?: string[];
25
+ /** The lowest version code a sandbox build may have. */
26
+ minVersionCode?: number;
23
27
  }) => Promise<{
24
28
  buildDirectory: string;
25
29
  buildArtifactPath: string;
30
+ /** The build log, or null without one. */
31
+ logFilePath: string | null;
26
32
  /** What the built artifact reports, or undefined without aapt2. */
27
33
  builtApp?: {
28
34
  appVersion: string | null;
@@ -33,6 +39,29 @@ declare const buildAndroid: ({ schemeConfig, minBundleId, credentials }: {
33
39
  };
34
40
  }>;
35
41
  //#endregion
42
+ //#region src/device.d.ts
43
+ interface AdbDevice {
44
+ readonly serial: string;
45
+ /** `device` when it takes commands; else `offline`, `unauthorized`, and so on. */
46
+ readonly state: string;
47
+ }
48
+ /** What `adb devices` lists. */
49
+ declare const listAdbDevices: () => Promise<readonly AdbDevice[]>;
50
+ /**
51
+ * The device to install on: `serial`, as adb's own `ANDROID_SERIAL` names it
52
+ * too, or else the only one that takes commands.
53
+ */
54
+ declare const selectAdbDevice: (devices: readonly AdbDevice[], serial?: string | undefined) => AdbDevice;
55
+ /**
56
+ * Installs an APK on a device, and opens its launcher activity. `appId` is
57
+ * the APK's own application ID, whatever suffix its build gave it.
58
+ */
59
+ declare const installOnAndroidDevice: ({ serial, apkPath, appId }: {
60
+ readonly serial: string;
61
+ readonly apkPath: string;
62
+ readonly appId: string;
63
+ }) => Promise<void>;
64
+ //#endregion
36
65
  //#region src/uploadToPlay.d.ts
37
66
  /**
38
67
  * Google Play refused the upload: it already has a bundle or APK with the
@@ -43,18 +72,81 @@ declare class PlayVersionCodeUsedError extends Error {
43
72
  readonly name = "PlayVersionCodeUsedError";
44
73
  constructor(options?: ErrorOptions);
45
74
  }
75
+ /**
76
+ * Play Console's page that invites `email` as a user. `_` stands for the
77
+ * developer account the browser is signed in to, so no ID is needed.
78
+ */
79
+ declare const playConsoleInviteUrl: (email: string) => string;
80
+ /**
81
+ * Whether a service account reaches an app in Google Play:
82
+ * - `ready`: it opened an edit of the app;
83
+ * - `denied`: Google Play refused it (401/403), so it needs a Play Console
84
+ * invite;
85
+ * - `not-found`: Google Play has no such app it can see (404), as before
86
+ * the app's first `.aab` is uploaded in Play Console;
87
+ * - `refused`: Google's token endpoint refused the key itself, such as a
88
+ * deleted key, with Google's reason.
89
+ */
90
+ type PlayAccess = {
91
+ readonly status: "ready";
92
+ } | {
93
+ readonly status: "denied";
94
+ readonly email: string;
95
+ } | {
96
+ readonly status: "not-found";
97
+ readonly email: string;
98
+ } | {
99
+ readonly status: "refused";
100
+ readonly email: string;
101
+ readonly reason: string;
102
+ };
103
+ /**
104
+ * Checks once whether the service account's key reaches `packageName`: it
105
+ * opens an edit of the app and deletes it again, which changes nothing.
106
+ * Throws only for what says nothing about access, such as a network error.
107
+ */
108
+ declare const checkPlayAccess: ({ serviceAccount: { json }, packageName, fetch }: {
109
+ serviceAccount: Credentials["play-service-account"];
110
+ packageName: string;
111
+ fetch?: typeof globalThis.fetch;
112
+ }) => Promise<PlayAccess>;
113
+ /**
114
+ * The status of the internal testing release holding `versionCode`, such as
115
+ * `completed` or `draft`, or null when the track doesn't hold it: never
116
+ * uploaded, or replaced by a newer release, which testers get instead.
117
+ */
118
+ declare const readPlayInternalRelease: ({ versionCode, packageName, serviceAccount, fetch }: {
119
+ versionCode: number;
120
+ /** The application ID the `.aab` was built with. */
121
+ packageName: string;
122
+ serviceAccount: Credentials["play-service-account"];
123
+ fetch?: typeof globalThis.fetch;
124
+ }) => Promise<string | null>;
46
125
  /**
47
126
  * Whether Google Play's internal testing track already releases the
48
- * `.aab`'s version code, as when a reused native build was uploaded
49
- * before. It reads the track in an edit it then deletes, changing nothing.
127
+ * `.aab`'s version code, as when a reused native build was uploaded before.
50
128
  */
51
- declare const findPlayInternalRelease: ({ versionCode, packageName, serviceAccount: { json }, fetch }: {
129
+ declare const findPlayInternalRelease: (options: {
52
130
  versionCode: number;
53
131
  /** The application ID the `.aab` was built with. */
54
132
  packageName: string;
55
133
  serviceAccount: Credentials["play-service-account"];
56
134
  fetch?: typeof globalThis.fetch;
57
135
  }) => Promise<boolean>;
136
+ /**
137
+ * The highest version code Google Play has taken for the app, on any track,
138
+ * or null with none: a new `.aab` needs one above it.
139
+ */
140
+ declare const readPlayHighestVersionCode: ({ packageName, serviceAccount, fetch }: {
141
+ packageName: string;
142
+ serviceAccount: Credentials["play-service-account"];
143
+ fetch?: typeof globalThis.fetch;
144
+ }) => Promise<number | null>;
145
+ /**
146
+ * The link that opts a tester in to the app's testing tracks. A build on the
147
+ * internal track installs through it, for the testers Play Console lists.
148
+ */
149
+ declare const playTestingUrl: (packageName: string) => string;
58
150
  /**
59
151
  * Throws when the `.aab` is signed with the Android debug keystore, which
60
152
  * Google Play refuses: a release build type left on `signingConfigs.debug`,
@@ -109,6 +201,17 @@ declare const extractBuiltInBundle: ({ artifactPath, outputPath }: {
109
201
  outputPath: string;
110
202
  }) => Promise<void>;
111
203
  //#endregion
204
+ //#region src/utils/sandboxGradle.d.ts
205
+ /**
206
+ * Why a sandbox build of a scheme can't work, read from the project's files
207
+ * before anything is built, or null. The init script checks again, with what
208
+ * Gradle actually resolved.
209
+ */
210
+ declare const findSandboxGradleBlocker: ({ variant, appModuleName }: {
211
+ readonly variant?: string;
212
+ readonly appModuleName?: string;
213
+ }) => string | null;
214
+ //#endregion
112
215
  //#region src/utils/readBuiltApp.d.ts
113
216
  /**
114
217
  * What the built `.apk` or `.aab` reports at runtime: the `versionName` and
@@ -144,117 +247,4 @@ declare const readBuiltVersionCode: ({ artifactPath, androidProjectPath }: {
144
247
  androidProjectPath: string;
145
248
  }) => Promise<number | undefined>;
146
249
  //#endregion
147
- //#region src/google/types.d.ts
148
- /** What stopped Hot Updater from issuing the Play service account key. */
149
- type PlayServiceAccountErrorCode =
150
- /** No OAuth client to sign in with, or Google refused it. */
151
- "sign-in-not-configured" |
152
- /** The browser sign-in was cancelled, refused, or timed out. */
153
- "sign-in-cancelled" |
154
- /** The account unticked a scope the setup needs on Google's consent screen. */
155
- "scope-not-granted" |
156
- /** The developer account ID names no Play Console account. */
157
- "developer-not-found" |
158
- /** The Google Account is no admin of the Play Console developer account. */
159
- "not-play-admin" |
160
- /** Google Play has no app with the package name in the developer account. */
161
- "app-not-found" |
162
- /** The Google Account may not create a Google Cloud project. */
163
- "project-create-denied" |
164
- /** The Google Account has no Google Cloud project quota left. */
165
- "project-quota" |
166
- /** The Google Account may not enable APIs or create service accounts in the project. */
167
- "project-access-denied" |
168
- /** Google is still enabling an API, or it is disabled in the OAuth client's project. */
169
- "api-not-enabled" |
170
- /** An organization policy (`iam.disableServiceAccountKeyCreation`) forbids keys. */
171
- "key-creation-disabled";
172
- /** A named failure of `issuePlayServiceAccount`, with what to do in its message. */
173
- declare class PlayServiceAccountError extends Error {
174
- readonly code: PlayServiceAccountErrorCode;
175
- constructor(code: PlayServiceAccountErrorCode, message: string, options?: {
176
- cause?: unknown;
177
- });
178
- }
179
- /**
180
- * A Google OAuth client of type "Desktop app". Google treats an installed
181
- * app's client secret as public, so it ships with the client ID.
182
- */
183
- interface GoogleOAuthClient {
184
- readonly clientId: string;
185
- readonly clientSecret?: string;
186
- }
187
- /** The environment variables that replace Hot Updater's Google OAuth client. */
188
- declare const GOOGLE_OAUTH_CLIENT_ENV_NAMES: {
189
- readonly clientId: "HOT_UPDATER_GOOGLE_OAUTH_CLIENT_ID";
190
- readonly clientSecret: "HOT_UPDATER_GOOGLE_OAUTH_CLIENT_SECRET";
191
- };
192
- /** The service account Hot Updater creates, `hot-updater-play@<project>.iam.gserviceaccount.com`. */
193
- declare const PLAY_SERVICE_ACCOUNT_ID = "hot-updater-play";
194
- /** Where a Play Console admin finds the developer account ID. */
195
- declare const PLAY_CONSOLE_URL = "https://play.google.com/console";
196
- //#endregion
197
- //#region src/playServiceAccount.d.ts
198
- /**
199
- * Hot Updater's Google OAuth client, a "Desktop app" client the sign-in
200
- * opens Google's consent screen for. Empty in a build that has none, where
201
- * `HOT_UPDATER_GOOGLE_OAUTH_CLIENT_ID` and `_SECRET` name one.
202
- */
203
- declare const HOT_UPDATER_GOOGLE_OAUTH_CLIENT: GoogleOAuthClient;
204
- /** A Google Cloud project the signed-in account can use. */
205
- interface GoogleCloudProject {
206
- readonly projectId: string;
207
- readonly displayName?: string;
208
- }
209
- interface IssuePlayServiceAccountRequest {
210
- /** The app's package name in Google Play, which the service account may release. */
211
- readonly packageName: string;
212
- /** The OAuth client to sign in with; Hot Updater's unless set. */
213
- readonly oauthClient?: GoogleOAuthClient;
214
- /** Sees the sign-in URL, to print it and open it in a browser. */
215
- readonly onSignInUrl: (url: string) => Promise<void> | void;
216
- /** Asks for the Play Console developer account ID, after the sign-in. */
217
- readonly askDeveloperId: () => Promise<string>;
218
- /**
219
- * Sees the account's projects when there are any, and returns the one to
220
- * create the service account in, or undefined to create a project.
221
- */
222
- readonly chooseProject: (projects: readonly GoogleCloudProject[]) => Promise<string | undefined>;
223
- /** Reports each step, such as "Creating the service account". */
224
- readonly onStep?: (message: string) => void;
225
- }
226
- /**
227
- * A Play service account's JSON key, just created, with the access token
228
- * of the sign-in it was created in. `revoke` deletes the key while the
229
- * sign-in lasts, and `dispose` ends the sign-in.
230
- */
231
- interface IssuedPlayServiceAccount {
232
- /** The JSON key file, as Google Cloud downloads it. */
233
- readonly json: string;
234
- /** The service account's email, the Play Console user it releases as. */
235
- readonly email: string;
236
- readonly projectId: string;
237
- readonly developerId: string;
238
- /** The key's ID, as Google Cloud lists it under the service account's keys. */
239
- readonly keyId: string;
240
- /** Deletes the key with the same sign-in; whether Google Cloud did. */
241
- revoke(): Promise<boolean>;
242
- /** Ends the sign-in: Google revokes its access token. */
243
- dispose(): Promise<void>;
244
- }
245
- /**
246
- * Signs in with Google and issues a service account key that releases the
247
- * app to Google Play: the developer signs in on Google's own consent
248
- * screen, in a browser, and the caller never sees the password. Nothing of
249
- * the sign-in outlives `dispose`.
250
- */
251
- type IssuePlayServiceAccount = (request: IssuePlayServiceAccountRequest) => Promise<IssuedPlayServiceAccount>;
252
- /**
253
- * Hot Updater's issuer, the one place that picks how it is done: Google's
254
- * OAuth for installed apps, then the Cloud Resource Manager, Service Usage,
255
- * IAM, and Play Developer APIs. Another implementation of
256
- * `IssuePlayServiceAccount` replaces it here without touching its callers.
257
- */
258
- declare const issuePlayServiceAccount: IssuePlayServiceAccount;
259
- //#endregion
260
- export { type EnrichedNativeBuildAndroidScheme, GOOGLE_OAUTH_CLIENT_ENV_NAMES, type GoogleCloudProject, type GoogleOAuthClient, HOT_UPDATER_GOOGLE_OAUTH_CLIENT, type IssuePlayServiceAccount, type IssuePlayServiceAccountRequest, type IssuedPlayServiceAccount, PLAY_CONSOLE_URL, PLAY_SERVICE_ACCOUNT_ID, PlayServiceAccountError, type PlayServiceAccountErrorCode, PlayVersionCodeUsedError, type UploadToPlayResult, assertPlaySigned, buildAndroid, enrichNativeBuildAndroidScheme, extractBuiltInBundle, findPlayInternalRelease, issuePlayServiceAccount, readBuiltApp, readBuiltPackageName, readBuiltVersionCode, resolvePlayUploadServiceAccount, uploadToPlay };
250
+ export { type AdbDevice, type EnrichedNativeBuildAndroidScheme, type PlayAccess, PlayVersionCodeUsedError, type UploadToPlayResult, assertPlaySigned, buildAndroid, checkPlayAccess, enrichNativeBuildAndroidScheme, extractBuiltInBundle, findPlayInternalRelease, findSandboxGradleBlocker, installOnAndroidDevice, listAdbDevices, playConsoleInviteUrl, playTestingUrl, readBuiltApp, readBuiltPackageName, readBuiltVersionCode, readPlayHighestVersionCode, readPlayInternalRelease, resolvePlayUploadServiceAccount, selectAdbDevice, uploadToPlay };