@steve31415/baselib 3.4.0 → 3.4.1

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.
@@ -1,4 +1,4 @@
1
- import { GoogleAuth, OAuth2Client } from 'google-auth-library';
1
+ import { type AuthClient } from 'google-auth-library';
2
2
  import type { Runner } from '../deploy/types.js';
3
3
  export type GcpCredential = {
4
4
  kind: 'adc';
@@ -22,4 +22,16 @@ export interface CredentialDeps {
22
22
  export declare function resolveGcpCredential(deps?: CredentialDeps): Promise<GcpCredential>;
23
23
  /** Short human description for the tool's progress line. */
24
24
  export declare function describeCredential(cred: GcpCredential): string;
25
- export declare function authClientFor(cred: GcpCredential): GoogleAuth | OAuth2Client;
25
+ /** The client the connector will mint the IAM login token from. Always a
26
+ * concrete AuthClient (JWT for a service-account key, UserRefreshClient for
27
+ * an authorized-user ADC file, OAuth2Client around a ready token), never a
28
+ * GoogleAuth: the connector tells the two apart with `instanceof GoogleAuth`
29
+ * against ITS copy of google-auth-library, and when a consumer's install
30
+ * hoists a different copy than baselib's (coder2, 2026-09-04 — connector
31
+ * 1.12 wants ^11, baselib ^10) a GoogleAuth of ours fails that check, gets
32
+ * wrapped as if it were an AuthClient, and the wrapper's getAccessToken()
33
+ * reads `.token` off the bare string GoogleAuth returns: "Failed to get
34
+ * access token for automatic IAM authentication". An AuthClient crosses the
35
+ * package boundary by duck typing alone, so the client carries both Cloud
36
+ * SQL scopes itself rather than relying on the wrapper's. */
37
+ export declare function authClientFor(cred: GcpCredential): Promise<AuthClient>;
@@ -54,11 +54,23 @@ export function describeCredential(cred) {
54
54
  return `gcloud access token for ${cred.account}`;
55
55
  }
56
56
  }
57
- export function authClientFor(cred) {
57
+ /** The client the connector will mint the IAM login token from. Always a
58
+ * concrete AuthClient (JWT for a service-account key, UserRefreshClient for
59
+ * an authorized-user ADC file, OAuth2Client around a ready token), never a
60
+ * GoogleAuth: the connector tells the two apart with `instanceof GoogleAuth`
61
+ * against ITS copy of google-auth-library, and when a consumer's install
62
+ * hoists a different copy than baselib's (coder2, 2026-09-04 — connector
63
+ * 1.12 wants ^11, baselib ^10) a GoogleAuth of ours fails that check, gets
64
+ * wrapped as if it were an AuthClient, and the wrapper's getAccessToken()
65
+ * reads `.token` off the bare string GoogleAuth returns: "Failed to get
66
+ * access token for automatic IAM authentication". An AuthClient crosses the
67
+ * package boundary by duck typing alone, so the client carries both Cloud
68
+ * SQL scopes itself rather than relying on the wrapper's. */
69
+ export async function authClientFor(cred) {
58
70
  if (cred.kind === 'access-token') {
59
71
  const client = new OAuth2Client();
60
72
  client.setCredentials({ access_token: cred.token });
61
73
  return client;
62
74
  }
63
- return new GoogleAuth({ keyFilename: cred.path, scopes: CLOUD_SQL_SCOPES });
75
+ return new GoogleAuth({ keyFilename: cred.path, scopes: CLOUD_SQL_SCOPES }).getClient();
64
76
  }
package/dist/ops/sql.js CHANGED
@@ -104,7 +104,7 @@ function outputTypes() {
104
104
  export async function connectCloudSql(target, log, runner) {
105
105
  const cred = await resolveGcpCredential({ runner });
106
106
  log(`connecting to ${target.instance} db=${target.database} as ${target.user} via ${describeCredential(cred)}`);
107
- const { options: connection, connector } = await cloudSqlClientOptions(target.instance, authClientFor(cred));
107
+ const { options: connection, connector } = await cloudSqlClientOptions(target.instance, await authClientFor(cred));
108
108
  const client = new pg.Client({
109
109
  ...connection,
110
110
  user: target.user,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steve31415/baselib",
3
- "version": "3.4.0",
3
+ "version": "3.4.1",
4
4
  "description": "Plasticine new-world shared platform library: logging, auth, service-to-service auth, db, HTTP, sync, app updates",
5
5
  "type": "module",
6
6
  "license": "MIT",