@openhi/constructs 0.0.141 → 0.0.142

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/lib/index.mjs CHANGED
@@ -2992,6 +2992,11 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
2992
2992
  * the website service will see at synth time. Both hostnames are
2993
2993
  * `https://`-only — they always resolve to real DNS records.
2994
2994
  *
2995
+ * The stage's `additionalTrustedClientOrigins` config entries (e.g. on-site
2996
+ * customer SPA hosts) are appended verbatim — both `http://` and `https://`
2997
+ * entries flow into CORS. Scheme filtering is OAuth-specific and happens
2998
+ * in `OpenHiAuthService.resolveOAuthRedirectUrls`.
2999
+ *
2995
3000
  * Auto-injected on every stage (no `isNonProd` gate) so the admin SPA can
2996
3001
  * call the API cross-origin without the caller having to predict the
2997
3002
  * per-deploy hostname. Override to customize the auto-injected set.
@@ -3011,7 +3016,9 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
3011
3016
  childZonePrefix: this.childZonePrefix,
3012
3017
  zoneName
3013
3018
  });
3014
- return [`https://${adminHost}`, `https://${websiteHost}`];
3019
+ const stageType = this.ohEnv.ohStage.stageType;
3020
+ const additional = this.ohEnv.ohStage.ohApp.config.deploymentTargets?.[stageType]?.additionalTrustedClientOrigins ?? [];
3021
+ return [`https://${adminHost}`, `https://${websiteHost}`, ...additional];
3015
3022
  }
3016
3023
  /**
3017
3024
  * Builds the full `CorsPreflightOptions` from a merged origins array,
@@ -3712,14 +3719,20 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
3712
3719
  * - `https://admin{,-<childZonePrefix>}.<zone>/oauth/{callback,logout}`
3713
3720
  * - `https://www{,-<childZonePrefix>}.<zone>/oauth/{callback,logout}`
3714
3721
  *
3715
- * Both deployed-host pairs are auto-injected on every stage. On non-prod
3716
- * stages the localhost dev URLs from {@link LOCALHOST_OAUTH_CALLBACK_URLS}
3717
- * / {@link LOCALHOST_OAUTH_LOGOUT_URLS} join the merge; on prod they are
3722
+ * Both deployed-host pairs are auto-injected on every stage. The stage's
3723
+ * `additionalTrustedClientOrigins` entries (e.g. on-site customer SPA
3724
+ * hosts) are filtered to `https://`-prefix values and contribute
3725
+ * `/oauth/callback` + `/oauth/logout` URLs to the merge — Cognito rejects
3726
+ * non-localhost http callbacks, so `http://` entries are silently dropped.
3727
+ * On non-prod stages the localhost dev URLs from
3728
+ * {@link LOCALHOST_OAUTH_CALLBACK_URLS} /
3729
+ * {@link LOCALHOST_OAUTH_LOGOUT_URLS} join the merge; on prod they are
3718
3730
  * deliberately excluded.
3719
3731
  *
3720
3732
  * If `zoneName` is absent (no-DNS test configurations), the deployed-host
3721
- * pairs are skipped — only the localhost set survives, and only on
3722
- * non-prod. Override to customize.
3733
+ * pairs are skipped — only the localhost set and any configured
3734
+ * additional `https://` origins survive (the latter on every stage).
3735
+ * Override to customize.
3723
3736
  */
3724
3737
  resolveOAuthRedirectUrls() {
3725
3738
  const isNonProd = this.ohEnv.ohStage.stageType !== import_config7.OPEN_HI_STAGE.PROD;
@@ -3741,15 +3754,21 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
3741
3754
  });
3742
3755
  deployedOrigins.push(`https://${adminHost}`, `https://${websiteHost}`);
3743
3756
  }
3757
+ const stageType = this.ohEnv.ohStage.stageType;
3758
+ const additionalHttpsOrigins = this.ohEnv.ohStage.ohApp.config.deploymentTargets?.[stageType]?.additionalTrustedClientOrigins?.filter(
3759
+ (o) => o.startsWith("https://")
3760
+ ) ?? [];
3744
3761
  const localhostCallbacks = isNonProd ? LOCALHOST_OAUTH_CALLBACK_URLS : [];
3745
3762
  const localhostLogouts = isNonProd ? LOCALHOST_OAUTH_LOGOUT_URLS : [];
3746
3763
  return {
3747
3764
  callbackUrls: [
3748
3765
  ...deployedOrigins.map((o) => `${o}/oauth/callback`),
3766
+ ...additionalHttpsOrigins.map((o) => `${o}/oauth/callback`),
3749
3767
  ...localhostCallbacks
3750
3768
  ],
3751
3769
  logoutUrls: [
3752
3770
  ...deployedOrigins.map((o) => `${o}/oauth/logout`),
3771
+ ...additionalHttpsOrigins.map((o) => `${o}/oauth/logout`),
3753
3772
  ...localhostLogouts
3754
3773
  ]
3755
3774
  };