@awsless/awsless 0.0.652 → 0.0.654

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/bin.js CHANGED
@@ -1415,7 +1415,7 @@ var QueueDefaultSchema = z20.object({
1415
1415
  maxBatchingWindow: MaxBatchingWindow.optional()
1416
1416
  }).default({});
1417
1417
  var QueueSchema = z20.object({
1418
- consumer: FunctionSchema.describe("The consuming lambda function properties."),
1418
+ consumer: FunctionSchema.optional().describe("The consuming lambda function properties."),
1419
1419
  retentionPeriod: RetentionPeriodSchema.optional(),
1420
1420
  visibilityTimeout: VisibilityTimeoutSchema.optional(),
1421
1421
  deliveryDelay: DeliveryDelaySchema.optional(),
@@ -1431,8 +1431,7 @@ var QueuesSchema = z20.record(
1431
1431
  LocalFileSchema.transform((consumer) => ({
1432
1432
  consumer
1433
1433
  })).pipe(QueueSchema),
1434
- QueueSchema,
1435
- z20.literal(true)
1434
+ QueueSchema
1436
1435
  ])
1437
1436
  ).optional().describe("Define the queues in your stack.");
1438
1437
 
@@ -1576,13 +1575,10 @@ var RouterDefaultSchema = z23.record(
1576
1575
  origins: z23.string().array().default(["*"]),
1577
1576
  methods: z23.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
1578
1577
  }).optional().describe("Specify the cors headers."),
1579
- passwordAuth: z23.object({
1580
- password: z23.string().describe("Password.")
1581
- }).optional().describe("Enable password authentication for the router."),
1582
1578
  basicAuth: z23.object({
1583
1579
  username: z23.string().describe("Basic auth username."),
1584
1580
  password: z23.string().describe("Basic auth password.")
1585
- }).optional().describe("Enable basic authentication for the router."),
1581
+ }).optional().describe("Enable basic authentication for the site."),
1586
1582
  // security: z
1587
1583
  // .object({
1588
1584
  // contentSecurityPolicy: z.object({
@@ -4670,7 +4666,7 @@ var queueFeature = defineFeature({
4670
4666
  resourceType: "queue",
4671
4667
  resourceName: name
4672
4668
  });
4673
- if (typeof props === "object" && "file" in props.consumer.code) {
4669
+ if (typeof props === "object" && props.consumer && "file" in props.consumer.code) {
4674
4670
  const relFile = relative5(directories.types, props.consumer.code.file);
4675
4671
  gen.addImport(varName, relFile);
4676
4672
  mock.addType(name, `MockBuilder<typeof ${varName}>`);
@@ -4717,7 +4713,7 @@ var queueFeature = defineFeature({
4717
4713
  })
4718
4714
  )
4719
4715
  });
4720
- if (typeof local === "object") {
4716
+ if (local.consumer) {
4721
4717
  const lambdaConsumer = createLambdaFunction(group, ctx, `queue`, id, local.consumer);
4722
4718
  lambdaConsumer.setEnvironment("THROW_EXPECTED_ERRORS", "1");
4723
4719
  new aws11.lambda.EventSourceMapping(
@@ -7391,13 +7387,7 @@ import { camelCase as camelCase8, constantCase as constantCase14 } from "change-
7391
7387
  var getViewerRequestFunctionCode = (props) => {
7392
7388
  return CODE([
7393
7389
  props.blockDirectAccess ? BLOCK_DIRECT_ACCESS_TO_CLOUDFRONT : "",
7394
- props.passwordAuth ?? props.basicAuth ? AUTH_WRAPPER(
7395
- [
7396
- //
7397
- props.basicAuth ? BASIC_AUTH_CHECK(props.basicAuth.username, props.basicAuth.password) : "",
7398
- props.passwordAuth ? PASSWORD_AUTH_CHECK(props.passwordAuth.password) : ""
7399
- ].join("\n")
7400
- ) : ""
7390
+ props.basicAuth ? BASIC_AUTH_CHECK(props.basicAuth.username, props.basicAuth.password) : ""
7401
7391
  ]);
7402
7392
  };
7403
7393
  var BLOCK_DIRECT_ACCESS_TO_CLOUDFRONT = `
@@ -7408,36 +7398,13 @@ if (headers.host && headers.host.value.includes('cloudfront.net')) {
7408
7398
  };
7409
7399
  }`;
7410
7400
  var BASIC_AUTH_CHECK = (username, password) => `
7411
- authMethods.push('Basic realm="Protected"');
7412
-
7413
- if(!isAuthorized) {
7414
- if(authHeader && authHeader.startsWith('Basic ') && authHeader.slice(6) === '${Buffer.from(`${username}:${password}`).toString("base64")}') {
7415
- isAuthorized = true;
7416
- }
7417
- }
7418
- `;
7419
- var PASSWORD_AUTH_CHECK = (password) => `
7420
- authMethods.push('Password realm="Protected"');
7421
-
7422
- if(!isAuthorized) {
7423
- if(authHeader && authHeader.startsWith('Password ') && authHeader.slice(9) === '${password}') {
7424
- isAuthorized = true;
7425
- }
7426
- }
7427
- `;
7428
- var AUTH_WRAPPER = (code) => `
7429
- const authHeader = headers.authorization && headers.authorization.value;
7430
- const authMethods = [];
7431
- let isAuthorized = false;
7432
-
7433
- ${code}
7434
-
7435
- if (!isAuthorized) {
7401
+ const auth = headers.authorization && headers.authorization.value;
7402
+ if (!auth || !auth.startsWith('Basic ') || auth.slice(6) !== '${Buffer.from(`${username}:${password}`).toString("base64")}') {
7436
7403
  return {
7437
7404
  statusCode: 401,
7438
7405
  headers: {
7439
7406
  'www-authenticate': {
7440
- value: authMethods.join(', ')
7407
+ value: 'Basic realm="Protected"'
7441
7408
  }
7442
7409
  }
7443
7410
  };
@@ -7756,8 +7723,7 @@ var routerFeature = defineFeature({
7756
7723
  keyValueStoreAssociations: [routeStore.arn],
7757
7724
  code: getViewerRequestFunctionCode({
7758
7725
  blockDirectAccess: !!props.domain,
7759
- basicAuth: props.basicAuth,
7760
- passwordAuth: props.passwordAuth
7726
+ basicAuth: props.basicAuth
7761
7727
  })
7762
7728
  });
7763
7729
  const wafSettingsConfig = props.waf;
@@ -477,7 +477,7 @@ var QueueDefaultSchema = z16.object({
477
477
  maxBatchingWindow: MaxBatchingWindow.optional()
478
478
  }).default({});
479
479
  var QueueSchema = z16.object({
480
- consumer: FunctionSchema.describe("The consuming lambda function properties."),
480
+ consumer: FunctionSchema.optional().describe("The consuming lambda function properties."),
481
481
  retentionPeriod: RetentionPeriodSchema.optional(),
482
482
  visibilityTimeout: VisibilityTimeoutSchema.optional(),
483
483
  deliveryDelay: DeliveryDelaySchema.optional(),
@@ -493,8 +493,7 @@ var QueuesSchema = z16.record(
493
493
  LocalFileSchema.transform((consumer) => ({
494
494
  consumer
495
495
  })).pipe(QueueSchema),
496
- QueueSchema,
497
- z16.literal(true)
496
+ QueueSchema
498
497
  ])
499
498
  ).optional().describe("Define the queues in your stack.");
500
499
 
@@ -638,13 +637,10 @@ var RouterDefaultSchema = z19.record(
638
637
  origins: z19.string().array().default(["*"]),
639
638
  methods: z19.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
640
639
  }).optional().describe("Specify the cors headers."),
641
- passwordAuth: z19.object({
642
- password: z19.string().describe("Password.")
643
- }).optional().describe("Enable password authentication for the router."),
644
640
  basicAuth: z19.object({
645
641
  username: z19.string().describe("Basic auth username."),
646
642
  password: z19.string().describe("Basic auth password.")
647
- }).optional().describe("Enable basic authentication for the router."),
643
+ }).optional().describe("Enable basic authentication for the site."),
648
644
  // security: z
649
645
  // .object({
650
646
  // contentSecurityPolicy: z.object({
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _awsless_mqtt from '@awsless/mqtt';
2
- import { QoS } from '@awsless/mqtt';
2
+ import { DebugCallback, QoS } from '@awsless/mqtt';
3
3
 
4
4
  interface AuthResources {
5
5
  }
@@ -61,7 +61,7 @@ type ClientProps = {
61
61
  token?: string;
62
62
  };
63
63
  type ClientPropsProvider = () => Promise<ClientProps> | ClientProps;
64
- declare const createPubSubClient: (app: string | (() => string), props: ClientProps | ClientPropsProvider) => {
64
+ declare const createPubSubClient: (app: string | (() => string), props: ClientProps | ClientPropsProvider, debug?: DebugCallback) => {
65
65
  connected: boolean;
66
66
  topics: string[];
67
67
  publish(topic: string, event: string, payload: unknown, qos: QoS): Promise<void>;
package/dist/client.js CHANGED
@@ -80,7 +80,7 @@ var createHttpClient = (fetcher) => {
80
80
  // src/lib/client/pubsub.ts
81
81
  import { parse, stringify } from "@awsless/json";
82
82
  import { createClient } from "@awsless/mqtt";
83
- var createPubSubClient = (app, props) => {
83
+ var createPubSubClient = (app, props, debug) => {
84
84
  const mqtt = createClient(async () => {
85
85
  const config = typeof props === "function" ? await props() : props;
86
86
  return {
@@ -88,7 +88,7 @@ var createPubSubClient = (app, props) => {
88
88
  username: `?x-amz-customauthorizer-name=${config.authorizer}`,
89
89
  password: config.token
90
90
  };
91
- });
91
+ }, debug);
92
92
  const getApp = () => {
93
93
  return typeof app === "string" ? app : app();
94
94
  };
Binary file
@@ -1 +1 @@
1
- b58a7ef4004def1e70afcf61a14ffd52c86500e7
1
+ a8a0c621098150215b693d66e3304f6d4ae1db1b
Binary file
Binary file