@hot-updater/android-helper 1.2.0-rc.0 → 1.2.0-rc.10

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
@@ -13,15 +13,19 @@ 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 }: {
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[];
22
24
  }) => Promise<{
23
25
  buildDirectory: string;
24
26
  buildArtifactPath: string;
27
+ /** The build log, or null without one. */
28
+ logFilePath: string | null;
25
29
  /** What the built artifact reports, or undefined without aapt2. */
26
30
  builtApp?: {
27
31
  appVersion: string | null;
@@ -42,6 +46,44 @@ declare class PlayVersionCodeUsedError extends Error {
42
46
  readonly name = "PlayVersionCodeUsedError";
43
47
  constructor(options?: ErrorOptions);
44
48
  }
49
+ /**
50
+ * Play Console's page that invites `email` as a user. `_` stands for the
51
+ * developer account the browser is signed in to, so no ID is needed.
52
+ */
53
+ declare const playConsoleInviteUrl: (email: string) => string;
54
+ /**
55
+ * Whether a service account reaches an app in Google Play:
56
+ * - `ready`: it opened an edit of the app;
57
+ * - `denied`: Google Play refused it (401/403), so it needs a Play Console
58
+ * invite;
59
+ * - `not-found`: Google Play has no such app it can see (404), as before
60
+ * the app's first `.aab` is uploaded in Play Console;
61
+ * - `refused`: Google's token endpoint refused the key itself, such as a
62
+ * deleted key, with Google's reason.
63
+ */
64
+ type PlayAccess = {
65
+ readonly status: "ready";
66
+ } | {
67
+ readonly status: "denied";
68
+ readonly email: string;
69
+ } | {
70
+ readonly status: "not-found";
71
+ readonly email: string;
72
+ } | {
73
+ readonly status: "refused";
74
+ readonly email: string;
75
+ readonly reason: string;
76
+ };
77
+ /**
78
+ * Checks once whether the service account's key reaches `packageName`: it
79
+ * opens an edit of the app and deletes it again, which changes nothing.
80
+ * Throws only for what says nothing about access, such as a network error.
81
+ */
82
+ declare const checkPlayAccess: ({ serviceAccount: { json }, packageName, fetch }: {
83
+ serviceAccount: Credentials["play-service-account"];
84
+ packageName: string;
85
+ fetch?: typeof globalThis.fetch;
86
+ }) => Promise<PlayAccess>;
45
87
  /**
46
88
  * Whether Google Play's internal testing track already releases the
47
89
  * `.aab`'s version code, as when a reused native build was uploaded
@@ -143,117 +185,4 @@ declare const readBuiltVersionCode: ({ artifactPath, androidProjectPath }: {
143
185
  androidProjectPath: string;
144
186
  }) => Promise<number | undefined>;
145
187
  //#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 };
188
+ export { type EnrichedNativeBuildAndroidScheme, type PlayAccess, PlayVersionCodeUsedError, type UploadToPlayResult, assertPlaySigned, buildAndroid, checkPlayAccess, enrichNativeBuildAndroidScheme, extractBuiltInBundle, findPlayInternalRelease, playConsoleInviteUrl, readBuiltApp, readBuiltPackageName, readBuiltVersionCode, resolvePlayUploadServiceAccount, uploadToPlay };
package/dist/index.d.mts CHANGED
@@ -14,15 +14,19 @@ 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 }: {
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[];
23
25
  }) => Promise<{
24
26
  buildDirectory: string;
25
27
  buildArtifactPath: string;
28
+ /** The build log, or null without one. */
29
+ logFilePath: string | null;
26
30
  /** What the built artifact reports, or undefined without aapt2. */
27
31
  builtApp?: {
28
32
  appVersion: string | null;
@@ -43,6 +47,44 @@ declare class PlayVersionCodeUsedError extends Error {
43
47
  readonly name = "PlayVersionCodeUsedError";
44
48
  constructor(options?: ErrorOptions);
45
49
  }
50
+ /**
51
+ * Play Console's page that invites `email` as a user. `_` stands for the
52
+ * developer account the browser is signed in to, so no ID is needed.
53
+ */
54
+ declare const playConsoleInviteUrl: (email: string) => string;
55
+ /**
56
+ * Whether a service account reaches an app in Google Play:
57
+ * - `ready`: it opened an edit of the app;
58
+ * - `denied`: Google Play refused it (401/403), so it needs a Play Console
59
+ * invite;
60
+ * - `not-found`: Google Play has no such app it can see (404), as before
61
+ * the app's first `.aab` is uploaded in Play Console;
62
+ * - `refused`: Google's token endpoint refused the key itself, such as a
63
+ * deleted key, with Google's reason.
64
+ */
65
+ type PlayAccess = {
66
+ readonly status: "ready";
67
+ } | {
68
+ readonly status: "denied";
69
+ readonly email: string;
70
+ } | {
71
+ readonly status: "not-found";
72
+ readonly email: string;
73
+ } | {
74
+ readonly status: "refused";
75
+ readonly email: string;
76
+ readonly reason: string;
77
+ };
78
+ /**
79
+ * Checks once whether the service account's key reaches `packageName`: it
80
+ * opens an edit of the app and deletes it again, which changes nothing.
81
+ * Throws only for what says nothing about access, such as a network error.
82
+ */
83
+ declare const checkPlayAccess: ({ serviceAccount: { json }, packageName, fetch }: {
84
+ serviceAccount: Credentials["play-service-account"];
85
+ packageName: string;
86
+ fetch?: typeof globalThis.fetch;
87
+ }) => Promise<PlayAccess>;
46
88
  /**
47
89
  * Whether Google Play's internal testing track already releases the
48
90
  * `.aab`'s version code, as when a reused native build was uploaded
@@ -144,117 +186,4 @@ declare const readBuiltVersionCode: ({ artifactPath, androidProjectPath }: {
144
186
  androidProjectPath: string;
145
187
  }) => Promise<number | undefined>;
146
188
  //#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 };
189
+ export { type EnrichedNativeBuildAndroidScheme, type PlayAccess, PlayVersionCodeUsedError, type UploadToPlayResult, assertPlaySigned, buildAndroid, checkPlayAccess, enrichNativeBuildAndroidScheme, extractBuiltInBundle, findPlayInternalRelease, playConsoleInviteUrl, readBuiltApp, readBuiltPackageName, readBuiltVersionCode, resolvePlayUploadServiceAccount, uploadToPlay };