@infoxchange/make-it-so 2.11.0-internal-testing-vdt-199-add-auth-token-verify-function-2.6 → 2.11.0-internal-testing-vdt-199-add-auth-token-verify-function-2.7

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cdk-constructs/SiteOidcAuth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,UAAU,MAAM,4BAA4B,CAAC;AACpD,OAAO,GAAG,MAAM,aAAa,CAAC;AAE9B,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AAOtC,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,2BAA2B,CAAC;AAEnC,KAAK,cAAc,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACjE,KAAK,WAAW,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9D,MAAM,MAAM,KAAK,GAAG;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,MAAM,MAAM,cAAc,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAIjD,qBAAa,YAAa,SAAQ,SAAS;IACzC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;gBAER,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK;IAQhE,oBAAoB,CAAC,SAAS,SAAS,uBAAuB,EAC5D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,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAIjD,qBAAa,YAAa,SAAQ,SAAS;IACzC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;gBAER,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK;IAQhE,oBAAoB,CAAC,SAAS,SAAS,uBAAuB,EAC5D,KAAK,EAAE,cAAc,EACrB,SAAS,EAAE,SAAS,EACpB,EAAE,MAA+B,EAAE,GAAE,cAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4C1D,iBAAiB,CAAC,SAAS,SAAS,uBAAuB,EACzD,KAAK,EAAE,cAAc,EACrB,SAAS,EAAE,SAAS,EACpB,EAAE,MAA+B,EAAE,GAAE,cAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAuC1D,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,sBAAsB;IAgC9B,OAAO,CAAC,2BAA2B;IAoBnC,OAAO,CAAC,yCAAyC;IAiBjD,OAAO,CAAC,sBAAsB;CAkF/B"}
@@ -72,7 +72,7 @@ export class SiteOidcAuth extends Construct {
72
72
  const jwtSecret = this.createJwtSecret();
73
73
  updatedSiteProps.cdk.transform = (plan) => {
74
74
  siteProps?.cdk?.transform?.(plan);
75
- plan.cloudFrontFunctions?.serverCfFunction.injections.push(this.getAuthCheckHandlerBodyCode(jwtSecret, prefix));
75
+ plan.cloudFrontFunctions?.serverCfFunction.injections.push(this.convertToCloudFrontFunctionCompatibleCode(this.getAuthCheckHandlerBodyCode(jwtSecret, prefix)));
76
76
  };
77
77
  updatedSiteProps.cdk.distribution.additionalBehaviors[behaviourName] =
78
78
  this.getAuthBehaviorOptions(scope, jwtSecret, prefix);
@@ -100,7 +100,7 @@ export class SiteOidcAuth extends Construct {
100
100
  var request = event.request;
101
101
  ${this.getAuthCheckHandlerBodyCode(jwtSecret, authRoutePrefix)}
102
102
  return request;
103
- }`)),
103
+ }`, { minify: true })),
104
104
  // We could specify the JS v2.0 runtime here but for SSR sites SST does the function creation and that currently
105
105
  // uses JS v1.0 so no point using v2.0 here as the code has to be compatible with v1.0 anyway.
106
106
  });
@@ -120,7 +120,7 @@ export class SiteOidcAuth extends Construct {
120
120
  // remove it here.
121
121
  .replace(/export {};\s*$/g, "");
122
122
  }
123
- convertToCloudFrontFunctionCompatibleCode(sourceCode) {
123
+ convertToCloudFrontFunctionCompatibleCode(sourceCode, esbuildOptions) {
124
124
  // ESBuild doesn't currently support transforming const/let to var, which is required for CloudFront Functions
125
125
  // JS runtime 1.0.
126
126
  sourceCode = sourceCode
@@ -128,8 +128,8 @@ export class SiteOidcAuth extends Construct {
128
128
  .replaceAll(/let /g, "var ");
129
129
  console.log("---- 3", sourceCode);
130
130
  return transformSync(sourceCode, {
131
- minify: true,
132
131
  target: "es5",
132
+ ...esbuildOptions,
133
133
  }).code;
134
134
  }
135
135
  // Get the behavior options for the auth route
@@ -161,7 +161,7 @@ export class SiteOidcAuth extends Construct {
161
161
  const request = event.request;
162
162
  request.headers["x-forwarded-host"] = { value: request.headers.host.value };
163
163
  return request;
164
- }`)),
164
+ }`, { minify: true })),
165
165
  runtime: CloudFront.FunctionRuntime.JS_2_0,
166
166
  });
167
167
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infoxchange/make-it-so",
3
- "version": "2.11.0-internal-testing-vdt-199-add-auth-token-verify-function-2.6",
3
+ "version": "2.11.0-internal-testing-vdt-199-add-auth-token-verify-function-2.7",
4
4
  "description": "Makes deploying services to IX infra easy",
5
5
  "repository": "github:infoxchange/make-it-so",
6
6
  "type": "module",
@@ -9,7 +9,7 @@ import { Config as SSTInternalConfig } from "sst/config.js";
9
9
  import CloudFrontOrigins from "aws-cdk-lib/aws-cloudfront-origins";
10
10
  import path from "node:path";
11
11
  import fs from "node:fs";
12
- import { transformSync } from "esbuild";
12
+ import { TransformOptions, transformSync } from "esbuild";
13
13
  import type {
14
14
  ExtendedNextjsSiteProps,
15
15
  ExtendedStaticSiteProps,
@@ -118,7 +118,9 @@ export class SiteOidcAuth extends Construct {
118
118
  siteProps?.cdk?.transform?.(plan);
119
119
 
120
120
  plan.cloudFrontFunctions?.serverCfFunction.injections.push(
121
- this.getAuthCheckHandlerBodyCode(jwtSecret, prefix),
121
+ this.convertToCloudFrontFunctionCompatibleCode(
122
+ this.getAuthCheckHandlerBodyCode(jwtSecret, prefix),
123
+ ),
122
124
  );
123
125
  };
124
126
 
@@ -161,6 +163,7 @@ export class SiteOidcAuth extends Construct {
161
163
  ${this.getAuthCheckHandlerBodyCode(jwtSecret, authRoutePrefix)}
162
164
  return request;
163
165
  }`,
166
+ { minify: true },
164
167
  ),
165
168
  ),
166
169
  // We could specify the JS v2.0 runtime here but for SSR sites SST does the function creation and that currently
@@ -197,6 +200,7 @@ export class SiteOidcAuth extends Construct {
197
200
 
198
201
  private convertToCloudFrontFunctionCompatibleCode(
199
202
  sourceCode: string,
203
+ esbuildOptions?: TransformOptions,
200
204
  ): string {
201
205
  // ESBuild doesn't currently support transforming const/let to var, which is required for CloudFront Functions
202
206
  // JS runtime 1.0.
@@ -205,8 +209,8 @@ export class SiteOidcAuth extends Construct {
205
209
  .replaceAll(/let /g, "var ");
206
210
  console.log("---- 3", sourceCode)
207
211
  return transformSync(sourceCode, {
208
- minify: true,
209
212
  target: "es5",
213
+ ...esbuildOptions,
210
214
  }).code;
211
215
  }
212
216
 
@@ -255,6 +259,7 @@ export class SiteOidcAuth extends Construct {
255
259
  request.headers["x-forwarded-host"] = { value: request.headers.host.value };
256
260
  return request;
257
261
  }`,
262
+ { minify: true },
258
263
  ),
259
264
  ),
260
265
  runtime: CloudFront.FunctionRuntime.JS_2_0,