@awsless/cli 0.0.44 → 0.0.45
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/app.json +1 -1
- package/dist/app.stage.json +1 -1
- package/dist/bin.js +68 -1
- package/dist/build-json-schema.js +16 -0
- package/dist/prebuild/icon/bundle.zip +0 -0
- package/dist/prebuild/image/bundle.zip +0 -0
- package/dist/prebuild/on-error-log/bundle.zip +0 -0
- package/dist/prebuild/on-failure/bundle.zip +0 -0
- package/dist/prebuild/pubsub-publisher/bundle.zip +0 -0
- package/dist/prebuild/rpc/bundle.zip +0 -0
- package/package.json +9 -9
package/dist/bin.js
CHANGED
|
@@ -1666,6 +1666,7 @@ var RouterDefaultSchema = z21.record(
|
|
|
1666
1666
|
z21.object({
|
|
1667
1667
|
domain: ResourceIdSchema.describe("The domain id to link your Router.").optional(),
|
|
1668
1668
|
subDomain: z21.string().optional(),
|
|
1669
|
+
redirectWww: z21.boolean().default(false).describe("Redirect all www subdomain requests to your root domain."),
|
|
1669
1670
|
waf: WafSettingsSchema.optional(),
|
|
1670
1671
|
geoRestrictions: z21.array(z21.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked."),
|
|
1671
1672
|
errors: z21.object({
|
|
@@ -1754,6 +1755,21 @@ var RouterDefaultSchema = z21.record(
|
|
|
1754
1755
|
}).optional().describe(
|
|
1755
1756
|
"Specifies the cookies, headers, and query values that CloudFront includes in the cache key."
|
|
1756
1757
|
)
|
|
1758
|
+
}).superRefine((props, ctx) => {
|
|
1759
|
+
if (props.redirectWww && !props.domain) {
|
|
1760
|
+
ctx.addIssue({
|
|
1761
|
+
code: z21.ZodIssueCode.custom,
|
|
1762
|
+
path: ["redirectWww"],
|
|
1763
|
+
message: "The redirectWww option requires a domain to be set."
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
if (props.redirectWww && props.subDomain) {
|
|
1767
|
+
ctx.addIssue({
|
|
1768
|
+
code: z21.ZodIssueCode.custom,
|
|
1769
|
+
path: ["redirectWww"],
|
|
1770
|
+
message: `The redirectWww option can't be combined with a subDomain, because the domain certificate only covers single level subdomains.`
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1757
1773
|
})
|
|
1758
1774
|
).optional().describe(`Define the global Router. Backed by AWS CloudFront.`);
|
|
1759
1775
|
|
|
@@ -9165,6 +9181,7 @@ import { camelCase as camelCase9, constantCase as constantCase16, kebabCase as k
|
|
|
9165
9181
|
var getViewerRequestFunctionCode = (props) => {
|
|
9166
9182
|
return CODE([
|
|
9167
9183
|
props.blockDirectAccess ? BLOCK_DIRECT_ACCESS_TO_CLOUDFRONT : "",
|
|
9184
|
+
props.redirectWww ? REDIRECT_WWW : "",
|
|
9168
9185
|
props.passwordAuth ?? props.basicAuth ? AUTH_WRAPPER(
|
|
9169
9186
|
[
|
|
9170
9187
|
//
|
|
@@ -9181,6 +9198,38 @@ if (headers.host && headers.host.value.includes('cloudfront.net')) {
|
|
|
9181
9198
|
statusDescription: 'Forbidden'
|
|
9182
9199
|
};
|
|
9183
9200
|
}`;
|
|
9201
|
+
var REDIRECT_WWW = `
|
|
9202
|
+
if (headers.host && headers.host.value.startsWith('www.')) {
|
|
9203
|
+
let location = 'https://' + headers.host.value.slice(4) + request.uri;
|
|
9204
|
+
const query = [];
|
|
9205
|
+
|
|
9206
|
+
for(const key in request.querystring) {
|
|
9207
|
+
const item = request.querystring[key];
|
|
9208
|
+
|
|
9209
|
+
if(item.multiValue) {
|
|
9210
|
+
for(const i in item.multiValue) {
|
|
9211
|
+
query.push(key + '=' + item.multiValue[i].value);
|
|
9212
|
+
}
|
|
9213
|
+
} else if(item.value === '') {
|
|
9214
|
+
query.push(key);
|
|
9215
|
+
} else {
|
|
9216
|
+
query.push(key + '=' + item.value);
|
|
9217
|
+
}
|
|
9218
|
+
}
|
|
9219
|
+
|
|
9220
|
+
if(query.length > 0) {
|
|
9221
|
+
location += '?' + query.join('&');
|
|
9222
|
+
}
|
|
9223
|
+
|
|
9224
|
+
return {
|
|
9225
|
+
statusCode: 301,
|
|
9226
|
+
statusDescription: 'Moved Permanently',
|
|
9227
|
+
headers: {
|
|
9228
|
+
'location': { value: location },
|
|
9229
|
+
'strict-transport-security': { value: 'max-age=31536000; includeSubdomains; preload' }
|
|
9230
|
+
}
|
|
9231
|
+
};
|
|
9232
|
+
}`;
|
|
9184
9233
|
var BASIC_AUTH_CHECK = (username, password) => `
|
|
9185
9234
|
authMethods.push('Basic realm="Protected"');
|
|
9186
9235
|
|
|
@@ -9631,6 +9680,7 @@ var routerFeature = defineFeature({
|
|
|
9631
9680
|
keyValueStoreAssociations: [routeStore.arn],
|
|
9632
9681
|
code: getViewerRequestFunctionCode({
|
|
9633
9682
|
blockDirectAccess: !!props.domain,
|
|
9683
|
+
redirectWww: !!props.domain && props.redirectWww,
|
|
9634
9684
|
basicAuth: props.basicAuth,
|
|
9635
9685
|
passwordAuth: props.passwordAuth
|
|
9636
9686
|
})
|
|
@@ -9860,6 +9910,7 @@ var routerFeature = defineFeature({
|
|
|
9860
9910
|
});
|
|
9861
9911
|
if (props.domain) {
|
|
9862
9912
|
const domainName = formatFullDomainName(ctx.appConfig, props.domain, props.subDomain);
|
|
9913
|
+
const wwwDomainName = props.redirectWww ? `www.${domainName}` : void 0;
|
|
9863
9914
|
const certificateArn = ctx.shared.entry("domain", `global-certificate-arn`, props.domain);
|
|
9864
9915
|
const zoneId = ctx.shared.entry("domain", "zone-id", props.domain);
|
|
9865
9916
|
const connectionGroup = new aws32.cloudfront.ConnectionGroup(group, "connection-group", {
|
|
@@ -9870,7 +9921,11 @@ var routerFeature = defineFeature({
|
|
|
9870
9921
|
enabled: true,
|
|
9871
9922
|
distributionId: distribution.id,
|
|
9872
9923
|
connectionGroupId: connectionGroup.id,
|
|
9873
|
-
domain: [
|
|
9924
|
+
domain: [
|
|
9925
|
+
//
|
|
9926
|
+
{ domain: domainName },
|
|
9927
|
+
...wwwDomainName ? [{ domain: wwwDomainName }] : []
|
|
9928
|
+
],
|
|
9874
9929
|
customizations: [{ certificate: [{ arn: certificateArn }] }]
|
|
9875
9930
|
});
|
|
9876
9931
|
new aws32.route53.Record(group, `record`, {
|
|
@@ -9883,6 +9938,18 @@ var routerFeature = defineFeature({
|
|
|
9883
9938
|
evaluateTargetHealth: false
|
|
9884
9939
|
}
|
|
9885
9940
|
});
|
|
9941
|
+
if (wwwDomainName) {
|
|
9942
|
+
new aws32.route53.Record(group, `www-record`, {
|
|
9943
|
+
zoneId,
|
|
9944
|
+
type: "A",
|
|
9945
|
+
name: wwwDomainName,
|
|
9946
|
+
alias: {
|
|
9947
|
+
name: connectionGroup.routingEndpoint,
|
|
9948
|
+
zoneId: "Z2FDTNDATAQYW2",
|
|
9949
|
+
evaluateTargetHealth: false
|
|
9950
|
+
}
|
|
9951
|
+
});
|
|
9952
|
+
}
|
|
9886
9953
|
ctx.bind(`ROUTER_${constantCase16(id)}_ENDPOINT`, domainName);
|
|
9887
9954
|
}
|
|
9888
9955
|
}
|
|
@@ -724,6 +724,7 @@ var RouterDefaultSchema = z17.record(
|
|
|
724
724
|
z17.object({
|
|
725
725
|
domain: ResourceIdSchema.describe("The domain id to link your Router.").optional(),
|
|
726
726
|
subDomain: z17.string().optional(),
|
|
727
|
+
redirectWww: z17.boolean().default(false).describe("Redirect all www subdomain requests to your root domain."),
|
|
727
728
|
waf: WafSettingsSchema.optional(),
|
|
728
729
|
geoRestrictions: z17.array(z17.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked."),
|
|
729
730
|
errors: z17.object({
|
|
@@ -812,6 +813,21 @@ var RouterDefaultSchema = z17.record(
|
|
|
812
813
|
}).optional().describe(
|
|
813
814
|
"Specifies the cookies, headers, and query values that CloudFront includes in the cache key."
|
|
814
815
|
)
|
|
816
|
+
}).superRefine((props, ctx) => {
|
|
817
|
+
if (props.redirectWww && !props.domain) {
|
|
818
|
+
ctx.addIssue({
|
|
819
|
+
code: z17.ZodIssueCode.custom,
|
|
820
|
+
path: ["redirectWww"],
|
|
821
|
+
message: "The redirectWww option requires a domain to be set."
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
if (props.redirectWww && props.subDomain) {
|
|
825
|
+
ctx.addIssue({
|
|
826
|
+
code: z17.ZodIssueCode.custom,
|
|
827
|
+
path: ["redirectWww"],
|
|
828
|
+
message: `The redirectWww option can't be combined with a subDomain, because the domain certificate only covers single level subdomains.`
|
|
829
|
+
});
|
|
830
|
+
}
|
|
815
831
|
})
|
|
816
832
|
).optional().describe(`Define the global Router. Backed by AWS CloudFront.`);
|
|
817
833
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.45",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -90,22 +90,22 @@
|
|
|
90
90
|
"zod-to-json-schema": "^3.24.3",
|
|
91
91
|
"@awsless/big-float": "^0.1.7",
|
|
92
92
|
"@awsless/dynamodb": "^0.3.22",
|
|
93
|
-
"@awsless/duration": "^0.0.4",
|
|
94
|
-
"@awsless/json": "^0.0.11",
|
|
95
93
|
"@awsless/lambda": "^0.0.44",
|
|
96
94
|
"@awsless/redis": "^0.1.13",
|
|
95
|
+
"@awsless/clui": "^0.0.8",
|
|
96
|
+
"@awsless/duration": "^0.0.4",
|
|
97
|
+
"@awsless/iot": "^0.0.5",
|
|
97
98
|
"@awsless/s3": "^0.0.21",
|
|
98
|
-
"@awsless/
|
|
99
|
+
"@awsless/json": "^0.0.11",
|
|
99
100
|
"@awsless/size": "^0.0.2",
|
|
100
101
|
"@awsless/sns": "^0.0.10",
|
|
101
|
-
"@awsless/clui": "^0.0.8",
|
|
102
|
-
"@awsless/scheduler": "^0.0.4",
|
|
103
102
|
"@awsless/validate": "^0.1.7",
|
|
104
103
|
"@awsless/weak-cache": "^0.0.1",
|
|
105
|
-
"awsless": "^0.0.
|
|
106
|
-
"@awsless/
|
|
104
|
+
"@awsless/cloudwatch": "^0.0.1",
|
|
105
|
+
"@awsless/scheduler": "^0.0.4",
|
|
107
106
|
"@awsless/ts-file-cache": "^0.0.16",
|
|
108
|
-
"@awsless/sqs": "^0.0.24"
|
|
107
|
+
"@awsless/sqs": "^0.0.24",
|
|
108
|
+
"awsless": "^0.0.14"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
111
|
"@hono/node-server": "1.19.9",
|