@kensio/yulin 1.16.0 → 1.16.1

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 (196) hide show
  1. package/README.md +44 -46
  2. package/dist/service/aws/factory/sim-aws-account-region-service-builder.js +2 -2
  3. package/dist/service/aws/factory/sim-aws-account-region-service-builder.js.map +1 -1
  4. package/dist/service/cloudfront/origin/custom/sim-cf-custom-origin-request.d.ts +3 -2
  5. package/dist/service/cloudfront/origin/custom/sim-cf-custom-origin-request.d.ts.map +1 -1
  6. package/dist/service/cloudfront/origin/custom/sim-cf-custom-origin-request.js.map +1 -1
  7. package/dist/service/cloudfront/origin/custom/sim-cf-custom-origin-signer.d.ts +5 -2
  8. package/dist/service/cloudfront/origin/custom/sim-cf-custom-origin-signer.d.ts.map +1 -1
  9. package/dist/service/cloudfront/origin/custom/sim-cf-custom-origin-signer.js +38 -2
  10. package/dist/service/cloudfront/origin/custom/sim-cf-custom-origin-signer.js.map +1 -1
  11. package/dist/service/cloudfront/origin/custom/sim-cf-function-url-origin-template.factory.d.ts.map +1 -1
  12. package/dist/service/cloudfront/origin/custom/sim-cf-function-url-origin-template.factory.js +5 -2
  13. package/dist/service/cloudfront/origin/custom/sim-cf-function-url-origin-template.factory.js.map +1 -1
  14. package/dist/service/cognito/command/hosted/hosted-auth.command.d.ts +10 -0
  15. package/dist/service/cognito/command/hosted/hosted-auth.command.d.ts.map +1 -1
  16. package/dist/service/cognito/command/hosted/sim-cognito-authorize-endpoint.d.ts +14 -13
  17. package/dist/service/cognito/command/hosted/sim-cognito-authorize-endpoint.d.ts.map +1 -1
  18. package/dist/service/cognito/command/hosted/sim-cognito-authorize-endpoint.js +14 -18
  19. package/dist/service/cognito/command/hosted/sim-cognito-authorize-endpoint.js.map +1 -1
  20. package/dist/service/cognito/command/hosted/sim-cognito-authorize-request.d.ts +15 -6
  21. package/dist/service/cognito/command/hosted/sim-cognito-authorize-request.d.ts.map +1 -1
  22. package/dist/service/cognito/command/hosted/sim-cognito-authorize-request.js +26 -19
  23. package/dist/service/cognito/command/hosted/sim-cognito-authorize-request.js.map +1 -1
  24. package/dist/service/cognito/command/hosted/sim-cognito-hosted-commands.d.ts.map +1 -1
  25. package/dist/service/cognito/command/hosted/sim-cognito-hosted-commands.js +5 -1
  26. package/dist/service/cognito/command/hosted/sim-cognito-hosted-commands.js.map +1 -1
  27. package/dist/service/cognito/command/hosted/sim-cognito-hosted-password-sign-in.d.ts +41 -0
  28. package/dist/service/cognito/command/hosted/sim-cognito-hosted-password-sign-in.d.ts.map +1 -0
  29. package/dist/service/cognito/command/hosted/sim-cognito-hosted-password-sign-in.js +71 -0
  30. package/dist/service/cognito/command/hosted/sim-cognito-hosted-password-sign-in.js.map +1 -0
  31. package/dist/service/cognito/command/hosted/sim-cognito-hosted-sign-in.d.ts +32 -0
  32. package/dist/service/cognito/command/hosted/sim-cognito-hosted-sign-in.d.ts.map +1 -0
  33. package/dist/service/cognito/command/hosted/sim-cognito-hosted-sign-in.js +36 -0
  34. package/dist/service/cognito/command/hosted/sim-cognito-hosted-sign-in.js.map +1 -0
  35. package/dist/service/cognito/error/sim-cognito-managed-login.error.d.ts +22 -0
  36. package/dist/service/cognito/error/sim-cognito-managed-login.error.d.ts.map +1 -0
  37. package/dist/service/cognito/error/sim-cognito-managed-login.error.js +32 -0
  38. package/dist/service/cognito/error/sim-cognito-managed-login.error.js.map +1 -0
  39. package/dist/service/cognito/serve/page/sim-cognito-confirm-page.d.ts +29 -0
  40. package/dist/service/cognito/serve/page/sim-cognito-confirm-page.d.ts.map +1 -0
  41. package/dist/service/cognito/serve/page/sim-cognito-confirm-page.js +90 -0
  42. package/dist/service/cognito/serve/page/sim-cognito-confirm-page.js.map +1 -0
  43. package/dist/service/cognito/serve/page/sim-cognito-managed-login.d.ts +38 -0
  44. package/dist/service/cognito/serve/page/sim-cognito-managed-login.d.ts.map +1 -0
  45. package/dist/service/cognito/serve/page/sim-cognito-managed-login.js +62 -0
  46. package/dist/service/cognito/serve/page/sim-cognito-managed-login.js.map +1 -0
  47. package/dist/service/cognito/serve/page/sim-cognito-page-form.d.ts +47 -0
  48. package/dist/service/cognito/serve/page/sim-cognito-page-form.d.ts.map +1 -0
  49. package/dist/service/cognito/serve/page/sim-cognito-page-form.js +76 -0
  50. package/dist/service/cognito/serve/page/sim-cognito-page-form.js.map +1 -0
  51. package/dist/service/cognito/serve/page/sim-cognito-page-markup.d.ts +69 -0
  52. package/dist/service/cognito/serve/page/sim-cognito-page-markup.d.ts.map +1 -0
  53. package/dist/service/cognito/serve/page/sim-cognito-page-markup.js +111 -0
  54. package/dist/service/cognito/serve/page/sim-cognito-page-markup.js.map +1 -0
  55. package/dist/service/cognito/serve/page/sim-cognito-page-paths.d.ts +39 -0
  56. package/dist/service/cognito/serve/page/sim-cognito-page-paths.d.ts.map +1 -0
  57. package/dist/service/cognito/serve/page/sim-cognito-page-paths.js +59 -0
  58. package/dist/service/cognito/serve/page/sim-cognito-page-paths.js.map +1 -0
  59. package/dist/service/cognito/serve/page/sim-cognito-page-request.d.ts +22 -0
  60. package/dist/service/cognito/serve/page/sim-cognito-page-request.d.ts.map +1 -0
  61. package/dist/service/cognito/serve/page/sim-cognito-page-request.js +30 -0
  62. package/dist/service/cognito/serve/page/sim-cognito-page-request.js.map +1 -0
  63. package/dist/service/cognito/serve/page/sim-cognito-sign-in-page.d.ts +28 -0
  64. package/dist/service/cognito/serve/page/sim-cognito-sign-in-page.d.ts.map +1 -0
  65. package/dist/service/cognito/serve/page/sim-cognito-sign-in-page.js +45 -0
  66. package/dist/service/cognito/serve/page/sim-cognito-sign-in-page.js.map +1 -0
  67. package/dist/service/cognito/serve/page/sim-cognito-sign-up-page.d.ts +35 -0
  68. package/dist/service/cognito/serve/page/sim-cognito-sign-up-page.d.ts.map +1 -0
  69. package/dist/service/cognito/serve/page/sim-cognito-sign-up-page.js +85 -0
  70. package/dist/service/cognito/serve/page/sim-cognito-sign-up-page.js.map +1 -0
  71. package/dist/service/cognito/serve/sim-cognito-domain-endpoints.d.ts +20 -23
  72. package/dist/service/cognito/serve/sim-cognito-domain-endpoints.d.ts.map +1 -1
  73. package/dist/service/cognito/serve/sim-cognito-domain-endpoints.js +40 -19
  74. package/dist/service/cognito/serve/sim-cognito-domain-endpoints.js.map +1 -1
  75. package/dist/service/cognito/serve/sim-cognito-domain-request.d.ts +14 -0
  76. package/dist/service/cognito/serve/sim-cognito-domain-request.d.ts.map +1 -0
  77. package/dist/service/cognito/serve/sim-cognito-domain-request.js +2 -0
  78. package/dist/service/cognito/serve/sim-cognito-domain-request.js.map +1 -0
  79. package/dist/service/iam/sigv4/canonical/sim-iam-sigv4-payload-hash.d.ts +8 -0
  80. package/dist/service/iam/sigv4/canonical/sim-iam-sigv4-payload-hash.d.ts.map +1 -1
  81. package/dist/service/iam/sigv4/canonical/sim-iam-sigv4-payload-hash.js +14 -6
  82. package/dist/service/iam/sigv4/canonical/sim-iam-sigv4-payload-hash.js.map +1 -1
  83. package/dist/service/lambda/serve/auth/sim-lambda-url-payload-hash.d.ts +28 -0
  84. package/dist/service/lambda/serve/auth/sim-lambda-url-payload-hash.d.ts.map +1 -0
  85. package/dist/service/lambda/serve/auth/sim-lambda-url-payload-hash.js +56 -0
  86. package/dist/service/lambda/serve/auth/sim-lambda-url-payload-hash.js.map +1 -0
  87. package/dist/service/lambda/serve/response/sim-lambda-url-error-response.d.ts +16 -0
  88. package/dist/service/lambda/serve/response/sim-lambda-url-error-response.d.ts.map +1 -1
  89. package/dist/service/lambda/serve/response/sim-lambda-url-error-response.js +24 -0
  90. package/dist/service/lambda/serve/response/sim-lambda-url-error-response.js.map +1 -1
  91. package/dist/service/lambda/serve/sim-lambda-controller.d.ts +6 -0
  92. package/dist/service/lambda/serve/sim-lambda-controller.d.ts.map +1 -1
  93. package/dist/service/lambda/serve/sim-lambda-controller.js +11 -0
  94. package/dist/service/lambda/serve/sim-lambda-controller.js.map +1 -1
  95. package/dist/service/sns/cfn/subscription/sim-cfn-sns-subscription-properties.d.ts +4 -3
  96. package/dist/service/sns/cfn/subscription/sim-cfn-sns-subscription-properties.d.ts.map +1 -1
  97. package/dist/service/sns/cfn/subscription/sim-cfn-sns-subscription-properties.js +4 -3
  98. package/dist/service/sns/cfn/subscription/sim-cfn-sns-subscription-properties.js.map +1 -1
  99. package/dist/service/sns/cfn/subscription/sim-cfn-sns-subscription-property-names.d.ts +2 -2
  100. package/dist/service/sns/cfn/subscription/sim-cfn-sns-subscription-property-names.js +2 -2
  101. package/dist/service/sns/command/publish/sim-sns-publish-commands.d.ts +3 -0
  102. package/dist/service/sns/command/publish/sim-sns-publish-commands.d.ts.map +1 -1
  103. package/dist/service/sns/command/publish/sim-sns-publish-commands.js +4 -2
  104. package/dist/service/sns/command/publish/sim-sns-publish-commands.js.map +1 -1
  105. package/dist/service/sns/command/publish/sim-sns-publish-dispatch.d.ts +39 -0
  106. package/dist/service/sns/command/publish/sim-sns-publish-dispatch.d.ts.map +1 -0
  107. package/dist/service/sns/command/publish/sim-sns-publish-dispatch.js +42 -0
  108. package/dist/service/sns/command/publish/sim-sns-publish-dispatch.js.map +1 -0
  109. package/dist/service/sns/command/publish/sim-sns-publish-input.d.ts +3 -3
  110. package/dist/service/sns/command/publish/sim-sns-publish-input.d.ts.map +1 -1
  111. package/dist/service/sns/command/publish/sim-sns-publish-input.js +8 -8
  112. package/dist/service/sns/command/publish/sim-sns-publish-input.js.map +1 -1
  113. package/dist/service/sns/command/publish/sim-sns-publish-sms.d.ts +38 -0
  114. package/dist/service/sns/command/publish/sim-sns-publish-sms.d.ts.map +1 -0
  115. package/dist/service/sns/command/publish/sim-sns-publish-sms.js +53 -0
  116. package/dist/service/sns/command/publish/sim-sns-publish-sms.js.map +1 -0
  117. package/dist/service/sns/command/sim-sns-command.types.d.ts +1 -0
  118. package/dist/service/sns/command/sim-sns-command.types.d.ts.map +1 -1
  119. package/dist/service/sns/command/sim-sns-commands.d.ts +12 -4
  120. package/dist/service/sns/command/sim-sns-commands.d.ts.map +1 -1
  121. package/dist/service/sns/command/sim-sns-commands.js +39 -4
  122. package/dist/service/sns/command/sim-sns-commands.js.map +1 -1
  123. package/dist/service/sns/command/sms/sim-sns-opt-out-commands.d.ts +41 -0
  124. package/dist/service/sns/command/sms/sim-sns-opt-out-commands.d.ts.map +1 -0
  125. package/dist/service/sns/command/sms/sim-sns-opt-out-commands.js +56 -0
  126. package/dist/service/sns/command/sms/sim-sns-opt-out-commands.js.map +1 -0
  127. package/dist/service/sns/command/sms/sms.command.d.ts +50 -0
  128. package/dist/service/sns/command/sms/sms.command.d.ts.map +1 -0
  129. package/dist/service/sns/command/sms/sms.command.js +2 -0
  130. package/dist/service/sns/command/sms/sms.command.js.map +1 -0
  131. package/dist/service/sns/delivery/sim-aws-sns-delivery-endpoints.d.ts +5 -6
  132. package/dist/service/sns/delivery/sim-aws-sns-delivery-endpoints.d.ts.map +1 -1
  133. package/dist/service/sns/delivery/sim-aws-sns-delivery-endpoints.js +8 -12
  134. package/dist/service/sns/delivery/sim-aws-sns-delivery-endpoints.js.map +1 -1
  135. package/dist/service/sns/delivery/sim-sns-no-delivery-endpoints.d.ts +6 -13
  136. package/dist/service/sns/delivery/sim-sns-no-delivery-endpoints.d.ts.map +1 -1
  137. package/dist/service/sns/delivery/sim-sns-no-delivery-endpoints.js +13 -2
  138. package/dist/service/sns/delivery/sim-sns-no-delivery-endpoints.js.map +1 -1
  139. package/dist/service/sns/delivery/sim-sns-protocol-delivery-endpoints.d.ts +10 -1
  140. package/dist/service/sns/delivery/sim-sns-protocol-delivery-endpoints.d.ts.map +1 -1
  141. package/dist/service/sns/delivery/sim-sns-protocol-delivery-endpoints.js.map +1 -1
  142. package/dist/service/sns/delivery/sms/sim-sns-delivery-sms.d.ts +34 -0
  143. package/dist/service/sns/delivery/sms/sim-sns-delivery-sms.d.ts.map +1 -0
  144. package/dist/service/sns/delivery/sms/sim-sns-delivery-sms.js +46 -0
  145. package/dist/service/sns/delivery/sms/sim-sns-delivery-sms.js.map +1 -0
  146. package/dist/service/sns/index.d.ts +5 -1
  147. package/dist/service/sns/index.d.ts.map +1 -1
  148. package/dist/service/sns/index.js +4 -1
  149. package/dist/service/sns/index.js.map +1 -1
  150. package/dist/service/sns/message/sim-sns-message-attribute-rules.d.ts.map +1 -1
  151. package/dist/service/sns/message/sim-sns-message-attribute-rules.js +9 -1
  152. package/dist/service/sns/message/sim-sns-message-attribute-rules.js.map +1 -1
  153. package/dist/service/sns/message/sim-sns-message-attributes.d.ts +8 -0
  154. package/dist/service/sns/message/sim-sns-message-attributes.d.ts.map +1 -1
  155. package/dist/service/sns/message/sim-sns-message-attributes.js +10 -0
  156. package/dist/service/sns/message/sim-sns-message-attributes.js.map +1 -1
  157. package/dist/service/sns/message/sim-sns-sms-attributes.d.ts +25 -0
  158. package/dist/service/sns/message/sim-sns-sms-attributes.d.ts.map +1 -0
  159. package/dist/service/sns/message/sim-sns-sms-attributes.js +46 -0
  160. package/dist/service/sns/message/sim-sns-sms-attributes.js.map +1 -0
  161. package/dist/service/sns/sdk/sim-sns-sdk-command-router.d.ts.map +1 -1
  162. package/dist/service/sns/sdk/sim-sns-sdk-command-router.js +12 -0
  163. package/dist/service/sns/sdk/sim-sns-sdk-command-router.js.map +1 -1
  164. package/dist/service/sns/sim-sns-sms.d.ts +63 -0
  165. package/dist/service/sns/sim-sns-sms.d.ts.map +1 -0
  166. package/dist/service/sns/sim-sns-sms.js +76 -0
  167. package/dist/service/sns/sim-sns-sms.js.map +1 -0
  168. package/dist/service/sns/sim-sns.d.ts +7 -15
  169. package/dist/service/sns/sim-sns.d.ts.map +1 -1
  170. package/dist/service/sns/sim-sns.js +23 -30
  171. package/dist/service/sns/sim-sns.js.map +1 -1
  172. package/dist/service/sns/sms/sim-sns-opt-out-list.d.ts +40 -0
  173. package/dist/service/sns/sms/sim-sns-opt-out-list.d.ts.map +1 -0
  174. package/dist/service/sns/sms/sim-sns-opt-out-list.js +47 -0
  175. package/dist/service/sns/sms/sim-sns-opt-out-list.js.map +1 -0
  176. package/dist/service/sns/sms/sim-sns-phone-number.d.ts +21 -0
  177. package/dist/service/sns/sms/sim-sns-phone-number.d.ts.map +1 -0
  178. package/dist/service/sns/sms/sim-sns-phone-number.js +41 -0
  179. package/dist/service/sns/sms/sim-sns-phone-number.js.map +1 -0
  180. package/dist/service/sns/sms/sim-sns-sent-sms-message.d.ts +69 -0
  181. package/dist/service/sns/sms/sim-sns-sent-sms-message.d.ts.map +1 -0
  182. package/dist/service/sns/sms/sim-sns-sent-sms-message.js +71 -0
  183. package/dist/service/sns/sms/sim-sns-sent-sms-message.js.map +1 -0
  184. package/dist/service/sns/sms/sim-sns-sent-sms-store.d.ts +25 -0
  185. package/dist/service/sns/sms/sim-sns-sent-sms-store.d.ts.map +1 -0
  186. package/dist/service/sns/sms/sim-sns-sent-sms-store.js +28 -0
  187. package/dist/service/sns/sms/sim-sns-sent-sms-store.js.map +1 -0
  188. package/dist/service/sns/subscription/sim-sns-subscription-endpoint.d.ts +9 -7
  189. package/dist/service/sns/subscription/sim-sns-subscription-endpoint.d.ts.map +1 -1
  190. package/dist/service/sns/subscription/sim-sns-subscription-endpoint.js +7 -2
  191. package/dist/service/sns/subscription/sim-sns-subscription-endpoint.js.map +1 -1
  192. package/dist/service/sns/subscription/sim-sns-subscription-protocol.d.ts +19 -1
  193. package/dist/service/sns/subscription/sim-sns-subscription-protocol.d.ts.map +1 -1
  194. package/dist/service/sns/subscription/sim-sns-subscription-protocol.js +26 -5
  195. package/dist/service/sns/subscription/sim-sns-subscription-protocol.js.map +1 -1
  196. package/package.json +1 -1
package/README.md CHANGED
@@ -54,9 +54,9 @@ npm i -D @kensio/yulin
54
54
 
55
55
  ### Intercept AWS SDK clients
56
56
 
57
- If your code uses the AWS SDK, you can intercept AWS SDK clients and route their Commands to
58
- simulated AWS services. Your implementation code uses the SDK as normal and never needs to know that
59
- it's dealing with a simulator behind the scenes:
57
+ If your code uses the AWS SDK, you can intercept its clients and route their Commands to simulated
58
+ AWS services. Your implementation code uses the SDK as normal and never needs to know a simulator is
59
+ answering:
60
60
 
61
61
  ```typescript
62
62
  import {
@@ -90,9 +90,9 @@ simSdk.restoreAll(); // Or `using simSdk = new SimSdk();` to restore on scope ex
90
90
  ```
91
91
 
92
92
  You can intercept a client class, as above, or a single client instance. The simulated Account and
93
- Region scope is resolved per send: the Region comes from the sending client's configuration, and
94
- the Account from the ambient `simAws.runAs(...)` caller when one is set, falling back to the
95
- simulation defaults.
93
+ Region scope is resolved per send. The Region comes from the sending client's configuration, and the
94
+ Account from the ambient `simAws.runAs(...)` caller when one is set, falling back to the simulation
95
+ defaults.
96
96
 
97
97
  Each `SimSdk` owns its own isolated simulated AWS, available as `simSdk.simAws` when a test needs
98
98
  to seed or inspect simulated state directly. To share state with an existing simulation, wrap it
@@ -130,8 +130,8 @@ await simAws.region("eu-west-2").dynamoDb().createTable({ ... });
130
130
  await simAws.account("111111111111").region("eu-west-2").dynamoDb().createTable({ ... });
131
131
  ```
132
132
 
133
- AWS state is simulated internally, so you can test realistic interactions with multiple AWS
134
- services.
133
+ AWS state is simulated internally. A test can drive realistic interactions across several AWS
134
+ services at once.
135
135
 
136
136
  An Account ID is a plain string wherever one is accepted. Code that wants to name the type can get a
137
137
  `SimAwsAccountId` from `simAwsAccountId(...)`, which refuses anything that is not a 12-digit AWS
@@ -144,8 +144,8 @@ const accountId = simAwsAccountId("111111111111");
144
144
  const someOtherAccountId = makeSimAwsAccountId();
145
145
  ```
146
146
 
147
- Each instance of `SimAws` is cheap and encapsulated so you can create them wherever you need them.
148
- It's fine to create a new instance of `SimAws` in every test case or in shared test setup.
147
+ Each instance of `SimAws` is cheap and encapsulated. Make one wherever you need it, in every test
148
+ case or in shared test setup, whichever suits.
149
149
 
150
150
  If you prefer, you can also instantiate simulated services individually:
151
151
 
@@ -209,7 +209,7 @@ const res = await fetch(new URL("/foo/", bucketWebsiteUrl));
209
209
  #### Send requests without a port
210
210
 
211
211
  A test usually wants the same requests with nothing listening. `SimAwsHttp` answers a Fetch API
212
- `Request` with a `Response` in process, so there is no port for parallel test files to collide over,
212
+ `Request` with a `Response` in process. There is no port for parallel test files to collide over,
213
213
  and no server to start or tear down:
214
214
 
215
215
  ```typescript
@@ -224,24 +224,24 @@ const simAwsHttp = new SimAwsHttp({ simAws });
224
224
  const response = await simAwsHttp.fetch("https://www.example.com/");
225
225
  ```
226
226
 
227
- Nothing binds a port, so a URL a simulated service gives out is fetched as it is, with no
228
- `localUrl(...)` adapting, and a hostname a simulated Route53 answers for is requested by its own
229
- name. Both routes go through the same authentication, routing and service code, so `serveSimAws` is
230
- what you want only when the request comes from outside the process. See the
231
- [serving docs](./docs/serve "Serving simulated AWS on localhost docs") for which to reach for.
227
+ A URL a simulated service gives out is fetched as it is, with no `localUrl(...)` adapting, and a
228
+ hostname a simulated Route53 answers for is requested by its own name. Both routes go through the
229
+ same authentication, routing and service code. Reach for `serveSimAws` when the request comes from
230
+ outside the process. See the
231
+ [serving docs](./docs/serve "Serving simulated AWS on localhost docs") for how to choose.
232
232
 
233
233
  #### Restarting a served environment
234
234
 
235
- A served environment takes an available port by default, so the URL changes every time the process
235
+ A served environment takes an available port by default. The URL changes every time the process
236
236
  starts. Pin a port to keep the URL the same across restarts:
237
237
 
238
238
  ```typescript
239
239
  const srv = await serveSimAws({ simAws, port: 4599 });
240
240
  ```
241
241
 
242
- Closing the server ends the connections it is holding, so the process can exit rather than being
243
- kept alive by a browser tab. Yulin does not install signal handlers, so call `close()` from your
244
- own:
242
+ Closing the server ends the connections it is holding, and the process can then exit. An open
243
+ browser tab would otherwise keep it alive. Yulin installs no signal handlers, so call `close()` from
244
+ your own:
245
245
 
246
246
  ```typescript
247
247
  process.on("SIGTERM", () => {
@@ -250,12 +250,12 @@ process.on("SIGTERM", () => {
250
250
  ```
251
251
 
252
252
  A restart usually overlaps the process it is replacing. `listen` waits a couple of seconds for a
253
- pinned port that is still held, then throws `SimAwsLocalPortInUse` naming the port, which means
254
- something other than the outgoing process owns it.
253
+ pinned port that is still held, then throws `SimAwsLocalPortInUse` naming the port. Something other
254
+ than the outgoing process owns it by then.
255
255
 
256
256
  #### Reload the browser on a restart
257
257
 
258
- Yulin is the only thing in the response path of a page it serves, so it can tell the browser to
258
+ Yulin is the only thing in the response path of a page it serves, and it can tell the browser to
259
259
  reload. Turning `liveReload` on puts a small script into the HTML pages served to browsers, and the
260
260
  page reloads itself when the process restarts:
261
261
 
@@ -273,16 +273,15 @@ the page refreshed:
273
273
  yulin watch -- tsx dev.ts
274
274
  ```
275
275
 
276
- It watches the working directory, plus the paths Yulin is holding that a module graph never mentions:
277
- a directory mounted into a Bucket, and a synthesized template. See the
276
+ It watches the working directory. It also watches the paths Yulin is holding that a module graph
277
+ never mentions, a directory mounted into a Bucket and a synthesized template. See the
278
278
  [serving docs](./docs/serve "Serving simulated AWS on localhost docs") for what gets the script, what
279
279
  is watched, and what is not.
280
280
 
281
281
  #### Update a stack when its template changes
282
282
 
283
- A synthesized template is data rather than code, so a change to one does not need the process
284
- restarted. Deploy it with `watch` and Yulin applies the file again whenever it changes, updating the
285
- stack in place:
283
+ A synthesized template is data, and a change to one needs no restart. Deploy it with `watch` and
284
+ Yulin applies the file again whenever it changes, updating the stack in place:
286
285
 
287
286
  ```typescript
288
287
  await simAws.cloudFormation().deployTemplateFile({
@@ -296,8 +295,8 @@ await simAws.cloudFormation().deployTemplateFile({
296
295
  ```
297
296
 
298
297
  Resources the change left alone keep what they hold, so simulated S3, DynamoDB and SQS survive a
299
- `cdk synth`. Under `yulin watch` the template is left to the process watching it rather than being a
300
- reason to restart. See the
298
+ `cdk synth`. Under `yulin watch` the template is left to the process watching it, and never triggers
299
+ a restart. See the
301
300
  [CloudFormation docs](./docs/services/cloudformation "Simulated CloudFormation docs") for what an
302
301
  update does to each resource.
303
302
 
@@ -328,37 +327,36 @@ await simAws.clock().advanceBy({ minutes: 20 });
328
327
  // Those session credentials have now expired.
329
328
  ```
330
329
 
331
- Advancing runs whatever falls due during the interval and returns once the simulation has settled,
332
- so the next line can assert. Time belongs to the `SimAws` instance, so moving it never disturbs
333
- another simulation, or the real clock. See the
330
+ Advancing runs whatever falls due during the interval and returns once the simulation has settled.
331
+ The next line can assert. Time belongs to the `SimAws` instance, so moving it never disturbs another
332
+ simulation, or the real clock. See the
334
333
  [simulated time docs](./docs/time "Simulated time docs") for full usage.
335
334
 
336
- ## What is yulin?
335
+ ## What is Yulin?
337
336
 
338
- TLDR: yulin is an AWS simulator for testing Node.js applications.
337
+ TLDR: Yulin is an AWS simulator for testing Node.js applications.
339
338
 
340
- The simulation is not only local to the machine, but in the same single process
341
- with the test and application under test. No network or external i/o is
342
- involved. This is what "isolated" refers to.
339
+ The simulation runs in the same single process as the test and the application
340
+ under test, and not just on the same machine. No network or external i/o is
341
+ involved. That is what "isolated" refers to.
343
342
 
344
343
  This "isolated system" approach to testing has a few advantages:
345
344
 
346
345
  - Tests run fast as everything is in memory with no real networking.
347
- - Test set-up is fast and uncomplicated, as there are no containers or extra
346
+ - Test set-up is quick and uncomplicated, as there are no containers or extra
348
347
  dependencies to manage.
349
348
  - It's straightforward to use multiple other mocks and simulators alongside
350
- yulin, such as [nock](https://github.com/nock/nock), as yulin makes no
349
+ Yulin, such as [nock](https://github.com/nock/nock), as Yulin makes no
351
350
  assumptions about the environment.
352
- - You can control everything in each isolated test process, such as controlling
353
- the current time, even when multiple different AWS services are simulated.
351
+ - You can control everything in each isolated test process, including the
352
+ current time, even when multiple different AWS services are simulated.
354
353
  - One test can cover **meaningful system behaviour** across multiple AWS
355
354
  services and applications, such as Lambdas sending events to SQS queues to be
356
355
  picked up by other Lambdas, or DynamoDB streams triggering Lambdas.
357
356
 
358
- That last point is the most important. The motivation behind yulin is to enable
359
- efficient tests that cover the logical behaviour of a system. That is in
360
- contrast to less valuable microscopic unit tests with fiddly mocks and brittle
361
- assertions. The goal of yulin is to allow you to test system behaviours that are
357
+ That last point matters most. Yulin exists to make efficient tests that cover
358
+ the logical behaviour of a system, in contrast to microscopic unit tests with
359
+ fiddly mocks and brittle assertions. The behaviours worth testing are the ones
362
360
  meaningful to users and stakeholders.
363
361
 
364
362
  ## What's in a name?
@@ -16,7 +16,7 @@ import { simAwsEcsCollaborators } from "./sim-aws-ecs-collaborators.js";
16
16
  import { simAwsLambdaCollaborators } from "./sim-aws-lambda-collaborators.js";
17
17
  import { simAwsS3NotificationDestinations } from "./sim-aws-s3-notification-destinations.js";
18
18
  import { SimSns } from "../../sns/index.js";
19
- import { SimAwsSnsDeliveryEndpoints } from "../../sns/delivery/sim-aws-sns-delivery-endpoints.js";
19
+ import { simAwsSnsDeliveryEndpoints } from "../../sns/delivery/sim-aws-sns-delivery-endpoints.js";
20
20
  import { SimSts } from "../../sts/sim-sts.js";
21
21
  /**
22
22
  * Builder for simulated AWS services scoped to one Account and Region.
@@ -172,7 +172,7 @@ export class SimAwsAccountRegionServiceBuilder {
172
172
  * and are resolved on delivery rather than here.
173
173
  */
174
174
  createSns(scope) {
175
- const endpoints = new SimAwsSnsDeliveryEndpoints({ simAws: this.simAws });
175
+ const endpoints = simAwsSnsDeliveryEndpoints({ simAws: this.simAws });
176
176
  return new SimSns({ ...this.scoped(scope), deliveryEndpoints: endpoints });
177
177
  }
178
178
  /** Create simulated EventBridge Scheduler for an Account Region scope. */
@@ -1 +1 @@
1
- {"version":3,"file":"sim-aws-account-region-service-builder.js","sourceRoot":"","sources":["../../../../src/service/aws/factory/sim-aws-account-region-service-builder.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,gCAAgC,EAChC,uBAAuB,EACvB,8BAA8B,GAC/B,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MA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GAAG,IAAI,0BAA0B,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAE1E,OAAO,IAAI,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,0EAA0E;IAC1E,eAAe,CAAC,KAAmC;QACjD,OAAO,IAAI,YAAY,CAAC;YACtB,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;YACrB,eAAe,EAAE,8BAA8B,CAAC,IAAI,CAAC,MAAM,CAAC;SAC7D,CAAC,CAAC;IACL,CAAC;IAED,wDAAwD;IACxD,SAAS,CAAC,KAAmC;QAC3C,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAEtC,OAAO,IAAI,MAAM,CAAC;YAChB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;YAC5C,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,MAAM,CACZ,KAAmC;QAEnC,OAAO,IAAI,CAAC,eAAe,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;CACF"}
1
+ {"version":3,"file":"sim-aws-account-region-service-builder.js","sourceRoot":"","sources":["../../../../src/service/aws/factory/sim-aws-account-region-service-builder.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,gCAAgC,EAChC,uBAAuB,EACvB,8BAA8B,GAC/B,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OA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AmC;QAC3C,MAAM,SAAS,GAAG,0BAA0B,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAEtE,OAAO,IAAI,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,0EAA0E;IAC1E,eAAe,CAAC,KAAmC;QACjD,OAAO,IAAI,YAAY,CAAC;YACtB,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;YACrB,eAAe,EAAE,8BAA8B,CAAC,IAAI,CAAC,MAAM,CAAC;SAC7D,CAAC,CAAC;IACL,CAAC;IAED,wDAAwD;IACxD,SAAS,CAAC,KAAmC;QAC3C,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAEtC,OAAO,IAAI,MAAM,CAAC;YAChB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;YAC5C,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,MAAM,CACZ,KAAmC;QAEnC,OAAO,IAAI,CAAC,eAAe,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;CACF"}
@@ -3,8 +3,9 @@ interface SimCfCustomOriginRequestProperties {
3
3
  readonly originPath: string;
4
4
  readonly request: Request;
5
5
  /**
6
- * Headers stating who the Origin request is from, which an Origin whose
7
- * origin access control signs carries and an anonymous one does not.
6
+ * Headers stating who the Origin request is from and what its signature
7
+ * covers, which an Origin whose origin access control signs carries and an
8
+ * anonymous one does not.
8
9
  */
9
10
  readonly signingHeaders?: Readonly<Record<string, string>> | undefined;
10
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sim-cf-custom-origin-request.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-custom-origin-request.ts"],"names":[],"mappings":"AAGA,UAAU,kCAAkC;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;CACxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,kCAAkC,GAC7C,OAAO,CAuCT"}
1
+ {"version":3,"file":"sim-cf-custom-origin-request.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-custom-origin-request.ts"],"names":[],"mappings":"AAGA,UAAU,kCAAkC;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;CACxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,kCAAkC,GAC7C,OAAO,CAuCT"}
@@ -1 +1 @@
1
- {"version":3,"file":"sim-cf-custom-origin-request.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-custom-origin-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iDAAiD,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,iDAAiD,CAAC;AAa5F;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CACtC,UAA8C;IAE9C,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;IAC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KACvB,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,UAAkB,EAAE,UAAkB;IAC/D,OAAO,IAAI,UAAU,IAAI,UAAU,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AACpE,CAAC"}
1
+ {"version":3,"file":"sim-cf-custom-origin-request.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-custom-origin-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iDAAiD,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,iDAAiD,CAAC;AAc5F;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CACtC,UAA8C;IAE9C,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;IAC/B,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAEvC,MAAM,SAAS,GAAG,IAAI,cAAc,CAAC;QACnC,KAAK,EAAE,WAAW,UAAU,CAAC,UAAU,EAAE;KAC1C,CAAC,CAAC,KAAK,EAAE,CAAC;IACX,SAAS,CAAC,QAAQ,GAAG,iBAAiB,CACpC,UAAU,CAAC,UAAU,EACrB,SAAS,CAAC,QAAQ,CACnB,CAAC;IACF,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAEpC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IAEpC,6EAA6E;IAC7E,wEAAwE;IACxE,0EAA0E;IAC1E,2EAA2E;IAC3E,0DAA0D;IAC1D,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAEnC,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;IAEvE,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,cAAc,EAAE,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,aAAa,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE/D,OAAO,IAAI,OAAO,CAAC,SAAS,EAAE;QAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO;QACP,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;QACjD,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,UAAkB,EAAE,UAAkB;IAC/D,OAAO,IAAI,UAAU,IAAI,UAAU,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AACpE,CAAC"}
@@ -14,6 +14,9 @@ import type { SimCloudFrontOriginRequest } from "../sim-cloudfront-request-respo
14
14
  * the same way anything else calling into simulated AWS in process says who it
15
15
  * is.
16
16
  *
17
+ * The payload hash a real signature covers is stated as itself, since it is
18
+ * the one part of a signature an Origin turns a request away over.
19
+ *
17
20
  * Which Distribution the request belongs to is only known per request, so this
18
21
  * answers per fetch rather than when the Origin is built.
19
22
  */
@@ -21,8 +24,8 @@ export declare class SimCfCustomOriginSigner {
21
24
  private readonly originAccessControl;
22
25
  constructor(originAccessControl?: SimCloudFrontOriginAccessControl);
23
26
  /**
24
- * The headers stating who one Origin request is from, which are none when the
25
- * Origin is reached anonymously.
27
+ * The headers stating who one Origin request is from and what its signature
28
+ * covers, which are none when the Origin is reached anonymously.
26
29
  */
27
30
  forRequest(request: SimCloudFrontOriginRequest): Record<string, string>;
28
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sim-cf-custom-origin-signer.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-custom-origin-signer.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,6DAA6D,CAAC;AAEpH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAExF;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAEtB;IAEd,YAAY,mBAAmB,CAAC,EAAE,gCAAgC,EAEjE;IAED;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAetE;CACF"}
1
+ {"version":3,"file":"sim-cf-custom-origin-signer.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-custom-origin-signer.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,6DAA6D,CAAC;AAEpH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAYxF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAEtB;IAEd,YAAY,mBAAmB,CAAC,EAAE,gCAAgC,EAEjE;IAED;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBtE;CACF"}
@@ -1,7 +1,17 @@
1
1
  import { simAwsCallerHeaderName, simAwsCallerHeaderValue, } from "../../../iam/request/sim-aws-caller-header.js";
2
2
  import { simAwsSourceAccountHeaderName, simAwsSourceArnHeaderName, } from "../../../iam/request/sim-aws-request-source.js";
3
+ import { simIamSigV4ContentSha256Header, simIamSigV4UnsignedPayload, } from "../../../iam/sigv4/canonical/sim-iam-sigv4-payload-hash.js";
3
4
  import { simCloudFrontDistributionArn } from "../../distribution/sim-cf-distribution-view.js";
4
5
  import { simCloudFrontServicePrincipal } from "../../sim-cloudfront-service-principal.js";
6
+ /**
7
+ * The viewer methods CloudFront has a body to hash for.
8
+ *
9
+ * These are the two AWS names on the Function URL Origin documentation, and
10
+ * the two a viewer sends a body with in practice. Anything else is left alone
11
+ * rather than guessed at, since refusing a method real CloudFront lets through
12
+ * would be the more expensive mistake.
13
+ */
14
+ const bodyCarryingMethods = new Set(["POST", "PUT"]);
5
15
  /**
6
16
  * Who a CloudFront custom Origin is reached as.
7
17
  *
@@ -16,6 +26,9 @@ import { simCloudFrontServicePrincipal } from "../../sim-cloudfront-service-prin
16
26
  * the same way anything else calling into simulated AWS in process says who it
17
27
  * is.
18
28
  *
29
+ * The payload hash a real signature covers is stated as itself, since it is
30
+ * the one part of a signature an Origin turns a request away over.
31
+ *
19
32
  * Which Distribution the request belongs to is only known per request, so this
20
33
  * answers per fetch rather than when the Origin is built.
21
34
  */
@@ -25,8 +38,8 @@ export class SimCfCustomOriginSigner {
25
38
  this.originAccessControl = originAccessControl;
26
39
  }
27
40
  /**
28
- * The headers stating who one Origin request is from, which are none when the
29
- * Origin is reached anonymously.
41
+ * The headers stating who one Origin request is from and what its signature
42
+ * covers, which are none when the Origin is reached anonymously.
30
43
  */
31
44
  forRequest(request) {
32
45
  if (this.originAccessControl?.signs !== true) {
@@ -39,7 +52,30 @@ export class SimCfCustomOriginSigner {
39
52
  }),
40
53
  [simAwsSourceArnHeaderName]: simCloudFrontDistributionArn(request.distribution),
41
54
  [simAwsSourceAccountHeaderName]: request.distribution.accountId,
55
+ ...payloadDeclaration(request.req),
42
56
  };
43
57
  }
44
58
  }
59
+ /**
60
+ * What the signature says the Origin request body hashes to.
61
+ *
62
+ * CloudFront streams the viewer's body on to the Origin rather than buffering
63
+ * it, so it has no hash of its own to sign with. It signs the viewer's
64
+ * `x-amz-content-sha256` when the viewer sent one, and `UNSIGNED-PAYLOAD` when
65
+ * it did not. A Lambda Function URL does not accept an unsigned payload, so a
66
+ * POST or PUT that carried no hash through a signing origin access control is
67
+ * refused at the Origin, which is what real CloudFront and Lambda do with one.
68
+ *
69
+ * A viewer's own header travels with the rest of its headers, so nothing is
70
+ * stated for it here.
71
+ *
72
+ * https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-lambda.html
73
+ */
74
+ function payloadDeclaration(viewerRequest) {
75
+ if (!bodyCarryingMethods.has(viewerRequest.method.toUpperCase()) ||
76
+ viewerRequest.headers.has(simIamSigV4ContentSha256Header)) {
77
+ return {};
78
+ }
79
+ return { [simIamSigV4ContentSha256Header]: simIamSigV4UnsignedPayload };
80
+ }
45
81
  //# sourceMappingURL=sim-cf-custom-origin-signer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sim-cf-custom-origin-signer.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-custom-origin-signer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;AAE9F,OAAO,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAC;AAG1F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,uBAAuB;IACjB,mBAAmB,CAEtB;IAEd,YAAY,mBAAsD;QAChE,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,OAAmC;QAC5C,IAAI,IAAI,CAAC,mBAAmB,EAAE,KAAK,KAAK,IAAI,EAAE,CAAC;YAC7C,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO;YACL,CAAC,sBAAsB,CAAC,EAAE,uBAAuB,CAAC;gBAChD,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,6BAA6B;aACvC,CAAC;YACF,CAAC,yBAAyB,CAAC,EAAE,4BAA4B,CACvD,OAAO,CAAC,YAAY,CACrB;YACD,CAAC,6BAA6B,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,SAAS;SAChE,CAAC;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"sim-cf-custom-origin-signer.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/origin/custom/sim-cf-custom-origin-signer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,GAC3B,MAAM,4DAA4D,CAAC;AACpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;AAE9F,OAAO,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAC;AAG1F;;;;;;;GAOG;AACH,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAErD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,uBAAuB;IACjB,mBAAmB,CAEtB;IAEd,YAAY,mBAAsD;QAChE,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,OAAmC;QAC5C,IAAI,IAAI,CAAC,mBAAmB,EAAE,KAAK,KAAK,IAAI,EAAE,CAAC;YAC7C,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO;YACL,CAAC,sBAAsB,CAAC,EAAE,uBAAuB,CAAC;gBAChD,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,6BAA6B;aACvC,CAAC;YACF,CAAC,yBAAyB,CAAC,EAAE,4BAA4B,CACvD,OAAO,CAAC,YAAY,CACrB;YACD,CAAC,6BAA6B,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,SAAS;YAC/D,GAAG,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC;SACnC,CAAC;IACJ,CAAC;CACF;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAS,kBAAkB,CAAC,aAAsB;IAChD,IACE,CAAC,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAC5D,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,EACzD,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,EAAE,CAAC,8BAA8B,CAAC,EAAE,0BAA0B,EAAE,CAAC;AAC1E,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,sFAmFjD,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,sFAsFjD,CAAC"}
@@ -60,8 +60,11 @@ export const simCfFunctionUrlOriginTemplateFactory = new MappedFactory(() => ({
60
60
  FunctionName: "greeter",
61
61
  Role: { "Fn::GetAtt": ["GreeterRole", "Arn"] },
62
62
  Code: {
63
- ZipFile: "exports.handler = async () => " +
64
- "({ statusCode: 200, body: 'Hello from behind CloudFront' });",
63
+ // The handler answers with whatever it was sent, so a test about a
64
+ // request with a body can see that the body reached it, and one
65
+ // about a request without stays as readable as it was.
66
+ ZipFile: "exports.handler = async (event) => ({ statusCode: 200, " +
67
+ "body: event.body ?? 'Hello from behind CloudFront' });",
65
68
  },
66
69
  Handler: "index.handler",
67
70
  Runtime: "nodejs22.x",
@@ -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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BACvB,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":"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,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,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"}
@@ -17,6 +17,16 @@ export interface SimCognitoAuthorizeInput {
17
17
  readonly idp_identifier?: string | undefined;
18
18
  readonly code_challenge?: string | undefined;
19
19
  readonly code_challenge_method?: string | undefined;
20
+ /**
21
+ * The username a pool's own user signs in with.
22
+ *
23
+ * Real Cognito takes these two from the managed login form rather than from
24
+ * the query string, and a request carrying them here is the form post the
25
+ * simulation's own sign-in page makes. Naming no identity provider and
26
+ * carrying these two is what tells a local sign-in from a federated one.
27
+ */
28
+ readonly username?: string | undefined;
29
+ readonly password?: string | undefined;
20
30
  }
21
31
  /**
22
32
  * Where a hosted endpoint sends the browser next.
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-auth.command.d.ts","sourceRoot":"","sources":["../../../../../src/service/cognito/command/hosted/hosted-auth.command.ts"],"names":[],"mappings":"AAA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,WAAW,qBAAqB;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC"}
@@ -1,9 +1,9 @@
1
1
  import type { SimClock } from "../../../../util/clock/sim-clock.js";
2
- import type { SimCognitoFederatedSignIn } from "../../user-pool/idp/sim-cognito-federated-sign-in.js";
3
2
  import type { SimCognitoUserPool } from "../../user-pool/sim-cognito-user-pool.js";
3
+ import type { SimCognitoHostedSignIn } from "./sim-cognito-hosted-sign-in.js";
4
4
  import type { SimCognitoAuthorizeInput, SimCognitoHostedRedirect } from "./hosted-auth.command.js";
5
5
  interface SimCognitoAuthorizeEndpointProperties {
6
- readonly federatedSignIn: SimCognitoFederatedSignIn;
6
+ readonly signIn: SimCognitoHostedSignIn;
7
7
  readonly clock: SimClock;
8
8
  }
9
9
  /**
@@ -11,25 +11,26 @@ interface SimCognitoAuthorizeEndpointProperties {
11
11
  *
12
12
  * Real Cognito answers this request in one of two ways: it sends the browser
13
13
  * to an identity provider's sign-in page when the request names a provider,
14
- * and to managed login's own page when it does not. Only the first has an
15
- * equivalent here, because the second is a web page a person fills in, and a
16
- * simulation of a person filling it in would be a simulation of nothing.
14
+ * and to managed login's own form when it does not. Both end in the same
15
+ * place, which is the app client's callback URL carrying an authorization
16
+ * code, and both end there here.
17
17
  *
18
- * So a request naming a provider signs in the user that provider has been told
19
- * is signed in at it, and answers with the code real Cognito would answer
20
- * with. A request naming no provider, or naming the pool's own users, is
21
- * refused with a message saying so, rather than being answered with a page or
22
- * with a user nothing put there.
18
+ * A request naming a provider signs in the user that provider has been told is
19
+ * signed in at it. A request naming none signs in one of the pool's own users,
20
+ * with the username and password real managed login would have taken from its
21
+ * form. Nothing here draws the form: the serving layer is what answers a
22
+ * browser with a page, and a test calling this directly passes the two fields
23
+ * the form would have posted.
23
24
  */
24
25
  export declare class SimCognitoAuthorizeEndpoint {
25
- private readonly federatedSignIn;
26
+ private readonly signIn;
26
27
  private readonly clock;
27
28
  private readonly hostedClient;
28
29
  private readonly request;
29
30
  constructor(properties: SimCognitoAuthorizeEndpointProperties);
30
31
  /**
31
- * Sign a user in through an identity provider, and send the browser back to
32
- * the application with an authorization code.
32
+ * Sign a user in, and send the browser back to the application with an
33
+ * authorization code.
33
34
  */
34
35
  handle(pool: SimCognitoUserPool, input: SimCognitoAuthorizeInput): SimCognitoHostedRedirect;
35
36
  private redirectWithCode;
@@ -1 +1 @@
1
- {"version":3,"file":"sim-cognito-authorize-endpoint.d.ts","sourceRoot":"","sources":["../../../../../src/service/cognito/command/hosted/sim-cognito-authorize-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAEpE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sDAAsD,CAAC;AACtG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAInF,OAAO,KAAK,EACV,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,0BAA0B,CAAC;AAElC,UAAU,qCAAqC;IAC7C,QAAQ,CAAC,eAAe,EAAE,yBAAyB,CAAC;IACpD,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;CAC1B;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,2BAA2B;IACtC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA4B;IAC5D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAgC;IAC7D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAE5D,YAAY,UAAU,EAAE,qCAAqC,EAG5D;IAED;;;OAGG;IACH,MAAM,CACJ,IAAI,EAAE,kBAAkB,EACxB,KAAK,EAAE,wBAAwB,GAC9B,wBAAwB,CAqC1B;IAED,OAAO,CAAC,gBAAgB;CAezB"}
1
+ {"version":3,"file":"sim-cognito-authorize-endpoint.d.ts","sourceRoot":"","sources":["../../../../../src/service/cognito/command/hosted/sim-cognito-authorize-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAInF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,KAAK,EACV,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,0BAA0B,CAAC;AAElC,UAAU,qCAAqC;IAC7C,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,2BAA2B;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;IAChD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAgC;IAC7D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAE5D,YAAY,UAAU,EAAE,qCAAqC,EAG5D;IAED;;;OAGG;IACH,MAAM,CACJ,IAAI,EAAE,kBAAkB,EACxB,KAAK,EAAE,wBAAwB,GAC9B,wBAAwB,CAgC1B;IAED,OAAO,CAAC,gBAAgB;CAezB"}
@@ -7,28 +7,29 @@ import { SimCognitoHostedClient } from "./sim-cognito-hosted-client.js";
7
7
  *
8
8
  * Real Cognito answers this request in one of two ways: it sends the browser
9
9
  * to an identity provider's sign-in page when the request names a provider,
10
- * and to managed login's own page when it does not. Only the first has an
11
- * equivalent here, because the second is a web page a person fills in, and a
12
- * simulation of a person filling it in would be a simulation of nothing.
10
+ * and to managed login's own form when it does not. Both end in the same
11
+ * place, which is the app client's callback URL carrying an authorization
12
+ * code, and both end there here.
13
13
  *
14
- * So a request naming a provider signs in the user that provider has been told
15
- * is signed in at it, and answers with the code real Cognito would answer
16
- * with. A request naming no provider, or naming the pool's own users, is
17
- * refused with a message saying so, rather than being answered with a page or
18
- * with a user nothing put there.
14
+ * A request naming a provider signs in the user that provider has been told is
15
+ * signed in at it. A request naming none signs in one of the pool's own users,
16
+ * with the username and password real managed login would have taken from its
17
+ * form. Nothing here draws the form: the serving layer is what answers a
18
+ * browser with a page, and a test calling this directly passes the two fields
19
+ * the form would have posted.
19
20
  */
20
21
  export class SimCognitoAuthorizeEndpoint {
21
- federatedSignIn;
22
+ signIn;
22
23
  clock;
23
24
  hostedClient = new SimCognitoHostedClient();
24
25
  request = new SimCognitoAuthorizeRequest();
25
26
  constructor(properties) {
26
- this.federatedSignIn = properties.federatedSignIn;
27
+ this.signIn = properties.signIn;
27
28
  this.clock = properties.clock;
28
29
  }
29
30
  /**
30
- * Sign a user in through an identity provider, and send the browser back to
31
- * the application with an authorization code.
31
+ * Sign a user in, and send the browser back to the application with an
32
+ * authorization code.
32
33
  */
33
34
  handle(pool, input) {
34
35
  const client = this.hostedClient.forAuthorize(pool, input.client_id);
@@ -40,12 +41,7 @@ export class SimCognitoAuthorizeEndpoint {
40
41
  this.hostedClient.requireCodeGrant(client, true);
41
42
  this.request.requireChallengeMethod(input);
42
43
  const scopes = new SimCognitoGrantedScopes(client, input.scope);
43
- const provider = this.request.requiredProvider(pool, client, input);
44
- const user = this.federatedSignIn.signIn({
45
- pool,
46
- provider,
47
- now: this.clock.now(),
48
- });
44
+ const user = this.signIn.signIn(pool, client, input);
49
45
  const code = new SimCognitoAuthorizationCode({
50
46
  username: user.username,
51
47
  clientId: client.id,
@@ -1 +1 @@
1
- {"version":3,"file":"sim-cognito-authorize-endpoint.js","sourceRoot":"","sources":["../../../../../src/service/cognito/command/hosted/sim-cognito-authorize-endpoint.ts"],"names":[],"mappings":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K,CAAC,CAAC;QACpE,MAAM,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;YACvC,IAAI;YACJ,QAAQ;YACR,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;SACtB,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,IAAI,2BAA2B,CAAC;YAC3C,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,WAAW;YACX,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;YAC1B,aAAa,EAAE,KAAK,CAAC,cAAc;SACpC,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;QAErC,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;YACrE,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;IACJ,CAAC;IAEO,gBAAgB,CACtB,WAAmB,EACnB,IAAY,EACZ,KAAyB;QAEzB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;QAEtC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAExC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF"}
1
+ {"version":3,"file":"sim-cognito-authorize-endpoint.js","sourceRoot":"","sources":["../../../../../src/service/cognito/command/hosted/sim-cognito-authorize-endpoint.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,wDAAwD,CAAC;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C;YAC3C,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,WAAW;YACX,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;YAC1B,aAAa,EAAE,KAAK,CAAC,cAAc;SACpC,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;QAErC,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;YACrE,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;IACJ,CAAC;IAEO,gBAAgB,CACtB,WAAmB,EACnB,IAAY,EACZ,KAAyB;QAEzB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;QAEtC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAExC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF"}
@@ -25,13 +25,22 @@ export declare class SimCognitoAuthorizeRequest {
25
25
  */
26
26
  requireChallengeMethod(input: SimCognitoAuthorizeInput): void;
27
27
  /**
28
- * The identity provider this request signs the user in through.
28
+ * The identity provider this request signs the user in through, and nothing
29
+ * where it signs one of the pool's own users in.
29
30
  *
30
- * A request naming none would reach managed login on real Cognito, which is
31
- * a page rather than anything an API answers, so it is refused here with a
32
- * message saying what to do instead.
31
+ * A request naming no provider, or naming `COGNITO`, is a local sign-in: on
32
+ * real Cognito it reaches managed login's own form, and here it carries the
33
+ * username and password that form would have posted.
33
34
  */
34
- requiredProvider(pool: SimCognitoUserPool, client: SimCognitoUserPoolClient, input: SimCognitoAuthorizeInput): SimCognitoUserPoolIdentityProvider;
35
- private requireSupportedProvider;
35
+ signInProvider(pool: SimCognitoUserPool, client: SimCognitoUserPoolClient, input: SimCognitoAuthorizeInput): SimCognitoUserPoolIdentityProvider | undefined;
36
+ /**
37
+ * Refuse a provider the app client does not offer.
38
+ *
39
+ * `COGNITO` is checked the same way, because real Cognito treats it as one
40
+ * of the entries in `SupportedIdentityProviders`: a client without it there
41
+ * signs nobody in at the hosted domain with a password, however many local
42
+ * users the pool holds.
43
+ */
44
+ private requireSupportedProviderName;
36
45
  }
37
46
  //# sourceMappingURL=sim-cognito-authorize-request.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sim-cognito-authorize-request.d.ts","sourceRoot":"","sources":["../../../../../src/service/cognito/command/hosted/sim-cognito-authorize-request.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wDAAwD,CAAC;AACvG,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,gEAAgE,CAAC;AACzH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAiBzE;;;;;;;GAOG;AACH,qBAAa,0BAA0B;IACrC;;OAEG;IACH,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAuB1D;IAED;;;;;;;OAOG;IACH,sBAAsB,CAAC,KAAK,EAAE,wBAAwB,GAAG,IAAI,CA8B5D;IAED;;;;;;OAMG;IACH,gBAAgB,CACd,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,wBAAwB,EAChC,KAAK,EAAE,wBAAwB,GAC9B,kCAAkC,CA6BpC;IAED,OAAO,CAAC,wBAAwB;CAejC"}
1
+ {"version":3,"file":"sim-cognito-authorize-request.d.ts","sourceRoot":"","sources":["../../../../../src/service/cognito/command/hosted/sim-cognito-authorize-request.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wDAAwD,CAAC;AACvG,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,gEAAgE,CAAC;AACzH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAqBzE;;;;;;;GAOG;AACH,qBAAa,0BAA0B;IACrC;;OAEG;IACH,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAuB1D;IAED;;;;;;;OAOG;IACH,sBAAsB,CAAC,KAAK,EAAE,wBAAwB,GAAG,IAAI,CA8B5D;IAED;;;;;;;OAOG;IACH,cAAc,CACZ,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,wBAAwB,EAChC,KAAK,EAAE,wBAAwB,GAC9B,kCAAkC,GAAG,SAAS,CAuBhD;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,4BAA4B;CAerC"}