@kensio/yulin 1.14.0 → 1.14.2

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.
Files changed (28) hide show
  1. package/dist/service/cloudfront/origin/custom/sim-cf-function-url-origin-fragments.d.ts +15 -9
  2. package/dist/service/cloudfront/origin/custom/sim-cf-function-url-origin-fragments.d.ts.map +1 -1
  3. package/dist/service/cloudfront/origin/custom/sim-cf-function-url-origin-fragments.js +24 -13
  4. package/dist/service/cloudfront/origin/custom/sim-cf-function-url-origin-fragments.js.map +1 -1
  5. package/dist/service/cloudfront/origin/custom/sim-cf-function-url-origin-template.factory.d.ts.map +1 -1
  6. package/dist/service/cloudfront/origin/custom/sim-cf-function-url-origin-template.factory.js +1 -0
  7. package/dist/service/cloudfront/origin/custom/sim-cf-function-url-origin-template.factory.js.map +1 -1
  8. package/dist/service/lambda/function/code/vm/sim-lambda-vm-context.d.ts +2 -1
  9. package/dist/service/lambda/function/code/vm/sim-lambda-vm-context.d.ts.map +1 -1
  10. package/dist/service/lambda/function/code/vm/sim-lambda-vm-context.js +15 -2
  11. package/dist/service/lambda/function/code/vm/sim-lambda-vm-context.js.map +1 -1
  12. package/dist/service/lambda/function/code/vm/sim-lambda-vm-output-stream.d.ts +40 -0
  13. package/dist/service/lambda/function/code/vm/sim-lambda-vm-output-stream.d.ts.map +1 -0
  14. package/dist/service/lambda/function/code/vm/sim-lambda-vm-output-stream.js +46 -0
  15. package/dist/service/lambda/function/code/vm/sim-lambda-vm-output-stream.js.map +1 -0
  16. package/dist/service/lambda/serve/auth/sim-lambda-url-authorizer.d.ts +14 -11
  17. package/dist/service/lambda/serve/auth/sim-lambda-url-authorizer.d.ts.map +1 -1
  18. package/dist/service/lambda/serve/auth/sim-lambda-url-authorizer.js +29 -12
  19. package/dist/service/lambda/serve/auth/sim-lambda-url-authorizer.js.map +1 -1
  20. package/dist/service/lambda/serve/auth/sim-lambda-url-invoke-actions.d.ts +34 -0
  21. package/dist/service/lambda/serve/auth/sim-lambda-url-invoke-actions.d.ts.map +1 -0
  22. package/dist/service/lambda/serve/auth/sim-lambda-url-invoke-actions.js +63 -0
  23. package/dist/service/lambda/serve/auth/sim-lambda-url-invoke-actions.js.map +1 -0
  24. package/dist/service/lambda/serve/response/sim-lambda-url-error-response.d.ts +9 -1
  25. package/dist/service/lambda/serve/response/sim-lambda-url-error-response.d.ts.map +1 -1
  26. package/dist/service/lambda/serve/response/sim-lambda-url-error-response.js +11 -2
  27. package/dist/service/lambda/serve/response/sim-lambda-url-error-response.js.map +1 -1
  28. package/package.json +4 -1
@@ -1,9 +1,9 @@
1
1
  import type { SimCfnTemplateValue, SimCfnTemplateValueRecord } from "../../../cloudformation/template/value/sim-cfn-template-value.js";
2
2
  /**
3
- * What a test asks for when it wants the template CDK synthesizes for
4
- * `origins.FunctionUrlOrigin.withOriginAccessControl()`.
3
+ * What a test asks for when it wants a working version of the template
4
+ * `origins.FunctionUrlOrigin.withOriginAccessControl()` synthesizes.
5
5
  *
6
- * Five Resources stand between a test and a Function URL served through a
6
+ * Six Resources stand between a test and a Function URL served through a
7
7
  * Distribution, and each test about that shape is about one of them being
8
8
  * wrong, so each field here is one thing a template can get wrong on its own.
9
9
  */
@@ -16,20 +16,26 @@ export interface SimCfFunctionUrlOriginTemplateInput {
16
16
  */
17
17
  readonly originAccessControl: boolean;
18
18
  /**
19
- * Whether the template grants CloudFront the Function URL, which CDK always
20
- * does alongside the Distribution.
19
+ * Whether the template grants CloudFront the Function URL at all.
21
20
  */
22
21
  readonly permitted: boolean;
22
+ /**
23
+ * The actions the grant covers.
24
+ *
25
+ * Reaching a Function URL through an origin access control takes both of
26
+ * them, so a template granting one is one that deploys and then answers 403.
27
+ */
28
+ readonly permittedActions: readonly string[];
23
29
  /** The Distribution the permission is granted for. */
24
30
  readonly permissionSourceArn: SimCfnTemplateValue;
25
31
  }
26
32
  /**
27
33
  * The parts of the template a template can leave out.
28
34
  *
29
- * Each is a Resource, or a property of one, that CDK always writes and that a
30
- * hand-written template can forget. The origin access control contributes two,
31
- * which are both there or both absent, since an Origin naming one nothing
32
- * created would be refused rather than reached.
35
+ * Each is a Resource, or a property of one, that a template can forget. The
36
+ * origin access control contributes two, which are both there or both absent,
37
+ * since an Origin naming one nothing created would be refused rather than
38
+ * reached. The permission contributes one Resource per action it grants.
33
39
  */
34
40
  export interface SimCfFunctionUrlOriginParts {
35
41
  readonly originAccessControl: SimCfnTemplateValueRecord;
@@ -1 +1 @@
1
- {"version":3,"file":"sim-cf-function-url-origin-fragments.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-function-url-origin-fragments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,kEAAkE,CAAC;AAE1E;;;;;;;GAOG;AACH,MAAM,WAAW,mCAAmC;IAClD,gFAAgF;IAChF,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,sDAAsD;IACtD,QAAQ,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;CACnD;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,mBAAmB,EAAE,yBAAyB,CAAC;IACxD,QAAQ,CAAC,qBAAqB,EAAE,yBAAyB,CAAC;IAC1D,QAAQ,CAAC,gBAAgB,EAAE,yBAAyB,CAAC;CACtD;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,mCAAmC,GACzC,2BAA2B,CAgC7B"}
1
+ {"version":3,"file":"sim-cf-function-url-origin-fragments.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-function-url-origin-fragments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,kEAAkE,CAAC;AAE1E;;;;;;;GAOG;AACH,MAAM,WAAW,mCAAmC;IAClD,gFAAgF;IAChF,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,sDAAsD;IACtD,QAAQ,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;CACnD;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,mBAAmB,EAAE,yBAAyB,CAAC;IACxD,QAAQ,CAAC,qBAAqB,EAAE,yBAAyB,CAAC;IAC1D,QAAQ,CAAC,gBAAgB,EAAE,yBAAyB,CAAC;CACtD;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,mCAAmC,GACzC,2BAA2B,CAsB7B"}
@@ -19,21 +19,32 @@ export function simCfFunctionUrlOriginParts(input) {
19
19
  originAccessControlId: included(input.originAccessControl, {
20
20
  OriginAccessControlId: { Ref: "SiteOac" },
21
21
  }),
22
- // The permission CDK writes beside the Distribution, letting CloudFront
23
- // invoke the Function URL for that Distribution alone.
24
- invokePermission: included(input.permitted, {
25
- InvokeFromCloudFront: {
26
- Type: "AWS::Lambda::Permission",
27
- Properties: {
28
- FunctionName: { "Fn::GetAtt": ["GreeterFunction", "Arn"] },
29
- Action: "lambda:InvokeFunctionUrl",
30
- Principal: "cloudfront.amazonaws.com",
31
- SourceArn: input.permissionSourceArn,
32
- },
33
- },
34
- }),
22
+ // The permissions letting CloudFront invoke the Function URL for this
23
+ // Distribution alone. AWS takes one per action, and both of them.
24
+ invokePermission: included(input.permitted, invokePermissions(input)),
35
25
  };
36
26
  }
27
+ /**
28
+ * One `AWS::Lambda::Permission` per granted action.
29
+ *
30
+ * The statement id is derived from the action, so a template granting both
31
+ * carries two Resources rather than one overwriting the other, which is how
32
+ * the two `aws lambda add-permission` calls in the AWS documentation land.
33
+ */
34
+ function invokePermissions(input) {
35
+ return Object.fromEntries(input.permittedActions.map((action) => [
36
+ `${action.replace("lambda:", "")}FromCloudFront`,
37
+ {
38
+ Type: "AWS::Lambda::Permission",
39
+ Properties: {
40
+ FunctionName: { "Fn::GetAtt": ["GreeterFunction", "Arn"] },
41
+ Action: action,
42
+ Principal: "cloudfront.amazonaws.com",
43
+ SourceArn: input.permissionSourceArn,
44
+ },
45
+ },
46
+ ]));
47
+ }
37
48
  /**
38
49
  * One fragment of the template, or nothing where the template omits it.
39
50
  */
@@ -1 +1 @@
1
- {"version":3,"file":"sim-cf-function-url-origin-fragments.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-function-url-origin-fragments.ts"],"names":[],"mappings":"AA4CA;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAA0C;IAE1C,OAAO;QACL,mBAAmB,EAAE,QAAQ,CAAC,KAAK,CAAC,mBAAmB,EAAE;YACvD,OAAO,EAAE;gBACP,IAAI,EAAE,sCAAsC;gBAC5C,UAAU,EAAE;oBACV,yBAAyB,EAAE;wBACzB,IAAI,EAAE,UAAU;wBAChB,6BAA6B,EAAE,QAAQ;wBACvC,eAAe,EAAE,KAAK,CAAC,eAAe;wBACtC,eAAe,EAAE,OAAO;qBACzB;iBACF;aACF;SACF,CAAC;QACF,qBAAqB,EAAE,QAAQ,CAAC,KAAK,CAAC,mBAAmB,EAAE;YACzD,qBAAqB,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE;SAC1C,CAAC;QACF,wEAAwE;QACxE,uDAAuD;QACvD,gBAAgB,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS,EAAE;YAC1C,oBAAoB,EAAE;gBACpB,IAAI,EAAE,yBAAyB;gBAC/B,UAAU,EAAE;oBACV,YAAY,EAAE,EAAE,YAAY,EAAE,CAAC,iBAAiB,EAAE,KAAK,CAAC,EAAE;oBAC1D,MAAM,EAAE,0BAA0B;oBAClC,SAAS,EAAE,0BAA0B;oBACrC,SAAS,EAAE,KAAK,CAAC,mBAAmB;iBACrC;aACF;SACF,CAAC;KACH,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,QAAQ,CACf,OAAgB,EAChB,QAAmC;IAEnC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"sim-cf-function-url-origin-fragments.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-function-url-origin-fragments.ts"],"names":[],"mappings":"AAkDA;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAA0C;IAE1C,OAAO;QACL,mBAAmB,EAAE,QAAQ,CAAC,KAAK,CAAC,mBAAmB,EAAE;YACvD,OAAO,EAAE;gBACP,IAAI,EAAE,sCAAsC;gBAC5C,UAAU,EAAE;oBACV,yBAAyB,EAAE;wBACzB,IAAI,EAAE,UAAU;wBAChB,6BAA6B,EAAE,QAAQ;wBACvC,eAAe,EAAE,KAAK,CAAC,eAAe;wBACtC,eAAe,EAAE,OAAO;qBACzB;iBACF;aACF;SACF,CAAC;QACF,qBAAqB,EAAE,QAAQ,CAAC,KAAK,CAAC,mBAAmB,EAAE;YACzD,qBAAqB,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE;SAC1C,CAAC;QACF,sEAAsE;QACtE,kEAAkE;QAClE,gBAAgB,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC;KACtE,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAS,iBAAiB,CACxB,KAA0C;IAE1C,OAAO,MAAM,CAAC,WAAW,CACvB,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;QACrC,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB;QAChD;YACE,IAAI,EAAE,yBAAyB;YAC/B,UAAU,EAAE;gBACV,YAAY,EAAE,EAAE,YAAY,EAAE,CAAC,iBAAiB,EAAE,KAAK,CAAC,EAAE;gBAC1D,MAAM,EAAE,MAAM;gBACd,SAAS,EAAE,0BAA0B;gBACrC,SAAS,EAAE,KAAK,CAAC,mBAAmB;aACrC;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,QAAQ,CACf,OAAgB,EAChB,QAAmC;IAEnC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sim-cf-function-url-origin-template.factory.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-function-url-origin-template.factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sDAAsD,CAAC;AAClG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kEAAkE,CAAC;AAC5G,OAAO,EACL,KAAK,mCAAmC,EAEzC,MAAM,2CAA2C,CAAC;AAanD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,mBAUlC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qCAAqC,sFAkFjD,CAAC"}
1
+ {"version":3,"file":"sim-cf-function-url-origin-template.factory.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-function-url-origin-template.factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sDAAsD,CAAC;AAClG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kEAAkE,CAAC;AAC5G,OAAO,EACL,KAAK,mCAAmC,EAEzC,MAAM,2CAA2C,CAAC;AAanD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,mBAUlC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qCAAqC,sFAmFjD,CAAC"}
@@ -43,6 +43,7 @@ export const simCfFunctionUrlOriginTemplateFactory = new MappedFactory(() => ({
43
43
  signingBehavior: "always",
44
44
  originAccessControl: true,
45
45
  permitted: true,
46
+ permittedActions: ["lambda:InvokeFunctionUrl", "lambda:InvokeFunction"],
46
47
  permissionSourceArn: simCfDistributionArn,
47
48
  }), (input) => ({
48
49
  Resources: {
@@ -1 +1 @@
1
- {"version":3,"file":"sim-cf-function-url-origin-template.factory.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-function-url-origin-template.factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,OAAO,EAEL,2BAA2B,GAC5B,MAAM,2CAA2C,CAAC;AAEnD,MAAM,wBAAwB,GAAG;IAC/B,OAAO,EAAE,YAAY;IACrB,SAAS,EAAE;QACT;YACE,MAAM,EAAE,OAAO;YACf,SAAS,EAAE,EAAE,OAAO,EAAE,sBAAsB,EAAE;YAC9C,MAAM,EAAE,gBAAgB;SACzB;KACF;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAwB;IACvD,UAAU,EAAE;QACV,EAAE;QACF;YACE,sBAAsB;YACtB,EAAE,GAAG,EAAE,gBAAgB,EAAE;YACzB,gBAAgB;YAChB,EAAE,GAAG,EAAE,kBAAkB,EAAE;SAC5B;KACF;CACF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,IAAI,aAAa,CAIpE,GAAG,EAAE,CAAC,CAAC;IACL,eAAe,EAAE,QAAQ;IACzB,mBAAmB,EAAE,IAAI;IACzB,SAAS,EAAE,IAAI;IACf,mBAAmB,EAAE,oBAAoB;CAC1C,CAAC,EACF,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACV,SAAS,EAAE;QACT,WAAW,EAAE;YACX,IAAI,EAAE,gBAAgB;YACtB,UAAU,EAAE;gBACV,QAAQ,EAAE,aAAa;gBACvB,wBAAwB,EAAE,wBAAwB;aACnD;SACF;QACD,eAAe,EAAE;YACf,IAAI,EAAE,uBAAuB;YAC7B,UAAU,EAAE;gBACV,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE,YAAY,EAAE,CAAC,aAAa,EAAE,KAAK,CAAC,EAAE;gBAC9C,IAAI,EAAE;oBACJ,OAAO,EACL,gCAAgC;wBAChC,8DAA8D;iBACjE;gBACD,OAAO,EAAE,eAAe;gBACxB,OAAO,EAAE,YAAY;aACtB;SACF;QACD,UAAU,EAAE;YACV,IAAI,EAAE,kBAAkB;YACxB,UAAU,EAAE;gBACV,iBAAiB,EAAE,EAAE,YAAY,EAAE,CAAC,iBAAiB,EAAE,KAAK,CAAC,EAAE;gBAC/D,QAAQ,EAAE,SAAS;aACpB;SACF;QACD,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAAC,mBAAmB;QACzD,gBAAgB,EAAE;YAChB,IAAI,EAAE,+BAA+B;YACrC,UAAU,EAAE;gBACV,kBAAkB,EAAE;oBAClB,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE;wBACP;4BACE,EAAE,EAAE,mBAAmB;4BACvB,4DAA4D;4BAC5D,iDAAiD;4BACjD,UAAU,EAAE;gCACV,YAAY,EAAE;oCACZ,CAAC;oCACD;wCACE,WAAW,EAAE;4CACX,GAAG;4CACH,EAAE,YAAY,EAAE,CAAC,YAAY,EAAE,aAAa,CAAC,EAAE;yCAChD;qCACF;iCACF;6BACF;4BACD,kBAAkB,EAAE,EAAE,oBAAoB,EAAE,YAAY,EAAE;4BAC1D,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAAC,qBAAqB;yBAC5D;qBACF;oBACD,oBAAoB,EAAE;wBACpB,cAAc,EAAE,mBAAmB;wBACnC,oBAAoB,EAAE,mBAAmB;qBAC1C;iBACF;aACF;SACF;QACD,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAAC,gBAAgB;KACvD;IACD,OAAO,EAAE;QACP,sBAAsB,EAAE;YACtB,KAAK,EAAE,EAAE,YAAY,EAAE,CAAC,kBAAkB,EAAE,YAAY,CAAC,EAAE;SAC5D;QACD,eAAe,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE;KACjD;CACF,CAAC,CACH,CAAC"}
1
+ {"version":3,"file":"sim-cf-function-url-origin-template.factory.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-function-url-origin-template.factory.ts"],"names":[],"mappings":"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"}
@@ -6,7 +6,8 @@ import type { SimLambdaEnvironment } from "../../environment/sim-lambda-environm
6
6
  *
7
7
  * The context provides the common globals a Node.js Lambda runtime offers,
8
8
  * including an AWS-like process.env holding the standard runtime variables
9
- * and any variables declared for the function. Everything else must be part
9
+ * and any variables declared for the function, and the writable standard
10
+ * streams function code writes its output to. Everything else must be part
10
11
  * of the deployed function code archive, as on real Lambda.
11
12
  *
12
13
  * Zip code needs nothing like the process.env and Date handling the
@@ -1 +1 @@
1
- {"version":3,"file":"sim-lambda-vm-context.d.ts","sourceRoot":"","sources":["../../../../../../src/service/lambda/function/code/vm/sim-lambda-vm-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EACL,KAAK,QAAQ,EAEd,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAExF;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,oBAAoB,EACjC,KAAK,GAAE,QAA6B,GACnC,EAAE,CAAC,OAAO,CAuBZ"}
1
+ {"version":3,"file":"sim-lambda-vm-context.d.ts","sourceRoot":"","sources":["../../../../../../src/service/lambda/function/code/vm/sim-lambda-vm-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EACL,KAAK,QAAQ,EAEd,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAGxF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,oBAAoB,EACjC,KAAK,GAAE,QAA6B,GACnC,EAAE,CAAC,OAAO,CAkCZ"}
@@ -1,12 +1,15 @@
1
+ import { Console } from "node:console";
1
2
  import vm from "node:vm";
2
3
  import { makeSimClockDate } from "../../../../../util/clock/sim-clock-date.js";
3
4
  import { SimRealClock, } from "../../../../../util/clock/sim-clock.js";
5
+ import { SimLambdaVmOutputStream } from "./sim-lambda-vm-output-stream.js";
4
6
  /**
5
7
  * Create the sandbox vm context that sim Lambda function code runs in.
6
8
  *
7
9
  * The context provides the common globals a Node.js Lambda runtime offers,
8
10
  * including an AWS-like process.env holding the standard runtime variables
9
- * and any variables declared for the function. Everything else must be part
11
+ * and any variables declared for the function, and the writable standard
12
+ * streams function code writes its output to. Everything else must be part
10
13
  * of the deployed function code archive, as on real Lambda.
11
14
  *
12
15
  * Zip code needs nothing like the process.env and Date handling the
@@ -15,11 +18,21 @@ import { SimRealClock, } from "../../../../../util/clock/sim-clock.js";
15
18
  * nothing outside the sandbox is touched to arrange that.
16
19
  */
17
20
  export function makeSimLambdaVmContext(environment, clock = new SimRealClock()) {
21
+ // Writable standard streams, as the real runtime provides. Code that builds
22
+ // its own console over them, as AWS Lambda Powertools' logger does, throws
23
+ // at module load without them.
24
+ const stdout = new SimLambdaVmOutputStream(() => process.stdout);
25
+ const stderr = new SimLambdaVmOutputStream(() => process.stderr);
18
26
  return vm.createContext({
19
- console,
27
+ // The sandbox's console is built over those streams, as the real
28
+ // runtime's is, so everything function code prints goes to one place
29
+ // whether it printed through the console or wrote to the stream itself.
30
+ console: new Console({ stdout, stderr }),
20
31
  Buffer,
21
32
  process: {
22
33
  env: environment.variables(),
34
+ stdout,
35
+ stderr,
23
36
  },
24
37
  // Function code asking JavaScript for the time gets the simulation's
25
38
  // time, so a frozen or advanced clock reaches the code under test.
@@ -1 +1 @@
1
- {"version":3,"file":"sim-lambda-vm-context.js","sourceRoot":"","sources":["../../../../../../src/service/lambda/function/code/vm/sim-lambda-vm-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EAEL,YAAY,GACb,MAAM,wCAAwC,CAAC;AAGhD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,sBAAsB,CACpC,WAAiC,EACjC,KAAK,GAAa,IAAI,YAAY,EAAE;IAEpC,OAAO,EAAE,CAAC,aAAa,CAAC;QACtB,OAAO;QACP,MAAM;QACN,OAAO,EAAE;YACP,GAAG,EAAE,WAAW,CAAC,SAAS,EAAE;SAC7B;QACD,qEAAqE;QACrE,mEAAmE;QACnE,IAAI,EAAE,gBAAgB,CAAC,KAAK,CAAC;QAC7B,UAAU;QACV,YAAY;QACZ,WAAW;QACX,aAAa;QACb,YAAY;QACZ,cAAc;QACd,WAAW;QACX,WAAW;QACX,GAAG;QACH,eAAe;QACf,eAAe;QACf,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"sim-lambda-vm-context.js","sourceRoot":"","sources":["../../../../../../src/service/lambda/function/code/vm/sim-lambda-vm-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EAEL,YAAY,GACb,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3E;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB,CACpC,WAAiC,EACjC,KAAK,GAAa,IAAI,YAAY,EAAE;IAEpC,4EAA4E;IAC5E,2EAA2E;IAC3E,+BAA+B;IAC/B,MAAM,MAAM,GAAG,IAAI,uBAAuB,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,IAAI,uBAAuB,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEjE,OAAO,EAAE,CAAC,aAAa,CAAC;QACtB,iEAAiE;QACjE,qEAAqE;QACrE,wEAAwE;QACxE,OAAO,EAAE,IAAI,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QACxC,MAAM;QACN,OAAO,EAAE;YACP,GAAG,EAAE,WAAW,CAAC,SAAS,EAAE;YAC5B,MAAM;YACN,MAAM;SACP;QACD,qEAAqE;QACrE,mEAAmE;QACnE,IAAI,EAAE,gBAAgB,CAAC,KAAK,CAAC;QAC7B,UAAU;QACV,YAAY;QACZ,WAAW;QACX,aAAa;QACb,YAAY;QACZ,cAAc;QACd,WAAW;QACX,WAAW;QACX,GAAG;QACH,eAAe;QACf,eAAe;QACf,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { Writable } from "node:stream";
2
+ /**
3
+ * One of the standard output streams the sim Lambda vm sandbox gives function
4
+ * code as `process.stdout` and `process.stderr`.
5
+ *
6
+ * Real Lambda gives function code writable standard streams, and libraries
7
+ * build their own console over them rather than the global one, so that
8
+ * console patching cannot affect their output. AWS Lambda Powertools' logger
9
+ * does exactly that, at module scope:
10
+ *
11
+ * ```javascript
12
+ * new Console({ stdout: process.stdout, stderr: process.stderr })
13
+ * ```
14
+ *
15
+ * Without the streams that construction throws
16
+ * (`ERR_CONSOLE_WRITABLE_STREAM`) before the handler runs.
17
+ *
18
+ * What function code writes is forwarded to the matching host stream,
19
+ * standard output to standard output and standard error to standard error.
20
+ * The sandbox's own console is built over these streams too, so a handler's
21
+ * output arrives there whether it printed through the console or wrote to the
22
+ * stream itself, instead of one of the two disappearing. The host stream is
23
+ * read per write, so a test that starts capturing host output after the
24
+ * function has cold-started still sees what the handler writes.
25
+ */
26
+ export declare class SimLambdaVmOutputStream extends Writable {
27
+ private readonly hostStream;
28
+ constructor(hostStream: () => NodeJS.WritableStream);
29
+ /**
30
+ * The write is handed on and reported as done without waiting for the host
31
+ * stream, as Node.js's own console hands writes to process.stdout. Waiting
32
+ * would make a failed log write fail the code that logged: reporting the
33
+ * host's error here destroys this stream, and with nothing listening for
34
+ * its error the process goes down over a lost line. It would also mean a
35
+ * test capturing host output had to complete the write it captured, and the
36
+ * ordinary way to capture it does not.
37
+ */
38
+ _write(chunk: Buffer, _encoding: BufferEncoding, done: (error?: Error) => void): void;
39
+ }
40
+ //# sourceMappingURL=sim-lambda-vm-output-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sim-lambda-vm-output-stream.d.ts","sourceRoot":"","sources":["../../../../../../src/service/lambda/function/code/vm/sim-lambda-vm-output-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,uBAAwB,SAAQ,QAAQ;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAAvC,YAA6B,UAAU,EAAE,MAAM,MAAM,CAAC,cAAc,EAEnE;IAED;;;;;;;;OAQG;IACM,MAAM,CACb,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,GAC5B,IAAI,CAGN;CACF"}
@@ -0,0 +1,46 @@
1
+ import { Writable } from "node:stream";
2
+ /**
3
+ * One of the standard output streams the sim Lambda vm sandbox gives function
4
+ * code as `process.stdout` and `process.stderr`.
5
+ *
6
+ * Real Lambda gives function code writable standard streams, and libraries
7
+ * build their own console over them rather than the global one, so that
8
+ * console patching cannot affect their output. AWS Lambda Powertools' logger
9
+ * does exactly that, at module scope:
10
+ *
11
+ * ```javascript
12
+ * new Console({ stdout: process.stdout, stderr: process.stderr })
13
+ * ```
14
+ *
15
+ * Without the streams that construction throws
16
+ * (`ERR_CONSOLE_WRITABLE_STREAM`) before the handler runs.
17
+ *
18
+ * What function code writes is forwarded to the matching host stream,
19
+ * standard output to standard output and standard error to standard error.
20
+ * The sandbox's own console is built over these streams too, so a handler's
21
+ * output arrives there whether it printed through the console or wrote to the
22
+ * stream itself, instead of one of the two disappearing. The host stream is
23
+ * read per write, so a test that starts capturing host output after the
24
+ * function has cold-started still sees what the handler writes.
25
+ */
26
+ export class SimLambdaVmOutputStream extends Writable {
27
+ hostStream;
28
+ constructor(hostStream) {
29
+ super();
30
+ this.hostStream = hostStream;
31
+ }
32
+ /**
33
+ * The write is handed on and reported as done without waiting for the host
34
+ * stream, as Node.js's own console hands writes to process.stdout. Waiting
35
+ * would make a failed log write fail the code that logged: reporting the
36
+ * host's error here destroys this stream, and with nothing listening for
37
+ * its error the process goes down over a lost line. It would also mean a
38
+ * test capturing host output had to complete the write it captured, and the
39
+ * ordinary way to capture it does not.
40
+ */
41
+ _write(chunk, _encoding, done) {
42
+ this.hostStream().write(chunk);
43
+ done();
44
+ }
45
+ }
46
+ //# sourceMappingURL=sim-lambda-vm-output-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sim-lambda-vm-output-stream.js","sourceRoot":"","sources":["../../../../../../src/service/lambda/function/code/vm/sim-lambda-vm-output-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,uBAAwB,SAAQ,QAAQ;IACtB,UAAU;IAAvC,YAA6B,UAAuC;QAClE,KAAK,EAAE,CAAC;0BADmB,UAAU;IAEvC,CAAC;IAED;;;;;;;;OAQG;IACM,MAAM,CACb,KAAa,EACb,SAAyB,EACzB,IAA6B;QAE7B,IAAI,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,EAAE,CAAC;IACT,CAAC;CACF"}
@@ -3,15 +3,6 @@ import type { SimIamAuthorizationDecision, SimIamInterServiceAuthZ } from "../..
3
3
  import type { SimAwsRequestSource } from "../../../iam/request/sim-aws-request-source.js";
4
4
  import type { SimLambdaFunction } from "../../function/sim-lambda-function.js";
5
5
  import type { SimLambdaFunctionUrl } from "../../function/url/sim-lambda-function-url.js";
6
- /**
7
- * The IAM action a Function URL invocation is authorized against.
8
- *
9
- * This is deliberately not `lambda:InvokeFunction`, which is what the Invoke
10
- * API maps to. Real AWS separates the two so a policy can grant the HTTP
11
- * endpoint without granting the SDK operation, and a test asserting on that
12
- * distinction should see it hold here.
13
- */
14
- export declare const simLambdaInvokeFunctionUrlAction = "lambda:InvokeFunctionUrl";
15
6
  interface SimLambdaUrlAuthorizerProperties {
16
7
  readonly iam: SimIamInterServiceAuthZ;
17
8
  }
@@ -40,7 +31,19 @@ export declare class SimLambdaUrlAuthorizer {
40
31
  private readonly iam;
41
32
  constructor(properties: SimLambdaUrlAuthorizerProperties);
42
33
  /**
43
- * Evaluate `lambda:InvokeFunctionUrl` for a caller against a Function URL.
34
+ * Evaluate the actions reaching this Function URL takes.
35
+ *
36
+ * `lambda:InvokeFunctionUrl` is the one a caller signing its own request
37
+ * needs. CloudFront reaching the URL through an origin access control needs
38
+ * `lambda:InvokeFunction` on top of it, so a resource policy granting only
39
+ * the URL action is refused here as real Lambda refuses it.
40
+ *
41
+ * Every action is judged against the same request, so a permission
42
+ * conditioned on the Distribution applies to both.
43
+ */
44
+ authorize(input: SimLambdaUrlAuthorizationInput): SimIamAuthorizationDecision;
45
+ /**
46
+ * Evaluate one action for a caller against a Function URL.
44
47
  *
45
48
  * The URL's auth type is supplied as `lambda:FunctionUrlAuthType`, which is
46
49
  * what a grant conditions on in practice: a permission granted for `AWS_IAM`
@@ -52,7 +55,7 @@ export declare class SimLambdaUrlAuthorizer {
52
55
  * no source supplies neither, so a permission conditioned on one does not
53
56
  * match rather than matching anything.
54
57
  */
55
- authorize(input: SimLambdaUrlAuthorizationInput): SimIamAuthorizationDecision;
58
+ private decide;
56
59
  }
57
60
  export {};
58
61
  //# sourceMappingURL=sim-lambda-url-authorizer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sim-lambda-url-authorizer.d.ts","sourceRoot":"","sources":["../../../../../src/service/lambda/serve/auth/sim-lambda-url-authorizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EACV,2BAA2B,EAC3B,uBAAuB,EACxB,MAAM,wDAAwD,CAAC;AAOhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAE1F;;;;;;;GAOG;AACH,eAAO,MAAM,gCAAgC,6BAA6B,CAAC;AAE3E,UAAU,gCAAgC;IACxC,QAAQ,CAAC,GAAG,EAAE,uBAAuB,CAAC;CACvC;AAED,UAAU,8BAA8B;IACtC,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IACxC,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;IAC3C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACnD;AAED;;;;;;;;;;GAUG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA0B;IAE9C,YAAY,UAAU,EAAE,gCAAgC,EAEvD;IAED;;;;;;;;;;;;OAYG;IACH,SAAS,CACP,KAAK,EAAE,8BAA8B,GACpC,2BAA2B,CAkB7B;CACF"}
1
+ {"version":3,"file":"sim-lambda-url-authorizer.d.ts","sourceRoot":"","sources":["../../../../../src/service/lambda/serve/auth/sim-lambda-url-authorizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EACV,2BAA2B,EAC3B,uBAAuB,EACxB,MAAM,wDAAwD,CAAC;AAYhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAE1F,UAAU,gCAAgC;IACxC,QAAQ,CAAC,GAAG,EAAE,uBAAuB,CAAC;CACvC;AAED,UAAU,8BAA8B;IACtC,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IACxC,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;IAC3C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACnD;AAED;;;;;;;;;;GAUG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA0B;IAE9C,YAAY,UAAU,EAAE,gCAAgC,EAEvD;IAED;;;;;;;;;;OAUG;IACH,SAAS,CACP,KAAK,EAAE,8BAA8B,GACpC,2BAA2B,CAkB7B;IAED;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,MAAM;CAsBf"}
@@ -1,14 +1,6 @@
1
1
  import { simLambdaResourcePolicies } from "../../command/authorize/sim-lambda-resource-policies.js";
2
2
  import { simLambdaFunctionUrlAuthTypeConditionKey, simLambdaSourceAccountConditionKey, simLambdaSourceArnConditionKey, } from "../../function/policy/sim-lambda-permission.js";
3
- /**
4
- * The IAM action a Function URL invocation is authorized against.
5
- *
6
- * This is deliberately not `lambda:InvokeFunction`, which is what the Invoke
7
- * API maps to. Real AWS separates the two so a policy can grant the HTTP
8
- * endpoint without granting the SDK operation, and a test asserting on that
9
- * distinction should see it hold here.
10
- */
11
- export const simLambdaInvokeFunctionUrlAction = "lambda:InvokeFunctionUrl";
3
+ import { simLambdaInvokeFunctionAction, simLambdaInvokeFunctionUrlAction, simLambdaUrlRequiresInvokeFunction, } from "./sim-lambda-url-invoke-actions.js";
12
4
  /**
13
5
  * Decides whether a caller may invoke a Function URL.
14
6
  *
@@ -26,7 +18,32 @@ export class SimLambdaUrlAuthorizer {
26
18
  this.iam = properties.iam;
27
19
  }
28
20
  /**
29
- * Evaluate `lambda:InvokeFunctionUrl` for a caller against a Function URL.
21
+ * Evaluate the actions reaching this Function URL takes.
22
+ *
23
+ * `lambda:InvokeFunctionUrl` is the one a caller signing its own request
24
+ * needs. CloudFront reaching the URL through an origin access control needs
25
+ * `lambda:InvokeFunction` on top of it, so a resource policy granting only
26
+ * the URL action is refused here as real Lambda refuses it.
27
+ *
28
+ * Every action is judged against the same request, so a permission
29
+ * conditioned on the Distribution applies to both.
30
+ */
31
+ authorize(input) {
32
+ const urlDecision = this.decide(simLambdaInvokeFunctionUrlAction, input);
33
+ if (urlDecision.isDenied) {
34
+ return urlDecision;
35
+ }
36
+ if (!simLambdaUrlRequiresInvokeFunction(input.caller)) {
37
+ return urlDecision;
38
+ }
39
+ const invokeDecision = this.decide(simLambdaInvokeFunctionAction, input);
40
+ if (invokeDecision.isDenied) {
41
+ return invokeDecision;
42
+ }
43
+ return urlDecision;
44
+ }
45
+ /**
46
+ * Evaluate one action for a caller against a Function URL.
30
47
  *
31
48
  * The URL's auth type is supplied as `lambda:FunctionUrlAuthType`, which is
32
49
  * what a grant conditions on in practice: a permission granted for `AWS_IAM`
@@ -38,10 +55,10 @@ export class SimLambdaUrlAuthorizer {
38
55
  * no source supplies neither, so a permission conditioned on one does not
39
56
  * match rather than matching anything.
40
57
  */
41
- authorize(input) {
58
+ decide(action, input) {
42
59
  const { source } = input;
43
60
  return this.iam.authorize({
44
- action: simLambdaInvokeFunctionUrlAction,
61
+ action,
45
62
  resource: input.simFunction.arn,
46
63
  caller: input.caller,
47
64
  resourcePolicies: simLambdaResourcePolicies(input.simFunction),
@@ -1 +1 @@
1
- {"version":3,"file":"sim-lambda-url-authorizer.js","sourceRoot":"","sources":["../../../../../src/service/lambda/serve/auth/sim-lambda-url-authorizer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,MAAM,yDAAyD,CAAC;AACpG,OAAO,EACL,wCAAwC,EACxC,kCAAkC,EAClC,8BAA8B,GAC/B,MAAM,gDAAgD,CAAC;AAKxD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,0BAA0B,CAAC;AAiB3E;;;;;;;;;;GAUG;AACH,MAAM,OAAO,sBAAsB;IAChB,GAAG,CAA0B;IAE9C,YAAY,UAA4C;QACtD,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,SAAS,CACP,KAAqC;QAErC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAEzB,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;YACxB,MAAM,EAAE,gCAAgC;YACxC,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG;YAC/B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,gBAAgB,EAAE,yBAAyB,CAAC,KAAK,CAAC,WAAW,CAAC;YAC9D,gBAAgB,EAAE;gBAChB,CAAC,wCAAwC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,QAAQ;gBACtE,GAAG,CAAC,MAAM,EAAE,GAAG,KAAK,SAAS,IAAI;oBAC/B,CAAC,8BAA8B,CAAC,EAAE,MAAM,CAAC,GAAG;iBAC7C,CAAC;gBACF,GAAG,CAAC,MAAM,EAAE,SAAS,KAAK,SAAS,IAAI;oBACrC,CAAC,kCAAkC,CAAC,EAAE,MAAM,CAAC,SAAS;iBACvD,CAAC;aACH;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
1
+ {"version":3,"file":"sim-lambda-url-authorizer.js","sourceRoot":"","sources":["../../../../../src/service/lambda/serve/auth/sim-lambda-url-authorizer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,MAAM,yDAAyD,CAAC;AACpG,OAAO,EACL,wCAAwC,EACxC,kCAAkC,EAClC,8BAA8B,GAC/B,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,6BAA6B,EAC7B,gCAAgC,EAChC,kCAAkC,GACnC,MAAM,oCAAoC,CAAC;AAoB5C;;;;;;;;;;GAUG;AACH,MAAM,OAAO,sBAAsB;IAChB,GAAG,CAA0B;IAE9C,YAAY,UAA4C;QACtD,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;OAUG;IACH,SAAS,CACP,KAAqC;QAErC,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;QAEzE,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;YACzB,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,IAAI,CAAC,kCAAkC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACtD,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;QAEzE,IAAI,cAAc,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,cAAc,CAAC;QACxB,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;OAYG;IACK,MAAM,CACZ,MAAc,EACd,KAAqC;QAErC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAEzB,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;YACxB,MAAM;YACN,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG;YAC/B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,gBAAgB,EAAE,yBAAyB,CAAC,KAAK,CAAC,WAAW,CAAC;YAC9D,gBAAgB,EAAE;gBAChB,CAAC,wCAAwC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,QAAQ;gBACtE,GAAG,CAAC,MAAM,EAAE,GAAG,KAAK,SAAS,IAAI;oBAC/B,CAAC,8BAA8B,CAAC,EAAE,MAAM,CAAC,GAAG;iBAC7C,CAAC;gBACF,GAAG,CAAC,MAAM,EAAE,SAAS,KAAK,SAAS,IAAI;oBACrC,CAAC,kCAAkC,CAAC,EAAE,MAAM,CAAC,SAAS;iBACvD,CAAC;aACH;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,34 @@
1
+ import type { SimAwsCaller } from "../../../aws/caller/sim-aws-caller.js";
2
+ /**
3
+ * The IAM action a Function URL invocation is authorized against.
4
+ *
5
+ * This is deliberately not `lambda:InvokeFunction`, which is what the Invoke
6
+ * API maps to. Real AWS separates the two so a policy can grant the HTTP
7
+ * endpoint without granting the SDK operation, and a test asserting on that
8
+ * distinction should see it hold here.
9
+ *
10
+ * That is the whole rule for a caller signing its own request. It is not the
11
+ * whole rule for a CloudFront origin access control, which needs
12
+ * `lambda:InvokeFunction` as well.
13
+ */
14
+ export declare const simLambdaInvokeFunctionUrlAction = "lambda:InvokeFunctionUrl";
15
+ /**
16
+ * The action the Invoke API maps to, which reaching a Function URL through a
17
+ * CloudFront origin access control takes on top of the URL action.
18
+ *
19
+ * Real Lambda answers an origin access control granted only the URL action
20
+ * with 403 and never runs the handler. Both grants go to the CloudFront
21
+ * service principal and both are conditioned on the Distribution, as described
22
+ * in [Restrict access to an AWS Lambda function URL
23
+ * origin](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-lambda.html).
24
+ */
25
+ export declare const simLambdaInvokeFunctionAction = "lambda:InvokeFunction";
26
+ /**
27
+ * Whether reaching this Function URL also takes `lambda:InvokeFunction`.
28
+ *
29
+ * True for CloudFront, and false for anything else, which is the distinction
30
+ * real Lambda draws: a caller signing the request itself needs the URL action
31
+ * alone.
32
+ */
33
+ export declare function simLambdaUrlRequiresInvokeFunction(caller: SimAwsCaller): boolean;
34
+ //# sourceMappingURL=sim-lambda-url-invoke-actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sim-lambda-url-invoke-actions.d.ts","sourceRoot":"","sources":["../../../../../src/service/lambda/serve/auth/sim-lambda-url-invoke-actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAEb,MAAM,uCAAuC,CAAC;AAE/C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gCAAgC,6BAA6B,CAAC;AAE3E;;;;;;;;;GASG;AACH,eAAO,MAAM,6BAA6B,0BAA0B,CAAC;AAWrE;;;;;;GAMG;AACH,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,YAAY,GACnB,OAAO,CAQT"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The IAM action a Function URL invocation is authorized against.
3
+ *
4
+ * This is deliberately not `lambda:InvokeFunction`, which is what the Invoke
5
+ * API maps to. Real AWS separates the two so a policy can grant the HTTP
6
+ * endpoint without granting the SDK operation, and a test asserting on that
7
+ * distinction should see it hold here.
8
+ *
9
+ * That is the whole rule for a caller signing its own request. It is not the
10
+ * whole rule for a CloudFront origin access control, which needs
11
+ * `lambda:InvokeFunction` as well.
12
+ */
13
+ export const simLambdaInvokeFunctionUrlAction = "lambda:InvokeFunctionUrl";
14
+ /**
15
+ * The action the Invoke API maps to, which reaching a Function URL through a
16
+ * CloudFront origin access control takes on top of the URL action.
17
+ *
18
+ * Real Lambda answers an origin access control granted only the URL action
19
+ * with 403 and never runs the handler. Both grants go to the CloudFront
20
+ * service principal and both are conditioned on the Distribution, as described
21
+ * in [Restrict access to an AWS Lambda function URL
22
+ * origin](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-lambda.html).
23
+ */
24
+ export const simLambdaInvokeFunctionAction = "lambda:InvokeFunction";
25
+ /**
26
+ * The service principal CloudFront reaches an Origin as.
27
+ *
28
+ * Named here rather than imported from simulated CloudFront, so that simulated
29
+ * Lambda goes on depending on nothing in that service. What real Lambda wants
30
+ * the second action for is the principal, whatever is simulating it.
31
+ */
32
+ const cloudFrontServicePrincipal = "cloudfront.amazonaws.com";
33
+ /**
34
+ * Whether reaching this Function URL also takes `lambda:InvokeFunction`.
35
+ *
36
+ * True for CloudFront, and false for anything else, which is the distinction
37
+ * real Lambda draws: a caller signing the request itself needs the URL action
38
+ * alone.
39
+ */
40
+ export function simLambdaUrlRequiresInvokeFunction(caller) {
41
+ const principal = callerPrincipal(caller);
42
+ if (principal.kind !== "service") {
43
+ return false;
44
+ }
45
+ return principal.service === cloudFrontServicePrincipal;
46
+ }
47
+ /**
48
+ * The principal a caller names.
49
+ *
50
+ * Credentials name one too, but only once IAM has authenticated them, and
51
+ * nothing reaching a Function URL as a service principal presents any: an
52
+ * origin access control states who it is at the boundary instead.
53
+ */
54
+ function callerPrincipal(caller) {
55
+ if (caller.kind === "resolved") {
56
+ return caller.principal;
57
+ }
58
+ if (caller.kind === "credentials") {
59
+ return { kind: "anonymous" };
60
+ }
61
+ return caller;
62
+ }
63
+ //# sourceMappingURL=sim-lambda-url-invoke-actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sim-lambda-url-invoke-actions.js","sourceRoot":"","sources":["../../../../../src/service/lambda/serve/auth/sim-lambda-url-invoke-actions.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,0BAA0B,CAAC;AAE3E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,uBAAuB,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,0BAA0B,GAAG,0BAA0B,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,UAAU,kCAAkC,CAChD,MAAoB;IAEpB,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAE1C,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,SAAS,CAAC,OAAO,KAAK,0BAA0B,CAAC;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,MAAoB;IAC3C,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,OAAO,MAAM,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QAClC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC/B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,3 +1,11 @@
1
+ /**
2
+ * What real Lambda says when it refuses a Function URL request.
3
+ *
4
+ * A refused request never reaches the handler and writes no log stream, so
5
+ * this body is the only thing a deployment has to go on. The wording is real
6
+ * Lambda's, down to the link, because that is what someone will be reading.
7
+ */
8
+ export declare const simLambdaUrlForbiddenMessage: string;
1
9
  /**
2
10
  * The error responses a Function URL endpoint returns itself, before or
3
11
  * instead of the function producing one.
@@ -12,7 +20,7 @@ export declare class SimLambdaUrlErrorResponse {
12
20
  */
13
21
  notFound(): Response;
14
22
  /**
15
- * The Function URL requires authentication the simulator cannot verify.
23
+ * The caller is not allowed to invoke this Function URL.
16
24
  */
17
25
  forbidden(): Response;
18
26
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"sim-lambda-url-error-response.d.ts","sourceRoot":"","sources":["../../../../../src/service/lambda/serve/response/sim-lambda-url-error-response.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,yBAAyB;IACpC;;OAEG;IACH,QAAQ,IAAI,QAAQ,CAEnB;IAED;;OAEG;IACH,SAAS,IAAI,QAAQ,CAEpB;IAED;;OAEG;IACH,mBAAmB,IAAI,QAAQ,CAE9B;IAED,OAAO,CAAC,YAAY;CASrB"}
1
+ {"version":3,"file":"sim-lambda-url-error-response.d.ts","sourceRoot":"","sources":["../../../../../src/service/lambda/serve/response/sim-lambda-url-error-response.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,QAEsB,CAAC;AAEhE;;;;;;;GAOG;AACH,qBAAa,yBAAyB;IACpC;;OAEG;IACH,QAAQ,IAAI,QAAQ,CAEnB;IAED;;OAEG;IACH,SAAS,IAAI,QAAQ,CAEpB;IAED;;OAEG;IACH,mBAAmB,IAAI,QAAQ,CAE9B;IAED,OAAO,CAAC,YAAY;CASrB"}
@@ -1,3 +1,12 @@
1
+ /**
2
+ * What real Lambda says when it refuses a Function URL request.
3
+ *
4
+ * A refused request never reaches the handler and writes no log stream, so
5
+ * this body is the only thing a deployment has to go on. The wording is real
6
+ * Lambda's, down to the link, because that is what someone will be reading.
7
+ */
8
+ export const simLambdaUrlForbiddenMessage = "Forbidden. For troubleshooting Function URL authorization issues, see: " +
9
+ "https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html";
1
10
  /**
2
11
  * The error responses a Function URL endpoint returns itself, before or
3
12
  * instead of the function producing one.
@@ -14,10 +23,10 @@ export class SimLambdaUrlErrorResponse {
14
23
  return this.jsonResponse(404, "Not Found");
15
24
  }
16
25
  /**
17
- * The Function URL requires authentication the simulator cannot verify.
26
+ * The caller is not allowed to invoke this Function URL.
18
27
  */
19
28
  forbidden() {
20
- return this.jsonResponse(403, "Forbidden");
29
+ return this.jsonResponse(403, simLambdaUrlForbiddenMessage);
21
30
  }
22
31
  /**
23
32
  * The function failed to handle the invocation.
@@ -1 +1 @@
1
- {"version":3,"file":"sim-lambda-url-error-response.js","sourceRoot":"","sources":["../../../../../src/service/lambda/serve/response/sim-lambda-url-error-response.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,yBAAyB;IACpC;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAC;IACzD,CAAC;IAEO,YAAY,CAAC,MAAc,EAAE,OAAe;QAClD,OAAO,QAAQ,CAAC,IAAI,CAClB,EAAE,OAAO,EAAE,OAAO,EAAE,EACpB;YACE,MAAM;YACN,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;SAChD,CACF,CAAC;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"sim-lambda-url-error-response.js","sourceRoot":"","sources":["../../../../../src/service/lambda/serve/response/sim-lambda-url-error-response.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,4BAA4B,GACvC,yEAAyE;IACzE,6DAA6D,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,OAAO,yBAAyB;IACpC;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,4BAA4B,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAC;IACzD,CAAC;IAEO,YAAY,CAAC,MAAc,EAAE,OAAe;QAClD,OAAO,QAAQ,CAAC,IAAI,CAClB,EAAE,OAAO,EAAE,OAAO,EAAE,EACpB;YACE,MAAM;YACN,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;SAChD,CACF,CAAC;IACJ,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kensio/yulin",
3
- "version": "1.14.0",
3
+ "version": "1.14.2",
4
4
  "description": "AWS system behaviour simulation for isolated unit testing",
5
5
  "repository": "https://github.com/KensioSoftware/yulin",
6
6
  "homepage": "https://yulinsim.dev/",
@@ -163,6 +163,8 @@
163
163
  "packageManager": "pnpm@11.17.0+sha512.cca3cea332ad254bb84145f966d19f4879615210346fc92c79a047f23a0d7b3cca3c3792f0076ba1f1831d277efbcf0a9119b31a9a60eca7fb3d6231f331ef72",
164
164
  "devDependencies": {
165
165
  "@aws-crypto/sha256-js": "^5.2.0",
166
+ "@aws-lambda-powertools/logger": "^2.34.0",
167
+ "@aws-lambda-powertools/metrics": "^2.34.0",
166
168
  "@aws-sdk/client-acm": "^3.1101.0",
167
169
  "@aws-sdk/client-apigatewayv2": "^3.1101.0",
168
170
  "@aws-sdk/client-cloudformation": "^3.1101.0",
@@ -204,6 +206,7 @@
204
206
  "aws-sdk-client-mock": "^4.1.0",
205
207
  "constructs": "^10.8.0",
206
208
  "conventional-changelog-conventionalcommits": "9.3.1",
209
+ "esbuild": "^0.28.2",
207
210
  "eslint": "^10.8.0",
208
211
  "eslint-plugin-jsdoc": "^63.3.2",
209
212
  "eslint-plugin-no-secrets": "^2.3.3",