@awsless/awsless 0.0.164 → 0.0.165

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
@@ -1764,47 +1764,50 @@ var authPlugin = definePlugin({
1764
1764
  gen.addInterface("AuthResources", resources);
1765
1765
  await write("auth.d.ts", gen, true);
1766
1766
  },
1767
- // onStack({ config, bootstrap, stackConfig, bind }) {
1768
- // for (const [id, props] of Object.entries(stackConfig.auth ?? {})) {
1769
- // if (props.access) {
1770
- // const userPoolId = bootstrap.import(`auth-${id}-user-pool-id`)
1771
- // const clientId = bootstrap.import(`auth-${id}-client-id`)
1772
- // const name = constantCase(id)
1773
- // bind(lambda => {
1774
- // lambda.addEnvironment(`AUTH_${name}_USER_POOL_ID`, userPoolId)
1775
- // lambda.addEnvironment(`AUTH_${name}_CLIENT_ID`, clientId)
1776
- // if (config.app.defaults.auth?.[id]?.secret) {
1777
- // const clientSecret = bootstrap.import(`auth-${id}-client-secret`)
1778
- // lambda.addEnvironment(`AUTH_${name}_CLIENT_SECRET`, clientSecret)
1779
- // }
1780
- // lambda.addPermissions({
1781
- // actions: ['cognito:*'],
1782
- // resources: ['*'],
1783
- // })
1784
- // })
1785
- // }
1786
- // }
1787
- // },
1788
- onStack({ config: config2, bootstrap: bootstrap2, bind: bind2 }) {
1789
- for (const [id, props] of Object.entries(config2.app.defaults.auth)) {
1790
- bind2((lambda) => {
1791
- const userPoolArn = bootstrap2.import(`auth-${id}-user-pool-arn`);
1767
+ onStack({ config: config2, bootstrap: bootstrap2, stackConfig, bind: bind2 }) {
1768
+ for (const [id, props] of Object.entries(stackConfig.auth ?? {})) {
1769
+ if (props.access) {
1792
1770
  const userPoolId = bootstrap2.import(`auth-${id}-user-pool-id`);
1793
1771
  const clientId = bootstrap2.import(`auth-${id}-client-id`);
1794
1772
  const name = constantCase6(id);
1795
- lambda.addEnvironment(`AUTH_${name}_USER_POOL_ID`, userPoolId);
1796
- lambda.addEnvironment(`AUTH_${name}_CLIENT_ID`, clientId);
1797
- if (props.secret) {
1798
- const clientSecret = bootstrap2.import(`auth-${id}-client-secret`);
1799
- lambda.addEnvironment(`AUTH_${name}_CLIENT_SECRET`, clientSecret);
1800
- }
1801
- lambda.addPermissions({
1802
- actions: ["cognito:*"],
1803
- resources: [userPoolArn]
1773
+ bind2((lambda) => {
1774
+ lambda.addEnvironment(`AUTH_${name}_USER_POOL_ID`, userPoolId);
1775
+ lambda.addEnvironment(`AUTH_${name}_CLIENT_ID`, clientId);
1776
+ if (config2.app.defaults.auth?.[id]?.secret) {
1777
+ const clientSecret = bootstrap2.import(`auth-${id}-client-secret`);
1778
+ lambda.addEnvironment(`AUTH_${name}_CLIENT_SECRET`, clientSecret);
1779
+ }
1780
+ lambda.addPermissions({
1781
+ actions: ["cognito:*"],
1782
+ resources: ["*"]
1783
+ });
1804
1784
  });
1805
- });
1785
+ }
1806
1786
  }
1807
1787
  },
1788
+ // onStack({ config, bootstrap, bind }) {
1789
+ // // Give access to every lambda function in our app to our cognito instance.
1790
+ // for (const [id, props] of Object.entries(config.app.defaults.auth)) {
1791
+ // bind(lambda => {
1792
+ // const userPoolArn = bootstrap.import(`auth-${id}-user-pool-arn`)
1793
+ // const userPoolId = bootstrap.import(`auth-${id}-user-pool-id`)
1794
+ // const clientId = bootstrap.import(`auth-${id}-client-id`)
1795
+ // const name = constantCase(id)
1796
+ // lambda.addEnvironment(`AUTH_${name}_USER_POOL_ID`, userPoolId)
1797
+ // lambda.addEnvironment(`AUTH_${name}_CLIENT_ID`, clientId)
1798
+ // // lambda.addEnvironment(`AWSLESS_PUBLIC_AUTH_${name}_USER_POOL_ID`, userPoolId)
1799
+ // // lambda.addEnvironment(`AWSLESS_PUBLIC_AUTH_${name}_CLIENT_ID`, clientId)
1800
+ // if (props.secret) {
1801
+ // const clientSecret = bootstrap.import(`auth-${id}-client-secret`)
1802
+ // lambda.addEnvironment(`AUTH_${name}_CLIENT_SECRET`, clientSecret)
1803
+ // }
1804
+ // lambda.addPermissions({
1805
+ // actions: ['cognito:*'],
1806
+ // resources: [userPoolArn],
1807
+ // })
1808
+ // })
1809
+ // }
1810
+ // },
1808
1811
  onApp(ctx) {
1809
1812
  const { config: config2, bootstrap: bootstrap2 } = ctx;
1810
1813
  if (Object.keys(config2.app.defaults.auth).length === 0) {
@@ -5921,10 +5924,7 @@ var TriggersSchema = z8.object({
5921
5924
  var AuthSchema = z8.record(
5922
5925
  ResourceIdSchema,
5923
5926
  z8.object({
5924
- // access: z
5925
- // .boolean()
5926
- // .default(false)
5927
- // .describe('Give access to every function in this stack to your cognito instance.'),
5927
+ access: z8.boolean().default(false).describe("Give access to every function in this stack to your cognito instance."),
5928
5928
  triggers: TriggersSchema.optional()
5929
5929
  })
5930
5930
  ).optional().describe("Define the auth triggers in your stack.");
package/dist/index.d.ts CHANGED
@@ -4180,6 +4180,7 @@ declare const StackSchema: z.ZodObject<{
4180
4180
  }[] | undefined;
4181
4181
  }>]>>;
4182
4182
  auth: z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodObject<{
4183
+ access: z.ZodDefault<z.ZodBoolean>;
4183
4184
  triggers: z.ZodOptional<z.ZodObject<{
4184
4185
  beforeToken: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, z.ZodObject<{
4185
4186
  file: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
@@ -5796,6 +5797,7 @@ declare const StackSchema: z.ZodObject<{
5796
5797
  } | undefined;
5797
5798
  }>>;
5798
5799
  }, "strip", z.ZodTypeAny, {
5800
+ access: boolean;
5799
5801
  triggers?: {
5800
5802
  beforeToken?: string | {
5801
5803
  file: string;
@@ -6078,6 +6080,7 @@ declare const StackSchema: z.ZodObject<{
6078
6080
  } | undefined;
6079
6081
  } | undefined;
6080
6082
  }, {
6083
+ access?: boolean | undefined;
6081
6084
  triggers?: {
6082
6085
  beforeToken?: string | {
6083
6086
  file: string;
@@ -9267,6 +9270,7 @@ declare const StackSchema: z.ZodObject<{
9267
9270
  }[] | undefined;
9268
9271
  } | undefined;
9269
9272
  auth?: Record<string, {
9273
+ access: boolean;
9270
9274
  triggers?: {
9271
9275
  beforeToken?: string | {
9272
9276
  file: string;
@@ -10206,6 +10210,7 @@ declare const StackSchema: z.ZodObject<{
10206
10210
  }[] | undefined;
10207
10211
  } | undefined;
10208
10212
  auth?: Record<string, {
10213
+ access?: boolean | undefined;
10209
10214
  triggers?: {
10210
10215
  beforeToken?: string | {
10211
10216
  file: string;
package/dist/json.js CHANGED
@@ -387,10 +387,7 @@ var TriggersSchema = z10.object({
387
387
  var AuthSchema = z10.record(
388
388
  ResourceIdSchema,
389
389
  z10.object({
390
- // access: z
391
- // .boolean()
392
- // .default(false)
393
- // .describe('Give access to every function in this stack to your cognito instance.'),
390
+ access: z10.boolean().default(false).describe("Give access to every function in this stack to your cognito instance."),
394
391
  triggers: TriggersSchema.optional()
395
392
  })
396
393
  ).optional().describe("Define the auth triggers in your stack.");