@go-to-k/cdkd 0.137.0 → 0.137.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.
package/dist/cli.js CHANGED
@@ -41144,11 +41144,19 @@ function collectAuthRoutesForApi(apiLogicalId, template, _stackName) {
41144
41144
  const props = resource.Properties ?? {};
41145
41145
  if (pickRefLogicalId$2(props["ApiId"]) !== apiLogicalId) continue;
41146
41146
  const authType = props["AuthorizationType"];
41147
- if (typeof authType !== "string" || authType.length === 0) continue;
41148
- if (authType === "NONE") continue;
41147
+ if (authType === void 0) continue;
41149
41148
  const routeKey = props["RouteKey"];
41149
+ const routeKeyForReport = typeof routeKey === "string" ? routeKey : "<unknown>";
41150
+ if (typeof authType !== "string" || authType.length === 0) {
41151
+ result.push({
41152
+ routeKey: routeKeyForReport,
41153
+ authorizationType: "<intrinsic-or-malformed>"
41154
+ });
41155
+ continue;
41156
+ }
41157
+ if (authType === "NONE") continue;
41150
41158
  result.push({
41151
- routeKey: typeof routeKey === "string" ? routeKey : "<unknown>",
41159
+ routeKey: routeKeyForReport,
41152
41160
  authorizationType: authType
41153
41161
  });
41154
41162
  }
@@ -41506,6 +41514,24 @@ function parseConnectionsPath(url) {
41506
41514
  return { connectionId: decoded };
41507
41515
  }
41508
41516
  /**
41517
+ * Build the per-Lambda env-var URL the cdkd local server injects as
41518
+ * `AWS_ENDPOINT_URL_APIGATEWAYMANAGEMENTAPI`. The URL MUST include the
41519
+ * `/<stage>` segment to mirror the AWS-deployed apigatewaymanagementapi
41520
+ * endpoint `https://<api-id>.execute-api.<region>.amazonaws.com/<stage>`:
41521
+ * SDK clients built from `domainName + stage` produce
41522
+ * `POST /<stage>/@connections/<id>`, and the local `parseConnectionsPath`
41523
+ * regex above requires the matching prefix. Without `/<stage>` the
41524
+ * deployed-shape SDK call hits a 404 against the local parser
41525
+ * (BLOCKER B1, #526).
41526
+ *
41527
+ * Lives next to `parseConnectionsPath` so the producer + consumer of
41528
+ * the URL shape stay in lockstep — change one, the other's tests fail.
41529
+ * Issue #537 item 7.
41530
+ */
41531
+ function buildMgmtEndpointEnvUrl(host, port, stage) {
41532
+ return `http://${host}:${port}/${stage}`;
41533
+ }
41534
+ /**
41509
41535
  * `decodeURIComponent` throws `URIError` on malformed input
41510
41536
  * (`%`-escape with non-hex tail). We treat that as a not-found rather
41511
41537
  * than a server error — symmetric with AWS-deployed behavior, which
@@ -41632,6 +41658,38 @@ function writeJson(res, status, body) {
41632
41658
  res.end(json);
41633
41659
  }
41634
41660
 
41661
+ //#endregion
41662
+ //#region src/local/websocket-body.ts
41663
+ /**
41664
+ * Convert a ws-emitted message buffer into the AWS-canonical event
41665
+ * body + `isBase64Encoded` discriminator. Text frames (opcode 0x1) pass
41666
+ * through as UTF-8 with `isBase64Encoded: false`; binary frames
41667
+ * (opcode 0x2) are base64-encoded with `isBase64Encoded: true`. Matches
41668
+ * AWS-deployed WebSocket API event shape exactly — handlers decode via
41669
+ * `Buffer.from(event.body, event.isBase64Encoded ? 'base64' : 'utf8')`.
41670
+ *
41671
+ * Closes the data-integrity bug where every byte > 0x7F on a binary
41672
+ * frame was silently corrupted by handlers that trusted the previously
41673
+ * hardcoded `isBase64Encoded: false` flag and UTF-8-decoded the
41674
+ * base64-encoded body.
41675
+ *
41676
+ * Lives in its own module so the B4 regression test can install a
41677
+ * `vi.fn()` spy that intercepts EVERY call — same-module references in
41678
+ * `websocket-server.ts` would bypass the export-binding spy. See
41679
+ * Issue #537 item 6.
41680
+ */
41681
+ function bufferToBody(raw, isBinary) {
41682
+ const buf = Array.isArray(raw) ? Buffer.concat(raw) : Buffer.isBuffer(raw) ? raw : Buffer.from(raw);
41683
+ if (isBinary) return {
41684
+ body: buf.toString("base64"),
41685
+ isBase64Encoded: true
41686
+ };
41687
+ return {
41688
+ body: buf.toString("utf-8"),
41689
+ isBase64Encoded: false
41690
+ };
41691
+ }
41692
+
41635
41693
  //#endregion
41636
41694
  //#region src/local/websocket-server.ts
41637
41695
  /**
@@ -41719,7 +41777,7 @@ function attachWebSocketServer(opts) {
41719
41777
  if (preVerdictFrames.length >= MAX_PRE_VERDICT_FRAMES) {
41720
41778
  if (!preVerdictOverflow) {
41721
41779
  preVerdictOverflow = true;
41722
- logger.warn(`WebSocket connection ${connectionId}: pre-verdict message buffer overflowed (>${MAX_PRE_VERDICT_FRAMES} frames). Excess frames dropped — client is sending faster than the $connect handler can resolve.`);
41780
+ logger.warn(`WebSocket connection ${connectionId}: pre-verdict message buffer overflowed (>${MAX_PRE_VERDICT_FRAMES} frames). Excess frames dropped — client is sending faster than the $connect handler can resolve. (api=${cfg.api.declaredAt})`);
41723
41781
  }
41724
41782
  return;
41725
41783
  }
@@ -42015,30 +42073,6 @@ function safeDecode$1(s) {
42015
42073
  return null;
42016
42074
  }
42017
42075
  }
42018
- /**
42019
- * Convert a ws-emitted message buffer into the AWS-canonical event
42020
- * body + `isBase64Encoded` discriminator. Text frames (opcode 0x1) pass
42021
- * through as UTF-8 with `isBase64Encoded: false`; binary frames
42022
- * (opcode 0x2) are base64-encoded with `isBase64Encoded: true`. Matches
42023
- * AWS-deployed WebSocket API event shape exactly — handlers decode via
42024
- * `Buffer.from(event.body, event.isBase64Encoded ? 'base64' : 'utf8')`.
42025
- *
42026
- * Closes the data-integrity bug where every byte > 0x7F on a binary
42027
- * frame was silently corrupted by handlers that trusted the previously
42028
- * hardcoded `isBase64Encoded: false` flag and UTF-8-decoded the
42029
- * base64-encoded body.
42030
- */
42031
- function bufferToBody(raw, isBinary) {
42032
- const buf = Array.isArray(raw) ? Buffer.concat(raw) : Buffer.isBuffer(raw) ? raw : Buffer.from(raw);
42033
- if (isBinary) return {
42034
- body: buf.toString("base64"),
42035
- isBase64Encoded: true
42036
- };
42037
- return {
42038
- body: buf.toString("utf-8"),
42039
- isBase64Encoded: false
42040
- };
42041
- }
42042
42076
 
42043
42077
  //#endregion
42044
42078
  //#region src/local/vtl-engine.ts
@@ -48052,7 +48086,7 @@ async function localStartApiCommand(target, options) {
48052
48086
  }]
48053
48087
  });
48054
48088
  registryRef = attached;
48055
- const mgmtEndpoint = `http://host.docker.internal:${started.port}/${api.stage}`;
48089
+ const mgmtEndpoint = buildMgmtEndpointEnvUrl("host.docker.internal", started.port, api.stage);
48056
48090
  const hostGatewayMapping = [{
48057
48091
  host: "host.docker.internal",
48058
48092
  ip: "host-gateway"
@@ -53981,7 +54015,7 @@ function reorderArgs(argv) {
53981
54015
  */
53982
54016
  async function main() {
53983
54017
  const program = new Command();
53984
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.137.0");
54018
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.137.1");
53985
54019
  program.addCommand(createBootstrapCommand());
53986
54020
  program.addCommand(createSynthCommand());
53987
54021
  program.addCommand(createListCommand());