@awsless/awsless 0.0.404 → 0.0.405

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/README.MD CHANGED
@@ -186,7 +186,7 @@ We use AWS SNS to provide serverless pubsub topics.
186
186
  }
187
187
  ```
188
188
 
189
- ## Realtime
189
+ ## Pubsub
190
190
 
191
191
  We use AWS IoT to provide a serverless mqtt pubsub channel.
192
192
 
package/dist/bin.js CHANGED
@@ -7413,7 +7413,7 @@ var line = (message) => {
7413
7413
  };
7414
7414
  var table = (props) => {
7415
7415
  console.log(color.line("\u2502"));
7416
- const table3 = new Table({
7416
+ const table2 = new Table({
7417
7417
  // wordWrap: true,
7418
7418
  // wrapOnWordBoundary: false,
7419
7419
  // truncate: '...',
@@ -7436,7 +7436,7 @@ var table = (props) => {
7436
7436
  // 'right-mid': '',
7437
7437
  }
7438
7438
  });
7439
- table3.push(
7439
+ table2.push(
7440
7440
  ...props.body.map(
7441
7441
  (row) => row.map((v) => {
7442
7442
  if (typeof v === "boolean") {
@@ -7446,7 +7446,7 @@ var table = (props) => {
7446
7446
  })
7447
7447
  )
7448
7448
  );
7449
- return table3.toString();
7449
+ return table2.toString();
7450
7450
  };
7451
7451
 
7452
7452
  // src/cli/ui/complex/bootstrap-awsless.ts
@@ -7512,12 +7512,12 @@ var createStateBucket = (client, accountId) => {
7512
7512
  var bootstrapAwsless = async (props) => {
7513
7513
  const dynamo = new DynamoDB(props);
7514
7514
  const s3 = new S3Client(props);
7515
- const [table3, bucket] = await Promise.all([
7515
+ const [table2, bucket] = await Promise.all([
7516
7516
  //
7517
7517
  hasLockTable(dynamo),
7518
7518
  hasStateBucket(s3, props.accountId)
7519
7519
  ]);
7520
- if (!table3 || !bucket) {
7520
+ if (!table2 || !bucket) {
7521
7521
  log.warn(`Awsless hasn't been bootstrapped yet.`);
7522
7522
  if (!process.env.SKIP_PROMPT) {
7523
7523
  const confirmed = await confirm({
@@ -7528,7 +7528,7 @@ var bootstrapAwsless = async (props) => {
7528
7528
  }
7529
7529
  }
7530
7530
  await task("Bootstrapping", async (update) => {
7531
- if (!table3) {
7531
+ if (!table2) {
7532
7532
  await createLockTable(dynamo);
7533
7533
  }
7534
7534
  if (!bucket) {
@@ -12302,7 +12302,7 @@ var pubsubFeature = defineFeature({
12302
12302
  });
12303
12303
  if (props.domain) {
12304
12304
  const domainName = formatFullDomainName(ctx.appConfig, props.domain, props.subDomain);
12305
- new aws13.iot.DomainConfiguration(group, "domain", {
12305
+ const domain = new aws13.iot.DomainConfiguration(group, "domain", {
12306
12306
  name,
12307
12307
  domainName,
12308
12308
  certificates: [ctx.shared.get(`local-certificate-${props.domain}-arn`)],
@@ -12311,6 +12311,7 @@ var pubsubFeature = defineFeature({
12311
12311
  }
12312
12312
  // validationCertificate: ctx.shared.get(`global-certificate-${props.domain}-arn`),
12313
12313
  });
12314
+ domain.dependsOn(authorizer);
12314
12315
  new aws13.route53.RecordSet(group, "record", {
12315
12316
  hostedZoneId: ctx.shared.get(`hosted-zone-${props.domain}-id`),
12316
12317
  name: domainName,
@@ -13378,14 +13379,14 @@ var tableFeature = defineFeature({
13378
13379
  resourceName: id
13379
13380
  });
13380
13381
  const deletionProtection = props.deletionProtection ?? ctx.appConfig.defaults.table?.deletionProtection;
13381
- const table3 = new aws22.dynamodb.Table(group, "table", {
13382
+ const table2 = new aws22.dynamodb.Table(group, "table", {
13382
13383
  ...props,
13383
13384
  name,
13384
13385
  stream: props.stream?.type,
13385
13386
  deletionProtection
13386
13387
  });
13387
13388
  if (deletionProtection) {
13388
- table3.deletionPolicy = "retain";
13389
+ table2.deletionPolicy = "retain";
13389
13390
  }
13390
13391
  if (props.stream) {
13391
13392
  const { lambda, policy } = createLambdaFunction(group, ctx, "table", id, props.stream.consumer);
@@ -13393,7 +13394,7 @@ var tableFeature = defineFeature({
13393
13394
  const onFailure = getGlobalOnFailure(ctx);
13394
13395
  const source = new aws22.lambda.EventSourceMapping(group, id, {
13395
13396
  functionArn: lambda.arn,
13396
- sourceArn: table3.streamArn,
13397
+ sourceArn: table2.streamArn,
13397
13398
  batchSize: 100,
13398
13399
  bisectBatchOnError: true,
13399
13400
  // retryAttempts: props.stream.consumer.retryAttempts ?? -1,
@@ -13401,7 +13402,7 @@ var tableFeature = defineFeature({
13401
13402
  startingPosition: "latest",
13402
13403
  onFailure
13403
13404
  });
13404
- policy.addStatement(table3.streamPermissions);
13405
+ policy.addStatement(table2.streamPermissions);
13405
13406
  source.dependsOn(policy);
13406
13407
  if (onFailure) {
13407
13408
  policy.addStatement({
@@ -13411,7 +13412,7 @@ var tableFeature = defineFeature({
13411
13412
  }
13412
13413
  }
13413
13414
  ctx.onStackPolicy((policy) => {
13414
- policy.addStatement(...table3.permissions);
13415
+ policy.addStatement(...table2.permissions);
13415
13416
  });
13416
13417
  }
13417
13418
  }
@@ -13660,12 +13661,12 @@ var vpcFeature = defineFeature({
13660
13661
  const zones = ["a", "b"];
13661
13662
  const tables = [privateRouteTable, publicRouteTable];
13662
13663
  let block = 0n;
13663
- for (const table3 of tables) {
13664
+ for (const table2 of tables) {
13664
13665
  for (const i in zones) {
13665
13666
  const index = Number(i) + 1;
13666
- const id = `${table3.identifier}-${index}`;
13667
+ const id = `${table2.identifier}-${index}`;
13667
13668
  const subnet = new aws24.ec2.Subnet(group, id, {
13668
- name: `${ctx.app.name}--${table3.identifier}-${index}`,
13669
+ name: `${ctx.app.name}--${table2.identifier}-${index}`,
13669
13670
  vpcId: vpc.id,
13670
13671
  cidrBlock: aws24.ec2.Peer.ipv4(`10.0.${block++}.0/24`),
13671
13672
  // ipv6CidrBlock: aws.ec2.Peer.ipv6(`fd00:10:20:${++block}::/64`),
@@ -13674,14 +13675,14 @@ var vpcFeature = defineFeature({
13674
13675
  // ipv6CidrBlock: slices.apply(list => aws.ec2.Peer.ipv6(list.get(block++).toString())),
13675
13676
  // assignIpv6AddressOnCreation: true,
13676
13677
  // ipv6Native: true,
13677
- mapPublicIpOnLaunch: table3.identifier === "public",
13678
+ mapPublicIpOnLaunch: table2.identifier === "public",
13678
13679
  availabilityZone: ctx.appConfig.region + zones[i]
13679
13680
  });
13680
13681
  new aws24.ec2.SubnetRouteTableAssociation(group, id, {
13681
- routeTableId: table3.id,
13682
+ routeTableId: table2.id,
13682
13683
  subnetId: subnet.id
13683
13684
  });
13684
- ctx.shared.set(`vpc-${table3.identifier}-subnet-id-${index}`, subnet.id);
13685
+ ctx.shared.set(`vpc-${table2.identifier}-subnet-id-${index}`, subnet.id);
13685
13686
  }
13686
13687
  }
13687
13688
  }
@@ -15112,7 +15113,6 @@ var list3 = (program2) => {
15112
15113
  const credentials = getCredentials(appConfig.profile);
15113
15114
  const accountId = await getAccountId(credentials, region);
15114
15115
  const { app } = createApp({ appConfig, stackConfigs, accountId });
15115
- const resources = [];
15116
15116
  const formatResource = (stack, urn) => {
15117
15117
  return urn.replace(stack.urn + ":", "").replace(/\{([a-z0-9\-\s\/\._]+)\}/gi, (_, v) => {
15118
15118
  return `${color.dim("{")}${color.warning(v)}${color.dim("}")}`;
Binary file
package/dist/server.js CHANGED
@@ -406,35 +406,45 @@ var pubsubAuthorizerResponse = (props) => {
406
406
  Resource: props.subscribe.map((topic) => {
407
407
  return `${prefix}:topicfilter/${getPubSubTopic(topic)}`;
408
408
  })
409
- },
410
- {
411
- Action: "iot:Receive",
412
- Effect: "Allow",
413
- Resource: props.subscribe.map((topic) => {
414
- return `${prefix}:topic/${getPubSubTopic(topic)}`;
415
- })
416
409
  }
410
+ // {
411
+ // Action: 'iot:Receive',
412
+ // Effect: 'Allow',
413
+ // Resource: props.subscribe.map(topic => {
414
+ // return `${prefix}:topic/${getPubSubTopic(topic)}`
415
+ // }),
416
+ // }
417
417
  );
418
418
  }
419
+ const policyDocuments = [
420
+ {
421
+ Version: "2012-10-17",
422
+ Statement: [
423
+ {
424
+ Action: "iot:Connect",
425
+ Effect: "Allow",
426
+ Resource: "*"
427
+ // Resource: `${prefix}:client/\${iot:ClientId}`,
428
+ },
429
+ {
430
+ Action: "iot:Receive",
431
+ Effect: "Allow",
432
+ Resource: "*"
433
+ // Resource: `${prefix}:client/\${iot:ClientId}`,
434
+ },
435
+ ...statements
436
+ ]
437
+ }
438
+ ];
439
+ if (JSON.stringify(policyDocuments).length > 2048) {
440
+ throw new Error("IoT Policy is too large");
441
+ }
419
442
  return {
420
443
  isAuthenticated: props.authorized,
421
444
  principalId: props.principalId ?? Date.now().toString(),
422
445
  disconnectAfterInSeconds: Number(toSeconds(props.disconnectAfter ?? hours(1))),
423
446
  refreshAfterInSeconds: Number(toSeconds(props.disconnectAfter ?? hours(1))),
424
- policyDocuments: [
425
- {
426
- Version: "2012-10-17",
427
- Statement: [
428
- {
429
- Action: "iot:Connect",
430
- Effect: "Allow",
431
- Resource: "*"
432
- // Resource: `${prefix}:client/\${iot:ClientId}`,
433
- },
434
- ...statements
435
- ]
436
- }
437
- ]
447
+ policyDocuments
438
448
  };
439
449
  };
440
450
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.404",
3
+ "version": "0.0.405",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -28,17 +28,17 @@
28
28
  }
29
29
  },
30
30
  "peerDependencies": {
31
- "@awsless/iot": "^0.0.2",
32
31
  "@awsless/lambda": "^0.0.27",
33
- "@awsless/mqtt": "^0.0.2",
34
32
  "@awsless/open-search": "^0.0.15",
35
- "@awsless/redis": "^0.0.13",
36
33
  "@awsless/sns": "^0.0.7",
37
- "@awsless/s3": "^0.0.18",
34
+ "@awsless/redis": "^0.0.13",
38
35
  "@awsless/sqs": "^0.0.7",
39
- "@awsless/ssm": "^0.0.7",
36
+ "@awsless/iot": "^0.0.2",
40
37
  "@awsless/validate": "^0.0.16",
41
- "@awsless/weak-cache": "^0.0.1"
38
+ "@awsless/ssm": "^0.0.7",
39
+ "@awsless/weak-cache": "^0.0.1",
40
+ "@awsless/s3": "^0.0.18",
41
+ "@awsless/mqtt": "^0.0.2"
42
42
  },
43
43
  "dependencies": {
44
44
  "@arcanyx/cidr-slicer": "^0.3.0",
@@ -113,12 +113,12 @@
113
113
  "zod": "^3.21.4",
114
114
  "zod-to-json-schema": "^3.22.3",
115
115
  "@awsless/code": "^0.0.10",
116
+ "@awsless/size": "^0.0.1",
117
+ "@awsless/validate": "^0.0.16",
116
118
  "@awsless/duration": "^0.0.1",
117
119
  "@awsless/formation": "^0.0.57",
118
- "@awsless/graphql": "^0.0.9",
119
120
  "@awsless/ts-file-cache": "^0.0.10",
120
- "@awsless/validate": "^0.0.16",
121
- "@awsless/size": "^0.0.1"
121
+ "@awsless/graphql": "^0.0.9"
122
122
  },
123
123
  "devDependencies": {
124
124
  "@node-rs/bcrypt": "^1.10.5"