@awsless/awsless 0.0.651 → 0.0.652

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
@@ -1576,10 +1576,13 @@ var RouterDefaultSchema = z23.record(
1576
1576
  origins: z23.string().array().default(["*"]),
1577
1577
  methods: z23.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
1578
1578
  }).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."),
1579
1582
  basicAuth: z23.object({
1580
1583
  username: z23.string().describe("Basic auth username."),
1581
1584
  password: z23.string().describe("Basic auth password.")
1582
- }).optional().describe("Enable basic authentication for the site."),
1585
+ }).optional().describe("Enable basic authentication for the router."),
1583
1586
  // security: z
1584
1587
  // .object({
1585
1588
  // contentSecurityPolicy: z.object({
@@ -7388,7 +7391,13 @@ import { camelCase as camelCase8, constantCase as constantCase14 } from "change-
7388
7391
  var getViewerRequestFunctionCode = (props) => {
7389
7392
  return CODE([
7390
7393
  props.blockDirectAccess ? BLOCK_DIRECT_ACCESS_TO_CLOUDFRONT : "",
7391
- props.basicAuth ? BASIC_AUTH_CHECK(props.basicAuth.username, props.basicAuth.password) : ""
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
+ ) : ""
7392
7401
  ]);
7393
7402
  };
7394
7403
  var BLOCK_DIRECT_ACCESS_TO_CLOUDFRONT = `
@@ -7399,13 +7408,36 @@ if (headers.host && headers.host.value.includes('cloudfront.net')) {
7399
7408
  };
7400
7409
  }`;
7401
7410
  var BASIC_AUTH_CHECK = (username, password) => `
7402
- const auth = headers.authorization && headers.authorization.value;
7403
- if (!auth || !auth.startsWith('Basic ') || auth.slice(6) !== '${Buffer.from(`${username}:${password}`).toString("base64")}') {
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) {
7404
7436
  return {
7405
7437
  statusCode: 401,
7406
7438
  headers: {
7407
7439
  'www-authenticate': {
7408
- value: 'Basic realm="Protected"'
7440
+ value: authMethods.join(', ')
7409
7441
  }
7410
7442
  }
7411
7443
  };
@@ -7724,7 +7756,8 @@ var routerFeature = defineFeature({
7724
7756
  keyValueStoreAssociations: [routeStore.arn],
7725
7757
  code: getViewerRequestFunctionCode({
7726
7758
  blockDirectAccess: !!props.domain,
7727
- basicAuth: props.basicAuth
7759
+ basicAuth: props.basicAuth,
7760
+ passwordAuth: props.passwordAuth
7728
7761
  })
7729
7762
  });
7730
7763
  const wafSettingsConfig = props.waf;
@@ -638,10 +638,13 @@ var RouterDefaultSchema = z19.record(
638
638
  origins: z19.string().array().default(["*"]),
639
639
  methods: z19.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
640
640
  }).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."),
641
644
  basicAuth: z19.object({
642
645
  username: z19.string().describe("Basic auth username."),
643
646
  password: z19.string().describe("Basic auth password.")
644
- }).optional().describe("Enable basic authentication for the site."),
647
+ }).optional().describe("Enable basic authentication for the router."),
645
648
  // security: z
646
649
  // .object({
647
650
  // contentSecurityPolicy: z.object({
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.651",
3
+ "version": "0.0.652",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -33,23 +33,23 @@
33
33
  ]
34
34
  },
35
35
  "peerDependencies": {
36
- "@awsless/big-float": "^0.1.6",
37
36
  "@awsless/clui": "^0.0.8",
38
- "@awsless/cloudwatch": "^0.0.1",
39
37
  "@awsless/duration": "^0.0.4",
40
- "@awsless/json": "^0.0.11",
38
+ "@awsless/cloudwatch": "^0.0.1",
41
39
  "@awsless/dynamodb": "^0.3.19",
42
40
  "@awsless/iot": "^0.0.3",
41
+ "@awsless/json": "^0.0.11",
42
+ "@awsless/lambda": "^0.0.41",
43
+ "@awsless/big-float": "^0.1.6",
43
44
  "@awsless/mqtt": "^0.0.2",
44
- "@awsless/open-search": "^0.0.21",
45
- "@awsless/redis": "^0.0.14",
45
+ "@awsless/s3": "^0.0.21",
46
46
  "@awsless/sns": "^0.0.10",
47
- "@awsless/lambda": "^0.0.41",
47
+ "@awsless/redis": "^0.0.14",
48
+ "@awsless/open-search": "^0.0.21",
49
+ "@awsless/sqs": "^0.0.16",
48
50
  "@awsless/validate": "^0.1.6",
49
- "@awsless/s3": "^0.0.21",
50
- "@awsless/weak-cache": "^0.0.1",
51
51
  "@awsless/ssm": "^0.0.7",
52
- "@awsless/sqs": "^0.0.16"
52
+ "@awsless/weak-cache": "^0.0.1"
53
53
  },
54
54
  "dependencies": {
55
55
  "@aws-sdk/client-cloudformation": "^3.369.0",
@@ -120,9 +120,9 @@
120
120
  "@awsless/duration": "^0.0.4",
121
121
  "@awsless/json": "^0.0.11",
122
122
  "@awsless/scheduler": "^0.0.4",
123
- "@awsless/size": "^0.0.2",
124
123
  "@awsless/ts-file-cache": "^0.0.12",
125
- "@awsless/validate": "^0.1.6"
124
+ "@awsless/validate": "^0.1.6",
125
+ "@awsless/size": "^0.0.2"
126
126
  },
127
127
  "devDependencies": {
128
128
  "@hono/node-server": "1.19.9",