@kensio/yulin 1.20.15 → 1.20.17

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 (355) hide show
  1. package/README.md +13 -0
  2. package/dist/sdk/module/sim-sdk-module-client-interceptor.d.ts +5 -0
  3. package/dist/sdk/module/sim-sdk-module-client-interceptor.js +14 -0
  4. package/dist/sdk/module/sim-sdk-static-client-factory.d.ts +26 -0
  5. package/dist/sdk/module/sim-sdk-static-client-factory.js +59 -0
  6. package/dist/sdk/send-patch.d.ts +8 -0
  7. package/dist/sdk/send-patch.js +11 -0
  8. package/dist/service/aws/caller/sim-aws-ambient-caller.d.ts +23 -0
  9. package/dist/service/aws/caller/sim-aws-ambient-caller.js +12 -0
  10. package/dist/service/aws/caller/sim-aws-caller-resolver.d.ts +39 -6
  11. package/dist/service/aws/caller/sim-aws-caller-resolver.js +32 -30
  12. package/dist/service/aws/caller/sim-aws-caller.d.ts +9 -0
  13. package/dist/service/aws/caller/sim-aws-resolved-caller.d.ts +19 -0
  14. package/dist/service/aws/caller/sim-aws-resolved-caller.js +26 -0
  15. package/dist/service/aws/factory/sim-aws-account-region-service-builder.d.ts +12 -0
  16. package/dist/service/aws/factory/sim-aws-account-region-service-builder.js +6 -0
  17. package/dist/service/aws/factory/sim-aws-account-service-cache.d.ts +12 -0
  18. package/dist/service/aws/factory/sim-aws-account-service-cache.js +9 -0
  19. package/dist/service/aws/factory/sim-aws-registered-service-builder.js +3 -1
  20. package/dist/service/aws/factory/sim-aws-service-factory.d.ts +5 -0
  21. package/dist/service/aws/factory/sim-aws-service-factory.js +14 -0
  22. package/dist/service/aws/sim-aws-properties.d.ts +15 -0
  23. package/dist/service/aws/sim-aws.js +2 -1
  24. package/dist/service/cloudformation/command/create-stack/create-stack.handler.d.ts +4 -0
  25. package/dist/service/cloudformation/command/create-stack/create-stack.handler.js +4 -1
  26. package/dist/service/cloudformation/deploy/sim-cfn-cdk-out-deployer.js +2 -1
  27. package/dist/service/cloudformation/deploy/sim-cfn-cdk-out-plan.d.ts +11 -2
  28. package/dist/service/cloudformation/deploy/sim-cfn-cdk-out-plan.js +2 -1
  29. package/dist/service/cloudformation/deploy/sim-cfn-cdk-out-stack-options.d.ts +6 -0
  30. package/dist/service/cloudformation/deploy/sim-cfn-template-deployer.d.ts +11 -0
  31. package/dist/service/cloudformation/deploy/sim-cfn-template-deployer.js +17 -15
  32. package/dist/service/cloudformation/deploy/sim-cfn-template-file-loader.d.ts +12 -0
  33. package/dist/service/cloudformation/deploy/sim-cfn-template-file-loader.js +2 -1
  34. package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-cache-policy-cfn.d.ts +23 -0
  35. package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-cache-policy-cfn.js +30 -0
  36. package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-cfn-value-adapter.js +8 -0
  37. package/dist/service/cloudformation/resource/name/sim-cfn-generated-resource-name.d.ts +29 -12
  38. package/dist/service/cloudformation/resource/name/sim-cfn-generated-resource-name.js +51 -20
  39. package/dist/service/cloudformation/stack/deploy/sim-cfn-resource-order.d.ts +19 -0
  40. package/dist/service/cloudformation/stack/deploy/sim-cfn-resource-order.js +6 -0
  41. package/dist/service/cloudformation/stack/deploy/sim-cfn-stack-resource-batch-creator.d.ts +7 -0
  42. package/dist/service/cloudformation/stack/deploy/sim-cfn-stack-resource-batch-creator.js +9 -2
  43. package/dist/service/cloudformation/stack/deploy/sim-cfn-stack-resource-creator.d.ts +2 -0
  44. package/dist/service/cloudformation/stack/deploy/sim-cfn-stack-resource-creator.js +2 -1
  45. package/dist/service/cloudformation/stack/sim-cfn-stack-resource-operations.d.ts +6 -0
  46. package/dist/service/cloudformation/stack/sim-cfn-stack-resource-operations.js +4 -1
  47. package/dist/service/cloudformation/stack/sim-cfn-stack.js +2 -1
  48. package/dist/service/cloudformation/stack/sim-cfn-stack.type.d.ts +6 -0
  49. package/dist/service/cloudfront/behaviour/sim-cloud-front-behavior.d.ts +5 -0
  50. package/dist/service/cloudfront/cache-policy/sim-cf-cache-policy-registry.d.ts +37 -0
  51. package/dist/service/cloudfront/cache-policy/sim-cf-cache-policy-registry.js +50 -0
  52. package/dist/service/cloudfront/cache-policy/sim-cf-cache-policy.d.ts +25 -0
  53. package/dist/service/cloudfront/cache-policy/sim-cf-cache-policy.js +21 -0
  54. package/dist/service/cloudfront/cache-policy/sim-cf-managed-cache-policies.d.ts +28 -0
  55. package/dist/service/cloudfront/cache-policy/sim-cf-managed-cache-policies.js +48 -0
  56. package/dist/service/cloudfront/cff/function-code-input/cff-function-code-input.d.ts +8 -0
  57. package/dist/service/cloudfront/cff/function-code-input/cff-function-code-input.js +13 -0
  58. package/dist/service/cloudfront/cff/sim-cf-function-commands.d.ts +52 -0
  59. package/dist/service/cloudfront/cff/sim-cf-function-commands.js +51 -0
  60. package/dist/service/cloudfront/cff/sim-cff-configuration.d.ts +41 -0
  61. package/dist/service/cloudfront/cff/sim-cff-configuration.js +34 -0
  62. package/dist/service/cloudfront/cff/sim-cff-stage.d.ts +23 -0
  63. package/dist/service/cloudfront/cff/sim-cff-stage.js +30 -0
  64. package/dist/service/cloudfront/cff/sim-cloudfront-function.d.ts +6 -1
  65. package/dist/service/cloudfront/cff/sim-cloudfront-function.js +6 -0
  66. package/dist/service/cloudfront/cfn/cache-policy/sim-cfn-cf-cache-policy-config.d.ts +27 -0
  67. package/dist/service/cloudfront/cfn/cache-policy/sim-cfn-cf-cache-policy-config.js +42 -0
  68. package/dist/service/cloudfront/cfn/cache-policy/sim-cfn-cf-cache-policy-creator.d.ts +24 -0
  69. package/dist/service/cloudfront/cfn/cache-policy/sim-cfn-cf-cache-policy-creator.js +32 -0
  70. package/dist/service/cloudfront/cfn/distro/{sim-cfn-cf-distro-response-headers-policy.d.ts → sim-cfn-cf-distro-behavior-policies.d.ts} +8 -7
  71. package/dist/service/cloudfront/cfn/distro/{sim-cfn-cf-distro-response-headers-policy.js → sim-cfn-cf-distro-behavior-policies.js} +11 -37
  72. package/dist/service/cloudfront/cfn/distro/sim-cfn-cf-distro-creator.d.ts +6 -5
  73. package/dist/service/cloudfront/cfn/distro/sim-cfn-cf-distro-creator.js +8 -7
  74. package/dist/service/cloudfront/cfn/distro/sim-cfn-cf-distro-policy-drops.d.ts +23 -0
  75. package/dist/service/cloudfront/cfn/distro/sim-cfn-cf-distro-policy-drops.js +50 -0
  76. package/dist/service/cloudfront/cfn/sim-cfn-cloudfront-resource-factory.d.ts +1 -0
  77. package/dist/service/cloudfront/cfn/sim-cfn-cloudfront-resource-factory.js +10 -0
  78. package/dist/service/cloudfront/command/create-distribution/create-distribution.command.d.ts +1 -0
  79. package/dist/service/cloudfront/command/create-distribution/create-distribution.handler.d.ts +2 -0
  80. package/dist/service/cloudfront/command/create-function/create-function.handler.js +7 -1
  81. package/dist/service/cloudfront/command/function/sim-cf-describe-function.d.ts +22 -0
  82. package/dist/service/cloudfront/command/function/sim-cf-describe-function.js +32 -0
  83. package/dist/service/cloudfront/command/function/sim-cf-function-access.d.ts +48 -0
  84. package/dist/service/cloudfront/command/function/sim-cf-function-access.js +48 -0
  85. package/dist/service/cloudfront/command/function/sim-cf-function-command.types.d.ts +97 -0
  86. package/dist/service/cloudfront/command/function/sim-cf-function-command.types.js +10 -0
  87. package/dist/service/cloudfront/command/function/sim-cf-function-lookup.d.ts +12 -0
  88. package/dist/service/cloudfront/command/function/sim-cf-function-lookup.js +21 -0
  89. package/dist/service/cloudfront/command/function/sim-cf-function-summary.d.ts +11 -0
  90. package/dist/service/cloudfront/command/function/sim-cf-function-summary.js +30 -0
  91. package/dist/service/cloudfront/command/function/sim-cf-get-function.d.ts +23 -0
  92. package/dist/service/cloudfront/command/function/sim-cf-get-function.js +33 -0
  93. package/dist/service/cloudfront/command/function/sim-cf-list-functions.d.ts +22 -0
  94. package/dist/service/cloudfront/command/function/sim-cf-list-functions.js +38 -0
  95. package/dist/service/cloudfront/command/update-distribution/update-distribution.handler.d.ts +2 -0
  96. package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-cache-policy.d.ts +18 -0
  97. package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-cache-policy.js +30 -0
  98. package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-policies.d.ts +28 -0
  99. package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-policies.js +41 -0
  100. package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-properties.d.ts +2 -2
  101. package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-properties.js +6 -3
  102. package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-response-headers-policy.d.ts +0 -10
  103. package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-response-headers-policy.js +0 -19
  104. package/dist/service/cloudfront/distribution/configurator/sim-cf-distribution-configurator.factory.d.ts +2 -0
  105. package/dist/service/cloudfront/distribution/configurator/sim-cf-distribution-configurator.factory.js +4 -2
  106. package/dist/service/cloudfront/distribution/configurator/sim-cloud-front-behavior-configurator.d.ts +3 -3
  107. package/dist/service/cloudfront/distribution/configurator/sim-cloud-front-behavior-configurator.js +5 -5
  108. package/dist/service/cloudfront/distribution/configurator/sim-cloud-front-distribution-configurator.d.ts +3 -3
  109. package/dist/service/cloudfront/distribution/configurator/sim-cloud-front-distribution-configurator.js +4 -4
  110. package/dist/service/cloudfront/distribution/sim-cf-distribution-configuration-state.d.ts +3 -1
  111. package/dist/service/cloudfront/distribution/sim-cf-distribution-reconfigurer.d.ts +2 -0
  112. package/dist/service/cloudfront/error/sim-cloudfront.error.d.ts +21 -0
  113. package/dist/service/cloudfront/error/sim-cloudfront.error.js +25 -0
  114. package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-access.js +2 -10
  115. package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store.js +2 -1
  116. package/dist/service/cloudfront/sdk/sim-cloudfront-sdk-command-router.js +12 -0
  117. package/dist/service/cloudfront/sim-cf-authorize.d.ts +16 -0
  118. package/dist/service/cloudfront/sim-cf-authorize.js +19 -0
  119. package/dist/service/cloudfront/sim-cf-etag.d.ts +7 -0
  120. package/dist/service/cloudfront/sim-cf-etag.js +10 -0
  121. package/dist/service/cloudfront/sim-cloudfront-commands.d.ts +8 -12
  122. package/dist/service/cloudfront/sim-cloudfront-commands.js +8 -17
  123. package/dist/service/cloudfront/sim-cloudfront-policies.d.ts +43 -0
  124. package/dist/service/cloudfront/sim-cloudfront-policies.js +53 -0
  125. package/dist/service/cloudfront/sim-cloudfront.d.ts +13 -17
  126. package/dist/service/cloudfront/sim-cloudfront.js +22 -25
  127. package/dist/service/ecr/authorize/sim-ecr-authorizer.d.ts +31 -0
  128. package/dist/service/ecr/authorize/sim-ecr-authorizer.js +38 -0
  129. package/dist/service/ecr/cfn/repository/sim-cfn-ecr-repository-creator.d.ts +11 -2
  130. package/dist/service/ecr/cfn/repository/sim-cfn-ecr-repository-creator.js +11 -2
  131. package/dist/service/ecr/cfn/sim-ecr-cfn-resource-factory.d.ts +4 -2
  132. package/dist/service/ecr/cfn/sim-ecr-cfn-resource-factory.js +8 -9
  133. package/dist/service/ecr/cfn/sim-ecr-cfn-unsupported-resource.d.ts +7 -0
  134. package/dist/service/ecr/cfn/sim-ecr-cfn-unsupported-resource.js +9 -0
  135. package/dist/service/ecr/sim-ecr.d.ts +7 -0
  136. package/dist/service/ecr/sim-ecr.js +16 -4
  137. package/dist/service/ecs/command/authorize/sim-ecs-authorizer.d.ts +12 -0
  138. package/dist/service/ecs/command/authorize/sim-ecs-authorizer.js +21 -0
  139. package/dist/service/ecs/command/register-task-definition/register-task-definition.handler.js +1 -0
  140. package/dist/service/ecs/sim-ecs-service-principal.d.ts +8 -0
  141. package/dist/service/ecs/sim-ecs-service-principal.js +8 -0
  142. package/dist/service/eventbridge/command/authorize/sim-event-bridge-authorizer.d.ts +12 -0
  143. package/dist/service/eventbridge/command/authorize/sim-event-bridge-authorizer.js +21 -0
  144. package/dist/service/eventbridge/command/rule/sim-event-bridge-rule-access.d.ts +13 -0
  145. package/dist/service/eventbridge/command/rule/sim-event-bridge-rule-access.js +9 -0
  146. package/dist/service/eventbridge/command/target/sim-event-bridge-put-targets.js +1 -0
  147. package/dist/service/firehose/command/authorize/sim-firehose-authorizer.d.ts +12 -0
  148. package/dist/service/firehose/command/authorize/sim-firehose-authorizer.js +20 -0
  149. package/dist/service/firehose/command/sim-firehose-delivery-stream-access.d.ts +4 -0
  150. package/dist/service/firehose/command/sim-firehose-delivery-stream-access.js +6 -0
  151. package/dist/service/firehose/command/stream/sim-firehose-create-delivery-stream.js +3 -1
  152. package/dist/service/firehose/sim-firehose-service-principal.d.ts +8 -0
  153. package/dist/service/firehose/sim-firehose-service-principal.js +8 -0
  154. package/dist/service/firehose/source/sim-firehose-source.d.ts +5 -0
  155. package/dist/service/firehose/source/sim-firehose-source.js +5 -0
  156. package/dist/service/glue/cfn/database/sim-cfn-glue-database-properties.js +2 -2
  157. package/dist/service/glue/cfn/sim-cfn-glue-generated-name.d.ts +10 -0
  158. package/dist/service/glue/cfn/sim-cfn-glue-generated-name.js +25 -0
  159. package/dist/service/glue/cfn/table/sim-cfn-glue-table-properties.js +2 -3
  160. package/dist/service/iam/authorize/allow/sim-iam-allow-requirement.d.ts +33 -2
  161. package/dist/service/iam/authorize/allow/sim-iam-allow-requirement.js +33 -2
  162. package/dist/service/iam/authorize/allow/sim-iam-allow-statements.d.ts +4 -3
  163. package/dist/service/iam/authorize/allow/sim-iam-allow-statements.js +9 -3
  164. package/dist/service/iam/authorize/context/sim-iam-auth-z-allow-requirement.d.ts +14 -5
  165. package/dist/service/iam/authorize/context/sim-iam-auth-z-allow-requirement.js +16 -12
  166. package/dist/service/iam/authorize/context/sim-iam-auth-z-caller-context-builder.d.ts +36 -7
  167. package/dist/service/iam/authorize/context/sim-iam-auth-z-caller-context-builder.js +22 -11
  168. package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.d.ts +10 -71
  169. package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.js +7 -2
  170. package/dist/service/iam/authorize/context/sim-iam-auth-z-input.d.ts +87 -0
  171. package/dist/service/iam/authorize/context/sim-iam-auth-z-input.js +1 -0
  172. package/dist/service/iam/authorize/match/sim-iam-policy-principal-matcher.d.ts +21 -3
  173. package/dist/service/iam/authorize/match/sim-iam-policy-principal-matcher.js +34 -10
  174. package/dist/service/iam/authorize/match/sim-iam-principal-match.d.ts +29 -8
  175. package/dist/service/iam/authorize/match/sim-iam-principal-match.js +38 -13
  176. package/dist/service/iam/authorize/pass-role/sim-iam-pass-role-authorizer.d.ts +74 -0
  177. package/dist/service/iam/authorize/pass-role/sim-iam-pass-role-authorizer.js +92 -0
  178. package/dist/service/iam/authorize/sim-iam-account-auth-z.d.ts +21 -5
  179. package/dist/service/iam/authorize/sim-iam-account-auth-z.js +7 -3
  180. package/dist/service/iam/authorize/sim-iam-authorizer.d.ts +5 -2
  181. package/dist/service/iam/authorize/sim-iam-authorizer.js +3 -1
  182. package/dist/service/iam/authorize/sim-iam-inter-service-auth-z.d.ts +1 -1
  183. package/dist/service/iam/authorize/sim-iam-wildcard.js +39 -4
  184. package/dist/service/iam/cfn/managed-policy/sim-cfn-iam-managed-policy-creator.js +2 -1
  185. package/dist/service/iam/cfn/name/sim-cfn-iam-generated-name.d.ts +16 -0
  186. package/dist/service/iam/cfn/name/sim-cfn-iam-generated-name.js +36 -0
  187. package/dist/service/iam/cfn/role/sim-cfn-iam-role-properties-parser.js +9 -8
  188. package/dist/service/iam/cfn/sim-cfn-iam-optional-string.d.ts +17 -0
  189. package/dist/service/iam/cfn/sim-cfn-iam-optional-string.js +17 -0
  190. package/dist/service/iam/cfn/user/sim-cfn-iam-user-properties-parser.js +4 -8
  191. package/dist/service/iam/command/policy/create-policy/create-policy-input-resolver.js +2 -0
  192. package/dist/service/iam/command/policy/put-role-policy/put-role-policy.handler.js +5 -0
  193. package/dist/service/iam/command/policy/put-user-policy/put-user-policy.handler.js +5 -0
  194. package/dist/service/iam/command/role/create-role/create-role.handler.js +4 -1
  195. package/dist/service/iam/error/sim-iam.error.d.ts +11 -0
  196. package/dist/service/iam/error/sim-iam.error.js +13 -0
  197. package/dist/service/iam/index.d.ts +1 -0
  198. package/dist/service/iam/policy/sim-iam-policy-document-of-size.d.ts +18 -0
  199. package/dist/service/iam/policy/sim-iam-policy-document-of-size.js +41 -0
  200. package/dist/service/iam/role/sim-iam-deploy-role.d.ts +56 -0
  201. package/dist/service/iam/role/sim-iam-deploy-role.js +50 -0
  202. package/dist/service/iam/role/sim-iam-role-with-policy.factory.d.ts +11 -0
  203. package/dist/service/iam/role/sim-iam-role-with-policy.factory.js +4 -2
  204. package/dist/service/iam/sim-iam-account-parts.d.ts +16 -0
  205. package/dist/service/iam/sim-iam-account-parts.js +2 -0
  206. package/dist/service/iam/sim-iam.d.ts +12 -2
  207. package/dist/service/iam/sim-iam.js +12 -0
  208. package/dist/service/iam/validate/size/sim-iam-policy-document-size.d.ts +57 -0
  209. package/dist/service/iam/validate/size/sim-iam-policy-document-size.js +71 -0
  210. package/dist/service/kms/command/authorize/sim-kms-authorizer.d.ts +3 -1
  211. package/dist/service/kms/command/authorize/sim-kms-authorizer.js +4 -1
  212. package/dist/service/kms/command/sim-kms-request-options.d.ts +11 -0
  213. package/dist/service/kms/key/sim-kms-key-policy.d.ts +5 -4
  214. package/dist/service/kms/key/sim-kms-key-policy.js +4 -3
  215. package/dist/service/lambda/cfn/function/sim-cfn-lambda-function-properties-parser.d.ts +2 -2
  216. package/dist/service/lambda/cfn/function/sim-cfn-lambda-function-properties-parser.js +4 -3
  217. package/dist/service/lambda/cfn/function/sim-cfn-lambda-generated-function-name.d.ts +10 -0
  218. package/dist/service/lambda/cfn/function/sim-cfn-lambda-generated-function-name.js +25 -0
  219. package/dist/service/lambda/command/authorize/sim-lambda-resource-policies.d.ts +1 -1
  220. package/dist/service/lambda/command/create-function/create-function-authorizer.d.ts +9 -2
  221. package/dist/service/lambda/command/create-function/create-function-authorizer.js +16 -2
  222. package/dist/service/lambda/command/create-function/create-function.handler.js +1 -1
  223. package/dist/service/lambda/command/update-function-configuration/update-function-configuration-authorizer.d.ts +7 -2
  224. package/dist/service/lambda/command/update-function-configuration/update-function-configuration-authorizer.js +14 -2
  225. package/dist/service/lambda/command/update-function-configuration/update-function-configuration.handler.js +1 -1
  226. package/dist/service/lambda/function/logging/sim-lambda-function-logging.d.ts +10 -1
  227. package/dist/service/lambda/function/logging/sim-lambda-function-logging.js +25 -1
  228. package/dist/service/lambda/function/logging/sim-lambda-invoke-error-log.d.ts +13 -0
  229. package/dist/service/lambda/function/logging/sim-lambda-invoke-error-log.js +18 -0
  230. package/dist/service/lambda/sim-lambda-service-principal.d.ts +7 -0
  231. package/dist/service/lambda/sim-lambda-service-principal.js +7 -0
  232. package/dist/service/logs/cfn/delivery/sim-cfn-delivery-authorization.d.ts +46 -0
  233. package/dist/service/logs/cfn/delivery/sim-cfn-delivery-authorization.js +49 -0
  234. package/dist/service/logs/cfn/delivery/sim-cfn-delivery-creator.d.ts +5 -0
  235. package/dist/service/logs/cfn/delivery/sim-cfn-delivery-creator.js +6 -0
  236. package/dist/service/logs/cfn/delivery/sim-cfn-delivery-destination-creator.d.ts +5 -0
  237. package/dist/service/logs/cfn/delivery/sim-cfn-delivery-destination-creator.js +6 -0
  238. package/dist/service/logs/cfn/delivery/sim-cfn-delivery-source-creator.d.ts +5 -0
  239. package/dist/service/logs/cfn/delivery/sim-cfn-delivery-source-creator.js +6 -0
  240. package/dist/service/logs/cfn/group/sim-cfn-log-group-creator.d.ts +9 -2
  241. package/dist/service/logs/cfn/group/sim-cfn-log-group-creator.js +34 -5
  242. package/dist/service/logs/cfn/sim-logs-cfn-resource-deleter.js +1 -1
  243. package/dist/service/logs/cfn/sim-logs-cfn-resource-factory.d.ts +4 -0
  244. package/dist/service/logs/cfn/sim-logs-cfn-resource-factory.js +9 -4
  245. package/dist/service/logs/sim-logs-commands.d.ts +3 -0
  246. package/dist/service/logs/sim-logs-commands.js +4 -0
  247. package/dist/service/logs/sim-logs.js +6 -1
  248. package/dist/service/s3/cfn/bucket/sim-cfn-s3-bucket-creator.d.ts +2 -2
  249. package/dist/service/s3/cfn/bucket/sim-cfn-s3-bucket-creator.js +4 -3
  250. package/dist/service/s3/cfn/bucket/sim-cfn-s3-bucket-generated-name.d.ts +12 -0
  251. package/dist/service/s3/cfn/bucket/sim-cfn-s3-bucket-generated-name.js +22 -0
  252. package/dist/service/s3/command/authorize/sim-s3-bucket-resource-policies.d.ts +1 -1
  253. package/dist/service/scheduler/command/authorize/sim-scheduler-authorizer.d.ts +10 -1
  254. package/dist/service/scheduler/command/authorize/sim-scheduler-authorizer.js +19 -1
  255. package/dist/service/scheduler/command/schedule/sim-scheduler-create-schedule.js +1 -0
  256. package/dist/service/scheduler/command/schedule/sim-scheduler-schedule-access.d.ts +8 -0
  257. package/dist/service/scheduler/command/schedule/sim-scheduler-schedule-access.js +9 -0
  258. package/dist/service/scheduler/command/schedule/sim-scheduler-update-schedule.js +1 -0
  259. package/dist/service/secretsmanager/cfn/secret/sim-cfn-secrets-manager-generated-name.d.ts +15 -0
  260. package/dist/service/secretsmanager/cfn/secret/sim-cfn-secrets-manager-generated-name.js +22 -0
  261. package/dist/service/secretsmanager/cfn/secret/sim-cfn-secrets-manager-secret-properties.d.ts +4 -10
  262. package/dist/service/secretsmanager/cfn/secret/sim-cfn-secrets-manager-secret-properties.js +13 -31
  263. package/dist/service/secretsmanager/cfn/secret/sim-cfn-secrets-manager-secret-value.d.ts +17 -0
  264. package/dist/service/secretsmanager/cfn/secret/sim-cfn-secrets-manager-secret-value.js +30 -0
  265. package/dist/service/secretsmanager/secret/sim-secrets-manager-secret-name.d.ts +6 -0
  266. package/dist/service/secretsmanager/secret/sim-secrets-manager-secret-name.js +8 -3
  267. package/dist/service/sns/command/authorize/sim-sns-topic-resource-policies.d.ts +1 -1
  268. package/dist/service/sqs/command/authorize/sim-sqs-queue-resource-policies.d.ts +1 -1
  269. package/dist/service/ssm/cfn/parameter/sim-cfn-ssm-generated-parameter-name.d.ts +16 -0
  270. package/dist/service/ssm/cfn/parameter/sim-cfn-ssm-generated-parameter-name.js +23 -0
  271. package/dist/service/ssm/cfn/parameter/sim-cfn-ssm-parameter-properties.d.ts +2 -4
  272. package/dist/service/ssm/cfn/parameter/sim-cfn-ssm-parameter-properties.js +5 -5
  273. package/dist/service/ssm/parameter/sim-ssm-kms-crypto.d.ts +6 -4
  274. package/dist/service/ssm/parameter/sim-ssm-kms-crypto.js +4 -4
  275. package/dist/service/ssm/parameter/sim-ssm-parameter-arn.d.ts +17 -0
  276. package/dist/service/ssm/parameter/sim-ssm-parameter-arn.js +20 -0
  277. package/dist/service/ssm/parameter/sim-ssm-parameter-kms.d.ts +15 -9
  278. package/dist/service/ssm/parameter/sim-ssm-parameter-kms.js +20 -10
  279. package/dist/service/ssm/parameter/sim-ssm-parameter-name.js +3 -12
  280. package/dist/service/stepfunctions/command/authorize/sim-step-functions-authorizer.d.ts +41 -0
  281. package/dist/service/stepfunctions/command/authorize/sim-step-functions-authorizer.js +64 -0
  282. package/dist/service/stepfunctions/command/machine/sim-state-machine-create.d.ts +5 -2
  283. package/dist/service/stepfunctions/command/machine/sim-state-machine-create.js +6 -2
  284. package/dist/service/stepfunctions/command/machine/sim-state-machine-delete.d.ts +26 -0
  285. package/dist/service/stepfunctions/command/machine/sim-state-machine-delete.js +29 -0
  286. package/dist/service/stepfunctions/command/machine/sim-state-machine-lookup.d.ts +7 -0
  287. package/dist/service/stepfunctions/command/machine/sim-state-machine-lookup.js +12 -3
  288. package/dist/service/stepfunctions/command/machine/sim-state-machine-update.d.ts +19 -0
  289. package/dist/service/stepfunctions/command/machine/{sim-state-machine-writes.js → sim-state-machine-update.js} +3 -14
  290. package/dist/service/stepfunctions/sim-step-functions.d.ts +8 -2
  291. package/dist/service/stepfunctions/sim-step-functions.js +26 -9
  292. package/dist/service/sts/auth-z/assume-role-auth-z-coordinator.d.ts +9 -2
  293. package/dist/service/sts/auth-z/assume-role-auth-z-coordinator.js +2 -2
  294. package/dist/service/sts/auth-z/assume-role-source-account-auth-z.d.ts +10 -4
  295. package/dist/service/sts/auth-z/assume-role-source-account-auth-z.js +8 -7
  296. package/dist/service/sts/auth-z/assume-role-target-auth-z.d.ts +2 -2
  297. package/dist/service/sts/auth-z/assume-role-trust-policy-authorizer.d.ts +6 -2
  298. package/dist/service/sts/auth-z/assume-role-trust-policy-authorizer.js +14 -11
  299. package/dist/service/sts/command/assume-role/assume-role.handler.d.ts +10 -1
  300. package/dist/service/sts/command/assume-role/assume-role.handler.js +6 -2
  301. package/dist/service/sts/command/get-caller-identity/get-caller-identity.handler.d.ts +10 -1
  302. package/dist/service/sts/command/get-caller-identity/get-caller-identity.handler.js +5 -1
  303. package/dist/service/sts/service-role/sim-service-role.js +5 -1
  304. package/dist/service/sts/sim-sts.d.ts +18 -1
  305. package/dist/service/sts/sim-sts.js +8 -0
  306. package/dist/util/memo/bounded-memo.d.ts +36 -0
  307. package/dist/util/memo/bounded-memo.js +58 -0
  308. package/docs/README.md +54 -0
  309. package/docs/ai-skill/README.md +69 -0
  310. package/docs/cli/README.md +284 -0
  311. package/docs/factories/README.md +140 -0
  312. package/docs/lint/README.md +176 -0
  313. package/docs/non-aws-dependencies/README.md +261 -0
  314. package/docs/sdk/README.md +274 -0
  315. package/docs/serve/README.md +1126 -0
  316. package/docs/services/acm/README.md +823 -0
  317. package/docs/services/apigateway/README.md +1919 -0
  318. package/docs/services/apigatewayv2/README.md +2678 -0
  319. package/docs/services/athena/README.md +1044 -0
  320. package/docs/services/bedrock/README.md +350 -0
  321. package/docs/services/cloudformation/README.md +3625 -0
  322. package/docs/services/cloudfront/README.md +3098 -0
  323. package/docs/services/cloudwatch/README.md +422 -0
  324. package/docs/services/cognito/README.md +4924 -0
  325. package/docs/services/dynamodb/README.md +3785 -0
  326. package/docs/services/ecr/README.md +302 -0
  327. package/docs/services/ecs/README.md +2021 -0
  328. package/docs/services/elbv2/README.md +1901 -0
  329. package/docs/services/eventbridge/README.md +1118 -0
  330. package/docs/services/firehose/README.md +811 -0
  331. package/docs/services/glue/README.md +507 -0
  332. package/docs/services/iam/README.md +1578 -0
  333. package/docs/services/kinesis/README.md +455 -0
  334. package/docs/services/kms/README.md +664 -0
  335. package/docs/services/lambda/README.md +3719 -0
  336. package/docs/services/logs/README.md +882 -0
  337. package/docs/services/organizations/README.md +574 -0
  338. package/docs/services/personalize/README.md +835 -0
  339. package/docs/services/rekognition/README.md +1070 -0
  340. package/docs/services/route53/README.md +1783 -0
  341. package/docs/services/s3/README.md +3029 -0
  342. package/docs/services/scheduler/README.md +814 -0
  343. package/docs/services/secretsmanager/README.md +670 -0
  344. package/docs/services/ses/README.md +1013 -0
  345. package/docs/services/sns/README.md +1904 -0
  346. package/docs/services/sqs/README.md +1185 -0
  347. package/docs/services/ssm/README.md +1096 -0
  348. package/docs/services/stepfunctions/README.md +1341 -0
  349. package/docs/services/sts/README.md +245 -0
  350. package/docs/services/wafv2/README.md +1380 -0
  351. package/docs/terraform/README.md +248 -0
  352. package/docs/time/README.md +284 -0
  353. package/llms.txt +59 -0
  354. package/package.json +7 -4
  355. package/dist/service/stepfunctions/command/machine/sim-state-machine-writes.d.ts +0 -25
@@ -0,0 +1,664 @@
1
+ # Simulated KMS
2
+
3
+ Yulin includes a simulated AWS Key Management Service (KMS) for tests and local development.
4
+
5
+ Encryption is real. Each simulated key holds AES-256 key material and the operations run through
6
+ Node.js's own `crypto`. A ciphertext can only be read with its key, and a decryption with the wrong
7
+ encryption context fails.
8
+
9
+ KMS-specific types are imported from the `@kensio/yulin/kms` subpath.
10
+
11
+ ## Encrypting and decrypting
12
+
13
+ Create a key and use it. `Decrypt` needs no `KeyId` for a symmetric key, because the ciphertext
14
+ already names the key that produced it.
15
+
16
+ ```typescript sim-kms-encrypt-decrypt
17
+ /**
18
+ * Encrypting and decrypting with a simulated KMS key.
19
+ */
20
+
21
+ import {
22
+ CreateKeyCommand,
23
+ DecryptCommand,
24
+ EncryptCommand,
25
+ } from "@aws-sdk/client-kms";
26
+
27
+ import { SimAws } from "@kensio/yulin";
28
+
29
+ const simAws = new SimAws();
30
+ const kms = simAws.kms();
31
+
32
+ const created = await kms.createKey(
33
+ new CreateKeyCommand({ Description: "Application key" }),
34
+ );
35
+
36
+ const encrypted = await kms.encrypt(
37
+ new EncryptCommand({
38
+ KeyId: created.KeyMetadata?.Arn,
39
+ Plaintext: Buffer.from("hunter2", "utf8"),
40
+ }),
41
+ );
42
+
43
+ const decrypted = await kms.decrypt(
44
+ new DecryptCommand({ CiphertextBlob: encrypted.CiphertextBlob }),
45
+ );
46
+
47
+ console.log(Buffer.from(decrypted.Plaintext ?? []).toString("utf8")); // "hunter2"
48
+ ```
49
+
50
+ The ciphertext blob is opaque. Only the `SimAws` instance that produced it can read it. Real AWS and
51
+ any second `SimAws` instance both reject it.
52
+
53
+ ## Encryption context
54
+
55
+ An encryption context is non-secret key/value data bound to a ciphertext. Decryption with a
56
+ different context fails. That ties a ciphertext to the thing it belongs to.
57
+
58
+ ```typescript sim-kms-encryption-context
59
+ /**
60
+ * Binding an encryption context to a simulated KMS ciphertext.
61
+ */
62
+
63
+ import {
64
+ CreateKeyCommand,
65
+ DecryptCommand,
66
+ EncryptCommand,
67
+ } from "@aws-sdk/client-kms";
68
+
69
+ import { SimAws } from "@kensio/yulin";
70
+ import { SimKmsInvalidCiphertextException } from "@kensio/yulin/kms";
71
+
72
+ const simAws = new SimAws();
73
+ const kms = simAws.kms();
74
+
75
+ const created = await kms.createKey(new CreateKeyCommand({}));
76
+
77
+ const encrypted = await kms.encrypt(
78
+ new EncryptCommand({
79
+ KeyId: created.KeyMetadata?.Arn,
80
+ Plaintext: Buffer.from("hunter2", "utf8"),
81
+ EncryptionContext: { tenant: "acme" },
82
+ }),
83
+ );
84
+
85
+ try {
86
+ await kms.decrypt(
87
+ new DecryptCommand({
88
+ CiphertextBlob: encrypted.CiphertextBlob,
89
+ EncryptionContext: { tenant: "other" },
90
+ }),
91
+ );
92
+ } catch (error) {
93
+ // The wrong context fails the cipher's own authentication, exactly as it
94
+ // does on real KMS.
95
+ console.log(error instanceof SimKmsInvalidCiphertextException); // true
96
+ }
97
+ ```
98
+
99
+ The context is an unordered map. The same pairs written in a different order still decrypt.
100
+
101
+ ## Envelope encryption
102
+
103
+ `Encrypt` takes at most 4096 bytes. That limit is what makes envelope encryption necessary.
104
+ `GenerateDataKey` returns a data key twice, once in the clear to encrypt your data with, and once
105
+ encrypted under the KMS key to store alongside it.
106
+
107
+ ```typescript sim-kms-generate-data-key
108
+ /**
109
+ * Envelope encryption with a simulated KMS data key.
110
+ */
111
+
112
+ import {
113
+ CreateKeyCommand,
114
+ DecryptCommand,
115
+ GenerateDataKeyCommand,
116
+ } from "@aws-sdk/client-kms";
117
+
118
+ import { SimAws } from "@kensio/yulin";
119
+
120
+ const simAws = new SimAws();
121
+ const kms = simAws.kms();
122
+
123
+ const created = await kms.createKey(new CreateKeyCommand({}));
124
+
125
+ const dataKey = await kms.generateDataKey(
126
+ new GenerateDataKeyCommand({
127
+ KeyId: created.KeyMetadata?.Arn,
128
+ KeySpec: "AES_256",
129
+ }),
130
+ );
131
+
132
+ console.log(dataKey.Plaintext?.length); // 32
133
+
134
+ // Store dataKey.CiphertextBlob with the data; discard the plaintext copy.
135
+ const recovered = await kms.decrypt(
136
+ new DecryptCommand({ CiphertextBlob: dataKey.CiphertextBlob }),
137
+ );
138
+
139
+ console.log(recovered.Plaintext?.length); // 32
140
+ ```
141
+
142
+ ## Signing and verifying
143
+
144
+ A key created with `KeyUsage: SIGN_VERIFY` holds a real key pair, and the signatures are real
145
+ signatures. A key spec is required, because the default `SYMMETRIC_DEFAULT` spec cannot sign.
146
+
147
+ ```typescript sim-kms-sign-verify
148
+ /**
149
+ * Signing and verifying with a simulated asymmetric KMS key.
150
+ */
151
+
152
+ import {
153
+ CreateKeyCommand,
154
+ SignCommand,
155
+ VerifyCommand,
156
+ } from "@aws-sdk/client-kms";
157
+
158
+ import { SimAws } from "@kensio/yulin";
159
+
160
+ const simAws = new SimAws();
161
+ const kms = simAws.kms();
162
+
163
+ const created = await kms.createKey(
164
+ new CreateKeyCommand({
165
+ KeySpec: "ECC_NIST_P256",
166
+ KeyUsage: "SIGN_VERIFY",
167
+ }),
168
+ );
169
+
170
+ const message = Buffer.from("order-1234", "utf8");
171
+
172
+ const signed = await kms.sign(
173
+ new SignCommand({
174
+ KeyId: created.KeyMetadata?.Arn,
175
+ Message: message,
176
+ SigningAlgorithm: "ECDSA_SHA_256",
177
+ }),
178
+ );
179
+
180
+ const verified = await kms.verify(
181
+ new VerifyCommand({
182
+ KeyId: created.KeyMetadata?.Arn,
183
+ Message: message,
184
+ Signature: signed.Signature,
185
+ SigningAlgorithm: "ECDSA_SHA_256",
186
+ }),
187
+ );
188
+
189
+ console.log(verified.SignatureValid); // true
190
+ ```
191
+
192
+ `Verify` raises `KMSInvalidSignatureException` for a signature that fails to check out. Real KMS
193
+ does the same, in place of answering `SignatureValid: false`.
194
+
195
+ The key specs simulated are `ECC_NIST_P256`, `ECC_NIST_P384`, `ECC_NIST_P521`, `ECC_SECG_P256K1`,
196
+ `RSA_2048`, `RSA_3072` and `RSA_4096`. Each ECC spec offers the one ECDSA algorithm paired with its
197
+ curve. Each RSA spec offers all six RSASSA algorithms. A signing algorithm the key spec leaves out
198
+ is refused. So is `Sign` against an encryption key, and `Encrypt` against a signing key.
199
+
200
+ `DescribeKey` reports the key's own spec, usage and algorithms. Code that branches on them branches
201
+ the same way it would on AWS.
202
+
203
+ ### Verifying outside KMS
204
+
205
+ `GetPublicKey` returns the public key as DER `SubjectPublicKeyInfo`, the encoding real KMS returns.
206
+ A verifier that never sees the simulator accepts a signature made in it.
207
+
208
+ ```typescript sim-kms-public-key
209
+ /**
210
+ * Verifying a simulated KMS signature outside KMS, with its public key.
211
+ */
212
+
213
+ import { createPublicKey, verify } from "node:crypto";
214
+
215
+ import {
216
+ CreateKeyCommand,
217
+ GetPublicKeyCommand,
218
+ SignCommand,
219
+ } from "@aws-sdk/client-kms";
220
+
221
+ import { SimAws } from "@kensio/yulin";
222
+
223
+ const simAws = new SimAws();
224
+ const kms = simAws.kms();
225
+
226
+ const created = await kms.createKey(
227
+ new CreateKeyCommand({
228
+ KeySpec: "ECC_NIST_P256",
229
+ KeyUsage: "SIGN_VERIFY",
230
+ }),
231
+ );
232
+
233
+ const message = Buffer.from("order-1234", "utf8");
234
+
235
+ const signed = await kms.sign(
236
+ new SignCommand({
237
+ KeyId: created.KeyMetadata?.Arn,
238
+ Message: message,
239
+ SigningAlgorithm: "ECDSA_SHA_256",
240
+ }),
241
+ );
242
+
243
+ const fetched = await kms.getPublicKey(
244
+ new GetPublicKeyCommand({ KeyId: created.KeyMetadata?.Arn }),
245
+ );
246
+
247
+ const publicKey = createPublicKey({
248
+ key: Buffer.from(fetched.PublicKey ?? new Uint8Array()),
249
+ format: "der",
250
+ type: "spki",
251
+ });
252
+
253
+ console.log(
254
+ verify("sha256", message, publicKey, signed.Signature ?? new Uint8Array()),
255
+ ); // true
256
+ ```
257
+
258
+ ECDSA signatures are DER encoded, and RSASSA-PSS signatures use a salt the length of the digest,
259
+ both matching what KMS produces. `GetPublicKey` against a symmetric key is
260
+ `UnsupportedOperationException`, since there is no public key to hand out.
261
+
262
+ ## Key policies and IAM
263
+
264
+ Every KMS key has a policy, and it cannot be removed. An IAM policy granting `kms:Decrypt` only
265
+ takes effect where the key's own policy admits the caller. How it admits them decides what else is
266
+ needed:
267
+
268
+ - A statement naming the caller grants access outright. A role with no permissions of its own can
269
+ still use the key.
270
+ - A statement naming the account root only delegates to that account's IAM. The caller still needs
271
+ an identity policy allowing the action. The default key policy is of this kind.
272
+
273
+ ```typescript sim-kms-key-policy
274
+ /**
275
+ * A simulated KMS key policy deciding who can use the key.
276
+ */
277
+
278
+ import { CreateRoleCommand } from "@aws-sdk/client-iam";
279
+ import { CreateKeyCommand, EncryptCommand } from "@aws-sdk/client-kms";
280
+
281
+ import { SimAws } from "@kensio/yulin";
282
+ import { SimIamAccessDenied } from "@kensio/yulin/iam";
283
+
284
+ const simAws = new SimAws();
285
+ const accountId = simAws.defaultAccountId;
286
+
287
+ const role = await simAws.iam().createRole(
288
+ new CreateRoleCommand({
289
+ RoleName: "Encrypter",
290
+ AssumeRolePolicyDocument: JSON.stringify({
291
+ Version: "2012-10-17",
292
+ Statement: {
293
+ Effect: "Allow",
294
+ Principal: { AWS: `arn:aws:iam::${accountId}:root` },
295
+ Action: "sts:AssumeRole",
296
+ },
297
+ }),
298
+ }),
299
+ );
300
+
301
+ // A key policy naming the Role directly, with no delegation to the Account.
302
+ const created = await simAws.kms().createKey(
303
+ new CreateKeyCommand({
304
+ Policy: JSON.stringify({
305
+ Version: "2012-10-17",
306
+ Statement: [
307
+ {
308
+ Effect: "Allow",
309
+ Principal: { AWS: role.Role.Arn },
310
+ Action: "kms:Encrypt",
311
+ Resource: "*",
312
+ },
313
+ ],
314
+ }),
315
+ }),
316
+ );
317
+
318
+ // The Role can encrypt, with no identity policy of its own.
319
+ await simAws.kms().encrypt(
320
+ new EncryptCommand({
321
+ KeyId: created.KeyMetadata?.Arn,
322
+ Plaintext: Buffer.from("hunter2", "utf8"),
323
+ }),
324
+ { caller: { kind: "arn", arn: role.Role.Arn } },
325
+ );
326
+
327
+ // The Account root cannot, because this key policy does not admit it.
328
+ try {
329
+ await simAws.kms().encrypt(
330
+ new EncryptCommand({
331
+ KeyId: created.KeyMetadata?.Arn,
332
+ Plaintext: Buffer.from("hunter2", "utf8"),
333
+ }),
334
+ );
335
+ } catch (error) {
336
+ console.log(error instanceof SimIamAccessDenied); // true
337
+ }
338
+ ```
339
+
340
+ Replacing a key policy with `PutKeyPolicyCommand` can lock an account out of its own key, as it can
341
+ on real KMS.
342
+
343
+ ## AWS managed keys and `kms:ViaService`
344
+
345
+ An alias beginning `alias/aws/` names an AWS managed key, and the key is created the first time
346
+ something references it. Such a key gets the policy real AWS gives it, which differs from the
347
+ customer default:
348
+
349
+ - Use of the key is allowed to any principal in the owning account, but only when `kms:ViaService`
350
+ names the service that owns the key, such as `ssm.us-east-1.amazonaws.com` for `aws/ssm`.
351
+ - The account root is allowed to read the key's metadata. That is the whole of what this policy
352
+ delegates to IAM.
353
+
354
+ That is why a role holding `kms:Decrypt` on such a key cannot use it by calling KMS itself.
355
+
356
+ `kms:ViaService` is set by the service making the call on the caller's behalf. Sim SSM does this for
357
+ `SecureString` parameters. Code calling simulated KMS directly sets it with the `viaService` request
358
+ option, naming the service on its own (`ssm`), since the region is the key's.
359
+
360
+ A service passing on the caller's own KMS permissions sets `withCallerPermissions` alongside it.
361
+ What the policy above admits is the service a request came through. A request carrying this option
362
+ is allowed only where IAM allows the caller the KMS action too, and a key policy naming the caller
363
+ allows it on its own. Sim SSM sets the option when it decrypts a `SecureString`. A role holding
364
+ `ssm:GetParameter` and no `kms:Decrypt` is refused the decrypted value.
365
+
366
+ ```typescript sim-kms-aws-managed-key
367
+ /**
368
+ * An AWS managed key, usable only through the service that owns it.
369
+ */
370
+
371
+ import { EncryptCommand, GetKeyPolicyCommand } from "@aws-sdk/client-kms";
372
+
373
+ import { SimAws } from "@kensio/yulin";
374
+ import { SimIamAccessDenied } from "@kensio/yulin/iam";
375
+
376
+ const simAws = new SimAws();
377
+
378
+ // A request reaching the key through Systems Manager, as Parameter Store makes
379
+ // it. No KMS permission is involved.
380
+ const encrypted = await simAws.kms().encrypt(
381
+ new EncryptCommand({
382
+ KeyId: "alias/aws/ssm",
383
+ Plaintext: Buffer.from("hunter2", "utf8"),
384
+ }),
385
+ { viaService: "ssm" },
386
+ );
387
+
388
+ console.log(encrypted.KeyId); // the ARN of the aws/ssm key
389
+
390
+ // The same request made directly is denied, whatever IAM allows.
391
+ try {
392
+ await simAws.kms().encrypt(
393
+ new EncryptCommand({
394
+ KeyId: "alias/aws/ssm",
395
+ Plaintext: Buffer.from("hunter2", "utf8"),
396
+ }),
397
+ );
398
+ } catch (error) {
399
+ console.log(error instanceof SimIamAccessDenied); // true
400
+ }
401
+
402
+ // Reading the key's metadata is allowed, because that much is delegated.
403
+ const policy = await simAws
404
+ .kms()
405
+ .getKeyPolicy(new GetKeyPolicyCommand({ KeyId: "alias/aws/ssm" }));
406
+
407
+ console.log(policy.Policy); // the via-service-scoped policy
408
+ ```
409
+
410
+ A key policy of your own can use `kms:ViaService` too, with the ordinary condition operators, and it
411
+ matches for requests carrying the option. A request that names no service has no value for the key,
412
+ and a condition on it stays unmatched.
413
+
414
+ ## Naming a key
415
+
416
+ Every operation takes its target as a `KeyId`, in any of the four forms real KMS accepts. Those are
417
+ a key ID, a key ARN, an alias name such as `alias/app-key`, and an alias ARN.
418
+
419
+ A key ARN or alias ARN naming another account or region resolves to no key at all. Its identifier is
420
+ never read out and looked up locally. A foreign ARN cannot reach a key that happens to share an
421
+ identifier.
422
+
423
+ Aliases beginning `alias/aws/` are reserved for AWS managed keys. `CreateAlias` refuses to create
424
+ one, but referencing one brings the key into existence, the way an AWS managed key appears on real
425
+ AWS when a service first needs it.
426
+
427
+ ```typescript sim-kms-aliases
428
+ /**
429
+ * Naming a simulated KMS key by alias.
430
+ */
431
+
432
+ import {
433
+ CreateAliasCommand,
434
+ CreateKeyCommand,
435
+ DescribeKeyCommand,
436
+ EncryptCommand,
437
+ } from "@aws-sdk/client-kms";
438
+
439
+ import { SimAws } from "@kensio/yulin";
440
+
441
+ const simAws = new SimAws();
442
+ const kms = simAws.kms();
443
+
444
+ const created = await kms.createKey(new CreateKeyCommand({}));
445
+ await kms.createAlias(
446
+ new CreateAliasCommand({
447
+ AliasName: "alias/app-key",
448
+ TargetKeyId: created.KeyMetadata?.KeyId,
449
+ }),
450
+ );
451
+
452
+ // The alias reaches the same key as its ID or ARN would.
453
+ await kms.encrypt(
454
+ new EncryptCommand({
455
+ KeyId: "alias/app-key",
456
+ Plaintext: Buffer.from("hunter2", "utf8"),
457
+ }),
458
+ );
459
+
460
+ // An AWS managed key appears the first time its alias is referenced.
461
+ const managed = await kms.describeKey(
462
+ new DescribeKeyCommand({ KeyId: "alias/aws/s3" }),
463
+ );
464
+
465
+ console.log(managed.KeyMetadata?.KeyManager); // "AWS"
466
+ ```
467
+
468
+ ## Key state and deletion
469
+
470
+ A key can be disabled and re-enabled later. A disabled key stays present, and refuses to be used.
471
+
472
+ Deletion is never immediate. `ScheduleKeyDeletion` sets a recovery window of 7 to 30 days, defaulting
473
+ to 30. During that window the key refuses to be used but can still be recovered with
474
+ `CancelKeyDeletion`. Cancelling leaves the key disabled. Re-enabling it is a separate step.
475
+
476
+ A disabled key fails cryptographic operations with `DisabledException`. A key pending deletion fails
477
+ with `KMSInvalidStateException`. The two are distinct. One means the key can be enabled again, the
478
+ other that it is on its way out.
479
+
480
+ ## Scoping
481
+
482
+ KMS keys belong to an account and a region, as they do on real AWS. A key created in one region
483
+ cannot be found or used from another, and a ciphertext produced under it cannot be decrypted
484
+ elsewhere.
485
+
486
+ ```typescript sim-kms-scoping
487
+ /**
488
+ * Simulated KMS keys are scoped to an account and region.
489
+ */
490
+
491
+ import { CreateKeyCommand, DescribeKeyCommand } from "@aws-sdk/client-kms";
492
+
493
+ import { SimAws } from "@kensio/yulin";
494
+ import { SimKmsNotFoundException } from "@kensio/yulin/kms";
495
+
496
+ const simAws = new SimAws();
497
+
498
+ const created = await simAws
499
+ .account("222222222222")
500
+ .region("eu-west-2")
501
+ .kms()
502
+ .createKey(new CreateKeyCommand({}));
503
+
504
+ try {
505
+ await simAws
506
+ .account("222222222222")
507
+ .region("us-east-1")
508
+ .kms()
509
+ .describeKey(new DescribeKeyCommand({ KeyId: created.KeyMetadata?.Arn }));
510
+ } catch (error) {
511
+ console.log(error instanceof SimKmsNotFoundException); // true
512
+ }
513
+ ```
514
+
515
+ ## Deploying a key from CloudFormation
516
+
517
+ Simulated CloudFormation creates a key from an `AWS::KMS::Key` resource and points an
518
+ `AWS::KMS::Alias` at it, in the stack's account and region. The key comes out of the same `CreateKey`
519
+ path an SDK caller uses, with real key material. A `KeyPolicy` the template declares becomes the key
520
+ policy. Omitting `KeyPolicy` gets the default root-delegation policy, as `CreateKey` with no
521
+ `Policy` does.
522
+
523
+ `Ref` on the key gives its key ID, as on real AWS, and `Fn::GetAtt` gives `Arn` or `KeyId`. `Ref` on
524
+ the alias gives the alias name, such as `alias/app-key`, and an alias name is itself usable as a
525
+ `KeyId`. So a property wanting a key ID takes the `Ref`, while an IAM policy resource wanting the
526
+ key needs `Fn::GetAtt … Arn`.
527
+
528
+ ```typescript sim-kms-cloudformation-key
529
+ /**
530
+ * Deploying a KMS key and alias from a CloudFormation template, then
531
+ * encrypting through the alias the template created.
532
+ */
533
+
534
+ import { DecryptCommand, EncryptCommand } from "@aws-sdk/client-kms";
535
+
536
+ import { SimAws } from "@kensio/yulin";
537
+
538
+ const simAws = new SimAws();
539
+
540
+ const stack = await simAws.cloudFormation().deployTemplate({
541
+ stackName: "app-stack",
542
+ template: {
543
+ Resources: {
544
+ AppKey: {
545
+ Type: "AWS::KMS::Key",
546
+ Properties: { Description: "Application data key" },
547
+ },
548
+ AppKeyAlias: {
549
+ Type: "AWS::KMS::Alias",
550
+ Properties: {
551
+ AliasName: "alias/app-key",
552
+ TargetKeyId: { Ref: "AppKey" },
553
+ },
554
+ },
555
+ },
556
+ Outputs: {
557
+ KeyArn: { Value: { "Fn::GetAtt": ["AppKey", "Arn"] } },
558
+ },
559
+ },
560
+ });
561
+ await stack.waitForDeployComplete();
562
+
563
+ const kms = simAws.kms();
564
+
565
+ const encrypted = await kms.encrypt(
566
+ new EncryptCommand({
567
+ KeyId: "alias/app-key",
568
+ Plaintext: Buffer.from("hunter2", "utf8"),
569
+ }),
570
+ );
571
+
572
+ const decrypted = await kms.decrypt(
573
+ new DecryptCommand({ CiphertextBlob: encrypted.CiphertextBlob }),
574
+ );
575
+
576
+ console.log(Buffer.from(decrypted.Plaintext ?? []).toString("utf8")); // "hunter2"
577
+ console.log(stack.output("KeyArn")); // "arn:aws:kms:...:key/..."
578
+ ```
579
+
580
+ A property asking for behaviour Yulin leaves out still deploys. The key is created without it, and
581
+ the property is recorded in
582
+ [`stack.ignoredProperties`](https://yulinsim.dev/services/cloudformation/#properties-a-resource-was-created-without).
583
+ The template deploys, and the record says what the key leaves out. `EnableKeyRotation`,
584
+ `RotationPeriodInDays`, `MultiRegion` and `Tags` are all recorded that way. The key encrypts and
585
+ decrypts, its material stays as it was, it exists in one region, and its tags go unread.
586
+
587
+ A `KeySpec` or `KeyUsage` pair simulated KMS has no model for, or an `Origin` other than `AWS_KMS`,
588
+ is refused by `CreateKey` in the same terms it refuses an SDK caller, since there is no key to
589
+ create at all. `Enabled: false` is supported, and deploys a key that is disabled from the moment it
590
+ exists.
591
+
592
+ ## Inside a simulated Lambda handler
593
+
594
+ Function code requiring `@aws-sdk/client-kms` is routed into the same simulated AWS environment, with
595
+ the function's execution role as the caller. A handler that decrypts a value therefore has to be
596
+ allowed to, by both the key policy and the role's identity policy, the same as on real AWS. See
597
+ [simulated Lambda](https://yulinsim.dev/services/lambda/) for how function code and execution roles work.
598
+
599
+ ## Available functionality
600
+
601
+ Sim KMS currently supports:
602
+
603
+ - `CreateKeyCommand`, for symmetric encryption keys and asymmetric signing keys
604
+ - `DescribeKeyCommand` and `ListKeysCommand`
605
+ - `GetKeyPolicyCommand` and `PutKeyPolicyCommand`
606
+ - `EncryptCommand` and `DecryptCommand`, including encryption context
607
+ - `GenerateDataKeyCommand`, by `KeySpec` or `NumberOfBytes`
608
+ - `SignCommand`, `VerifyCommand` and `GetPublicKeyCommand`, for asymmetric signing keys
609
+ - `CreateAliasCommand` and `ListAliasesCommand`, including AWS managed key aliases
610
+ - `EnableKeyCommand`, `DisableKeyCommand`, `ScheduleKeyDeletionCommand`, `CancelKeyDeletionCommand`
611
+ - Key policy evaluation by simulated IAM
612
+ - Key ARNs, key IDs, alias names and alias ARNs as interchangeable ways to name a key
613
+ - The `AWS::KMS::Key` and `AWS::KMS::Alias` CloudFormation resources
614
+ - Calls made from inside a simulated Lambda handler, authorized as the function's execution role
615
+
616
+ ## Limitations
617
+
618
+ Current documented limitations:
619
+
620
+ - Only encryption with a symmetric key and signing with an asymmetric key are simulated. Left out
621
+ are asymmetric encryption (`RSAES_OAEP_SHA_1` and `RSAES_OAEP_SHA_256`), HMAC keys and
622
+ `GENERATE_VERIFY_MAC`, key agreement and `DeriveSharedSecret`, the `SM2` key spec, and
623
+ `ReEncrypt`. An RSA key asked for with `KeyUsage: ENCRYPT_DECRYPT` is refused, which real KMS
624
+ allows.
625
+ - `Sign` and `Verify` take a `MessageType` of `RAW` only. A `DIGEST` message is refused. Node cannot
626
+ sign a digest that has already been computed, because `crypto.sign` with no algorithm hashes what
627
+ it is given. The resulting signature would differ from the one real KMS makes, and would fail to
628
+ verify against the message anywhere outside the simulator.
629
+ - Generating an RSA key pair is real key generation. An `RSA_4096` key costs a second or so of test
630
+ time. The ECC specs are effectively free.
631
+ - Imported key material and custom key stores are left out. `Origin` other than `AWS_KMS` is
632
+ refused.
633
+ - Grants (`CreateGrant` and friends) are left out.
634
+ - Key material stays as it was created. An `AWS::KMS::Key` declaring `EnableKeyRotation` or
635
+ `RotationPeriodInDays` is created without it, and the property is recorded in
636
+ `stack.ignoredProperties`.
637
+ - A Multi-Region key comes out as an ordinary key in one region. An `AWS::KMS::Key` declaring
638
+ `MultiRegion: true` deploys that way, and the property is recorded.
639
+ - `AWS::KMS::Key` accepts but ignores `PendingWindowInDays` and `BypassPolicyLockoutSafetyCheck`.
640
+ Both are inert here. A stack teardown schedules the key for deletion with the default window, and
641
+ simulated KMS applies no policy lockout safety check to bypass.
642
+ - An `AWS::KMS::Alias` retargeted by a stack update is deleted and created again pointing at the new
643
+ key, because a stack update replaces a changed resource and simulated KMS has no `UpdateAlias`.
644
+ - A template declaring `AWS::KMS::Grant` or `AWS::KMS::ReplicaKey` is refused.
645
+ - A key pending deletion stays in that state indefinitely. Advancing the simulated clock past the
646
+ recovery window leaves it there, and the key ID stays taken.
647
+ - `UpdateAlias` is absent. An alias is retargeted by deleting it and creating it again.
648
+ - Tags, `ListResourceTags` and the `aws:ResourceTag` condition key are left out. An
649
+ `AWS::KMS::Key` declaring `Tags` deploys with the tags dropped and the property recorded. A policy
650
+ condition written around one fails to match here, where on AWS it would match.
651
+ - `kms:ViaService` and `kms:CallerAccount` are the KMS-specific condition keys derived. A policy
652
+ relying on `kms:EncryptionContext:*` or any other one fails to match. Ordinary condition operators
653
+ on values sim IAM does supply work as usual.
654
+ - The service an AWS managed key belongs to is taken from its alias. `alias/aws/ebs` is scoped to
655
+ `ebs.<region>.amazonaws.com`. Real AWS scopes that one to EC2. The two agree for every service
656
+ Yulin simulates.
657
+ - Key material lives in process memory for the lifetime of the `SimAws` instance. Anything sharing
658
+ the process can reach it.
659
+ - Sim SSM encrypts `SecureString` parameters with simulated keys, checking `kms:Encrypt` and
660
+ `kms:Decrypt`, and sim Secrets Manager encrypts every secret version, checking
661
+ `kms:GenerateDataKey` and `kms:Decrypt`. No other simulated service uses simulated keys. Sim S3,
662
+ sim DynamoDB and sim Lambda environment variables leave them alone, and skip the `kms:Decrypt`
663
+ check.
664
+ - KMS is not served as an HTTP API by `serveSimAws`.