@sanoma-ai/connector-gcp 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -46,10 +46,36 @@ export default defineConfig({ connectors: [gcp], connections: [provisioning] });
46
46
 
47
47
  The mapping contains a file **path**, not its contents. Deliver the file through the trusted deployment environment; keep its contents and source tokens out of code, resource inputs, fixtures, logs and the secret-entry form. Treat this configuration and its file as security-sensitive even though no service-account private key is involved. Connect/verify the named account through the normal connection lifecycle; a declaration alone is not a verified binding.
48
48
 
49
- Only an explicit `external_account` OIDC federation file is accepted. It must use Google's STS endpoint, a JWT subject token and impersonation of the exact configured service account. Service-account key files, executable sources, AWS environment sources and ambient ADC fallback are refused. A successful token exchange and impersonation verify the selected identity; a configured email alone is not proof. Verification returns the account identity and an empty scope list, not the access token or an attestation of individual IAM grants. Google IAM remains authoritative for permissions.
49
+ Only explicit `external_account` OIDC federation configuration is accepted. It must use Google's STS endpoint, a JWT subject token and impersonation of the exact configured service account. Service-account key files, executable sources, AWS environment sources and ambient ADC fallback are refused. A successful token exchange and impersonation verify the selected identity; a configured email alone is not proof. Verification returns the account identity and an empty scope list, not the access token or an attestation of individual IAM grants. Google IAM remains authoritative for permissions.
50
50
 
51
51
  The provider receives that explicit federation configuration inside a fresh session for each authorized operation. The driver checks project IDs/numbers in resource identifiers and fields against the selected deployment. The provisioning account's Google IAM grants must also limit its authority: application-side checks do not replace IAM isolation. Give provisioning and company runtime different service accounts and roles; a company runtime must not inherit the provisioning account's IAM administration permissions.
52
52
 
53
+ ### Provisioning service on a non-Google host
54
+
55
+ Use the separate [provisioning identity service](../../packages/workflows/CLOUD-IDENTITY.md#provisioning-identity-from-a-non-google-host) when the control plane has no native Google identity:
56
+
57
+ ```ts
58
+ import { gcpProvisioningIdentity, gcpWithIdentities } from "@sanoma-ai/connector-gcp";
59
+
60
+ const gcp = gcpWithIdentities({
61
+ "gcp/provisioning": gcpProvisioningIdentity({
62
+ project: "example-company",
63
+ projectNumber: "123456789012",
64
+ serviceAccount: "provisioner@example-company.iam.gserviceaccount.com",
65
+ audience:
66
+ "//iam.googleapis.com/projects/123456789012/locations/global/workloadIdentityPools/provision/providers/google",
67
+ issuer: "https://provisioning.example.test/identity",
68
+ credential: async () => process.env.SANOMA_PROVISIONING_CREDENTIAL ?? "",
69
+ }),
70
+ });
71
+ ```
72
+
73
+ This is trusted deployment composition. The host supplies that explicit secret binding; there is no implicit environment fallback. `gcpProvisioningIdentity` generates an HTTPS URL-source configuration in memory, fixes Google STS and the target impersonation URL, and requests ten-minute access tokens. The named account must still be verified normally.
74
+
75
+ The callback is read for each verification and provider operation. A running provider session holds its starting bootstrap header while it renews from the URL, so bootstrap rotation needs enough overlap for active operations to finish. Stopping enrollment does not invalidate already issued Google OIDC tokens, which last up to one hour: remove federation/impersonation trust as part of incident revocation. Runtime identities use the separate company broker and never receive this provisioning bootstrap.
76
+
77
+ For another trusted deployment integration, `GcpIdentity.credentials` can return external-account JSON asynchronously instead of `credentialsFile`. Configure exactly one source. Callback/file/SDK failures are sanitized and never fall back to another identity. Do not call this callback from a workflow or serialize its output into durable state.
78
+
53
79
  ### First administrator setup
54
80
 
55
81
  An administrator must first establish the project, billing, required APIs, provisioning service account and initial federation trust using an existing authorized administration path. This connector has no project, billing or API-enablement resource. Grant the provisioning account only the KMS/IAM administration needed for its intended declarations, and grant the approved federated principal service-account impersonation access. Once that trust works, Sanoma can manage subsequent resources or import existing ones. See [Google's deployment-pipeline WIF setup](https://docs.cloud.google.com/iam/docs/workload-identity-federation-with-deployment-pipelines).
@@ -95,12 +121,24 @@ export const key = gcp.cryptoKey(
95
121
 
96
122
  Grant runtime encrypt/decrypt access with `keyIamMember` on the specific key. Keep production and preview identities separate. Rotation creates new key versions; it does not by itself re-encrypt stored ciphertext or retire versions needed by backups. This provisioning surface is separate from the credential-storage adapter in [#470](https://github.com/Sanoma-AI/sanoma/issues/470).
97
123
 
124
+ ### IAM member IDs
125
+
126
+ For `keyIamMember` and `serviceAccountIamMember`, the public operation result's `id` is the provider's import identifier:
127
+
128
+ ```text
129
+ resource_name role member [condition_title]
130
+ ```
131
+
132
+ Pass that returned `id` unchanged to a subsequent read, including when no saved provider state is available. Sanoma derives it from the structured parent resource, role, member and optional condition title. Custom role paths and `principal://` members retain their slashes. The provider's native `state.id` remains unchanged; its slash-delimited representation is not the import identifier. See the pinned provider's [IAM member import implementation](https://github.com/hashicorp/terraform-provider-google/blob/v8.7.0/google/tpgiamresource/resource_iam_member.go).
133
+
98
134
  ## Testing and current evidence
99
135
 
100
136
  `fakeGcp` is the bridge's in-memory resource fake; it is not Google IAM or a federation server. Authentication tests use synthetic STS/IAM responses and temporary token/config files, including separate account sources, denied impersonation, rejected key/executable configs and sanitized failures. Driver tests use a provider state double to check concurrent session separation, project/account refusals, symmetric-key and retention guards, OIDC condition requirements, sanitized failures and the fake. The recorded schema/pin in `testdata/` establishes the generated provider contract, not a successful cloud deployment.
101
137
 
102
138
  The [isolated live run](https://github.com/Sanoma-AI/sanoma/actions/runs/41164779676) passed on `e43fb77c1e05d51838687d4574b2678218983386` in project `sanoma-513217`: GitHub OIDC → WIF → scoped provisioning account, denied impersonation of another existing account, real Google-provider key create/read/update, rotation-period update and key-deletion refusal. One provider session remained active for 660 seconds and fetched a fresh OIDC subject token after its ten-minute impersonated token expired. Trust was restricted to numeric repository/owner IDs, branch, workflow and the exact reviewed commit. This proves that provisioning path; it does not establish live CRUD for all seven resource types or a company runtime's identity.
103
139
 
140
+ A later published-package workflow under [#532](https://github.com/Sanoma-AI/sanoma/issues/532) created a key ring, service account, crypto key and both IAM member types, then exposed a failure when reading an IAM member by its returned ID. The connector now derives importable public IDs while preserving native provider state. Synthetic regression coverage checks custom roles, `principal://` members, optional conditions and reads by returned ID without saved state. A successful live rerun of the full provisioning graph remains pending.
141
+
104
142
  The manual `gcp-live.yml` workflow accepts project ID/number, provisioner and denied-account emails, disposable key-ring name and WIF audience as inputs. Administrators must enable billing/APIs, establish narrowly scoped federation and ring permissions, and restrict trust to the intended repository, workflow, ref and reviewed commit before running it. The denied account must exist without an impersonation grant to that federation. No service-account private key is needed. Ordinary CI skips `test/live.test.ts`; only the dedicated workflow enables it. The test creates a synthetic key, so retire all its versions after verification; KMS key/ring metadata remains. Never use a production ring. Provisioning and renewable runtime identity remain separate.
105
143
 
106
144
  Run `pnpm vitest run connectors/gcp` and the repository's type/lint/build checks. Regenerate types with `pnpm --filter @sanoma-ai/connector-gcp generate`; update the recorded schema/pins deliberately, and never edit `resources.gen.ts` by hand. Test-map details are in [test/AGENTS.md](test/AGENTS.md).
@@ -1,10 +1,12 @@
1
1
  import { type AuthenticationContext } from "@sanoma-ai/workflows";
2
- /** Trusted deployment configuration. The file is generated by the workload's OIDC integration. */
2
+ /** Trusted deployment configuration, resolved inside each authorized invocation. */
3
3
  export interface GcpIdentity {
4
4
  project: string;
5
5
  projectNumber: string;
6
6
  serviceAccount: string;
7
- credentialsFile: string;
7
+ credentialsFile?: string;
8
+ /** Reads protected external-account configuration; never a workflow callback or durable result. */
9
+ credentials?: () => Promise<string>;
8
10
  }
9
11
  export type GcpIdentities = Readonly<Record<string, GcpIdentity>>;
10
12
  export declare function identityFor(identities: GcpIdentities, context?: AuthenticationContext): GcpIdentity;
@@ -7,14 +7,22 @@ export function identityFor(identities, context) {
7
7
  !/^[a-z][a-z0-9-]{4,28}[a-z0-9]$/.test(identity.project) ||
8
8
  !/^[1-9][0-9]+$/.test(identity.projectNumber) ||
9
9
  !/^[a-z][a-z0-9-]+@[a-z][a-z0-9-]+\.iam\.gserviceaccount\.com$/.test(identity.serviceAccount) ||
10
- !identity.credentialsFile)
10
+ !((typeof identity.credentialsFile === "string" && identity.credentialsFile.length > 0 && !identity.credentials) ||
11
+ (typeof identity.credentials === "function" && identity.credentialsFile === undefined)))
11
12
  throw new AuthenticationError("missing");
12
13
  return identity;
13
14
  }
14
15
  /** Explicit WIF config only: no ambient ADC fallback, service-account key or executable source. */
15
16
  export async function federationCredentials(identity) {
16
17
  try {
17
- const text = await readFile(identity.credentialsFile, "utf8");
18
+ // Refuse ambiguous sources even when called outside identityFor. Never fall back on failure.
19
+ const text = identity.credentials && identity.credentialsFile === undefined
20
+ ? await identity.credentials()
21
+ : identity.credentialsFile && !identity.credentials
22
+ ? await readFile(identity.credentialsFile, "utf8")
23
+ : (() => {
24
+ throw new Error();
25
+ })();
18
26
  if (Buffer.byteLength(text) > 65_536)
19
27
  throw new Error();
20
28
  const config = JSON.parse(text);
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.js","sourceRoot":"","sources":["../src/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAA8B,MAAM,sBAAsB,CAAC;AAW7G,MAAM,UAAU,WAAW,CAAC,UAAyB,EAAE,OAA+B;IACpF,MAAM,QAAQ,GAAG,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1F,IACE,CAAC,QAAQ;QACT,CAAC,gCAAgC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QACxD,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC;QAC7C,CAAC,8DAA8D,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;QAC7F,CAAC,QAAQ,CAAC,eAAe;QAEzB,MAAM,IAAI,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC3C,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,mGAAmG;AACnG,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,QAAqB;IAC/D,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC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-ai/bridge/connector";
2
2
  import { vendorInfo } from "@sanoma-ai/workflows";
3
3
  import { provider, google_kms_key_ring, google_kms_crypto_key, google_kms_crypto_key_iam_member, google_service_account, google_service_account_iam_member, google_iam_workload_identity_pool, google_iam_workload_identity_pool_provider, } from "./resources.gen.js";
4
+ // Google's IAM state IDs contain slash-separated role/member/condition fields, but
5
+ // its importer takes space-separated fields. Derive a round-trippable binding ID
6
+ // from structured state rather than parsing slashes inside custom roles/principals.
7
+ const iamBindingId = (parent) => (state) => {
8
+ const condition = state.condition;
9
+ return [state[parent], state.role, state.member, ...(condition?.title ? [condition.title] : [])].join(" ");
10
+ };
4
11
  export const gcpTf = tfConnector({
5
12
  vendor: "gcp",
6
13
  provider,
@@ -8,9 +15,19 @@ export const gcpTf = tfConnector({
8
15
  types: {
9
16
  keyRing: { tf: google_kms_key_ring, title: "KMS key ring", writable: true },
10
17
  cryptoKey: { tf: google_kms_crypto_key, title: "KMS key", writable: true },
11
- keyIamMember: { tf: google_kms_crypto_key_iam_member, title: "KMS key access", writable: true },
18
+ keyIamMember: {
19
+ tf: google_kms_crypto_key_iam_member,
20
+ title: "KMS key access",
21
+ writable: true,
22
+ bindingId: iamBindingId("crypto_key_id"),
23
+ },
12
24
  serviceAccount: { tf: google_service_account, title: "Service account", writable: true },
13
- serviceAccountIamMember: { tf: google_service_account_iam_member, title: "Service account access", writable: true },
25
+ serviceAccountIamMember: {
26
+ tf: google_service_account_iam_member,
27
+ title: "Service account access",
28
+ writable: true,
29
+ bindingId: iamBindingId("service_account_id"),
30
+ },
14
31
  workloadIdentityPool: { tf: google_iam_workload_identity_pool, title: "Workload identity pool", writable: true },
15
32
  workloadIdentityProvider: { tf: google_iam_workload_identity_pool_provider, title: "OIDC trust", writable: true },
16
33
  },
@@ -1 +1 @@
1
- {"version":3,"file":"connector.js","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,O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,EAAE;QAC1E,YAAY,EAAE;YACZ,EAAE,EAAE,gCAAgC;YACpC,KAAK,EAAE,gBAAgB;YACvB,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,YAAY,CAAC,eAAe,CAAC;SACzC;QACD,cAAc,EAAE,EAAE,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACxF,uBAAuB,EAAE;YACvB,EAAE,EAAE,iCAAiC;YACrC,KAAK,EAAE,wBAAwB;YAC/B,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,YAAY,CAAC,oBAAoB,CAAC;SAC9C;QACD,oBAAoB,EAAE,EAAE,EAAE,EAAE,iCAAiC,EAAE,KAAK,EAAE,wBAAwB,EAAE,QAAQ,EAAE,IAAI,EAAE;QAChH,wBAAwB,EAAE,EAAE,EAAE,EAAE,0CAA0C,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE;KAClH;IACD,UAAU,EAAE;QACV,SAAS,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE;QAChD,YAAY,EAAE,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE;QAC1D,uBAAuB,EAAE,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,EAAE;KAChF;CACF,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { type GcpIdentities } from "./authentication.ts";
2
+ export { gcpProvisioningIdentity } from "./provisioning-identity.ts";
2
3
  export type { GcpIdentities, GcpIdentity } from "./authentication.ts";
3
- /** Bind named connections to trusted deployment WIF files; configuration contains no secret values. */
4
+ /** Bind named connections to trusted deployment WIF sources; configuration contains no secret values. */
4
5
  export declare function gcpWithIdentities(identities: GcpIdentities): import("@sanoma-ai/workflows").Connector<"gcp", import("@sanoma-ai/bridge/connector").TfResources<"gcp", {
5
6
  keyRing: import("zod").ZodObject<{
6
7
  id: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
package/dist/index.js CHANGED
@@ -3,7 +3,8 @@ import { gcpTf } from "./connector.js";
3
3
  import { gcpAuthentication } from "./authentication.js";
4
4
  import { gcpDriver } from "./driver.js";
5
5
  import { fakeGcp } from "./fake.js";
6
- /** Bind named connections to trusted deployment WIF files; configuration contains no secret values. */
6
+ export { gcpProvisioningIdentity } from "./provisioning-identity.js";
7
+ /** Bind named connections to trusted deployment WIF sources; configuration contains no secret values. */
7
8
  export function gcpWithIdentities(identities) {
8
9
  const configured = Object.freeze(Object.fromEntries(Object.entries(identities).map(([id, identity]) => [id, Object.freeze({ ...identity })])));
9
10
  return withSetup(gcpTf.connector, {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAsB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,uGAAuG;AACvG,MAAM,UAAU,iBAAiB,CAAC,UAAyB;IACzD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAC9B,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAC7G,CAAC;IACF,OAAO,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE;QAChC,cAAc,EAAE,EAAE,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,iBAAiB,CAAC,EAAE,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { GcpIdentity } from "./authentication.ts";
2
+ /** Build a protected URL-source WIF configuration for the separate provisioning identity service. */
3
+ export declare function gcpProvisioningIdentity(options: {
4
+ project: string;
5
+ projectNumber: string;
6
+ serviceAccount: string;
7
+ audience: string;
8
+ /** HTTPS GET /identity endpoint; fixed by the deployment, never connection input. */
9
+ issuer: string;
10
+ /** Read the current provisioning bearer from protected host configuration. */
11
+ credential(): Promise<string>;
12
+ }): GcpIdentity;
@@ -0,0 +1,48 @@
1
+ import { AuthenticationError } from "@sanoma-ai/workflows";
2
+ /** Build a protected URL-source WIF configuration for the separate provisioning identity service. */
3
+ export function gcpProvisioningIdentity(options) {
4
+ const { project, projectNumber, serviceAccount, audience, issuer, credential } = options;
5
+ try {
6
+ const url = new URL(issuer);
7
+ if (url.protocol !== "https:" ||
8
+ url.username ||
9
+ url.password ||
10
+ url.search ||
11
+ url.hash ||
12
+ url.pathname !== "/identity" ||
13
+ !/^\/\/iam\.googleapis\.com\/projects\/[1-9][0-9]+\/locations\/global\/workloadIdentityPools\/[a-z][a-z0-9-]+\/providers\/[a-z][a-z0-9-]+$/.test(audience))
14
+ throw new Error();
15
+ }
16
+ catch {
17
+ throw new AuthenticationError("rejected");
18
+ }
19
+ return {
20
+ project,
21
+ projectNumber,
22
+ serviceAccount,
23
+ credentials: async () => {
24
+ try {
25
+ const bearer = await credential();
26
+ if (!/^[A-Za-z0-9_-]{43}$/.test(bearer))
27
+ throw new Error();
28
+ return JSON.stringify({
29
+ type: "external_account",
30
+ audience,
31
+ subject_token_type: "urn:ietf:params:oauth:token-type:jwt",
32
+ token_url: "https://sts.googleapis.com/v1/token",
33
+ service_account_impersonation_url: `https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/${serviceAccount}:generateAccessToken`,
34
+ service_account_impersonation: { token_lifetime_seconds: 600 },
35
+ credential_source: {
36
+ url: issuer,
37
+ headers: { Authorization: `Bearer ${bearer}` },
38
+ format: { type: "json", subject_token_field_name: "idToken" },
39
+ },
40
+ });
41
+ }
42
+ catch {
43
+ throw new AuthenticationError("rejected");
44
+ }
45
+ },
46
+ };
47
+ }
48
+ //# sourceMappingURL=provisioning-identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provisioning-identity.js","sourceRoot":"","sources":["../src/provisioning-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG3D,qGAAqG;AACrG,MAAM,UAAU,uBAAuB,CAAC,OASvC;IACC,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACzF,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;QAC5B,IACE,GAAG,CAAC,QAAQ,KAAK,QAAQ;YACzB,GAAG,CAAC,QAAQ;YACZ,GAAG,CAAC,QAAQ;YACZ,GAAG,CAAC,MAAM;YACV,GAAG,CAAC,IAAI;YACR,GAAG,CAAC,QAAQ,KAAK,WAAW;YAC5B,CAAC,0IAA0I,CAAC,IAAI,CAC9I,QAAQ,CACT;YAED,MAAM,IAAI,KAAK,EAAE,CAAC;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO;QACL,OAAO;QACP,aAAa;QACb,cAAc;QACd,WAAW,EAAE,KAAK,IAAI,EAAE;YACtB,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;gBAClC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC;oBAAE,MAAM,IAAI,KAAK,EAAE,CAAC;gBAC3D,OAAO,IAAI,CAAC,SAAS,CAAC;oBACpB,IAAI,EAAE,kBAAkB;oBACxB,QAAQ;oBACR,kBAAkB,EAAE,sCAAsC;oBAC1D,SAAS,EAAE,qCAAqC;oBAChD,iCAAiC,EAAE,uEAAuE,cAAc,sBAAsB;oBAC9I,6BAA6B,EAAE,EAAE,sBAAsB,EAAE,GAAG,EAAE;oBAC9D,iBAAiB,EAAE;wBACjB,GAAG,EAAE,MAAM;wBACX,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,MAAM,EAAE,EAAE;wBAC9C,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,wBAAwB,EAAE,SAAS,EAAE;qBAC9D;iBACF,CAAC,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanoma-ai/connector-gcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Google Cloud KMS and IAM provisioning through isolated OpenTofu provider sessions",
5
5
  "keywords": [
6
6
  "connector",
@@ -54,14 +54,14 @@
54
54
  "google-auth-library": "^10.5.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@sanoma-ai/bridge": "0.5.0",
58
- "@sanoma-ai/workflows": "0.10.2",
57
+ "@sanoma-ai/bridge": "0.5.1",
58
+ "@sanoma-ai/workflows": "0.10.11",
59
59
  "msw": "^3.0.3",
60
60
  "zod": "^4.6.5"
61
61
  },
62
62
  "peerDependencies": {
63
- "@sanoma-ai/bridge": "^0.5.0",
64
- "@sanoma-ai/workflows": "^0.10.2",
63
+ "@sanoma-ai/bridge": "^0.5.1",
64
+ "@sanoma-ai/workflows": "^0.10.11",
65
65
  "zod": "^4"
66
66
  },
67
67
  "engines": {