@reventlessdev/reventless-aws 3.0.0-alpha.318 → 3.0.0-alpha.320

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 (40) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/package.json +11 -7
  3. package/rescript.json +4 -0
  4. package/run-provision-identity.mjs +3 -0
  5. package/scripts/ProvisionIdentity.res +303 -0
  6. package/scripts/ProvisionIdentity.res.mjs +376 -0
  7. package/src/Platform.res +54 -30
  8. package/src/Platform.res.mjs +34 -32
  9. package/src/Platform_Stack.res +102 -19
  10. package/src/Platform_Stack.res.mjs +43 -7
  11. package/src/adapter/Auth/Auth_ActiveRolePoolAttachment.res +267 -32
  12. package/src/adapter/Auth/Auth_ActiveRolePoolAttachment.res.mjs +124 -14
  13. package/src/adapter/Auth/Auth_ActiveRoleStore.res +93 -5
  14. package/src/adapter/Auth/Auth_ActiveRoleStore.res.mjs +53 -4
  15. package/src/adapter/Auth/Auth_ActiveRoleStore_Ops.res +50 -4
  16. package/src/adapter/Auth/Auth_ActiveRoleStore_Ops.res.mjs +24 -3
  17. package/src/adapter/Auth/Auth_ActiveRoleStore_Schema.res +92 -0
  18. package/src/adapter/Auth/Auth_ActiveRoleStore_Schema.res.mjs +49 -0
  19. package/src/adapter/Auth/Auth_ActiveRoleTrigger_Ops.res +21 -7
  20. package/src/adapter/Auth/Auth_ActiveRoleTrigger_Ops.res.mjs +15 -7
  21. package/src/adapter/Runtime/AutomationSliceEntryPoint_Ops.res +6 -3
  22. package/src/util/Util_AwsError.res +56 -0
  23. package/src/util/Util_AwsError.res.mjs +59 -0
  24. package/src/util/Util_ShellConfig.res +28 -0
  25. package/src/util/Util_ShellConfig.res.mjs +22 -0
  26. package/tests/Auth_ActiveRolePoolAttachmentTest.res +175 -0
  27. package/tests/Auth_ActiveRolePoolAttachmentTest.res.mjs +136 -0
  28. package/tests/Auth_ActiveRoleStoreTest.res +65 -0
  29. package/tests/Auth_ActiveRoleStoreTest.res.mjs +48 -0
  30. package/tests/Auth_ActiveRoleStore_SchemaTest.res +98 -0
  31. package/tests/Auth_ActiveRoleStore_SchemaTest.res.mjs +97 -0
  32. package/tests/AwsErrorFixtures.mjs +16 -0
  33. package/tests/PgQueryResolver_LambdaTest.res +166 -0
  34. package/tests/PgQueryResolver_LambdaTest.res.mjs +196 -0
  35. package/tests/ProvisionIdentityTest.res +109 -0
  36. package/tests/ProvisionIdentityTest.res.mjs +132 -0
  37. package/tests/Util_AwsErrorTest.res +127 -0
  38. package/tests/Util_AwsErrorTest.res.mjs +76 -0
  39. package/tests/Util_ShellConfigTest.res +51 -0
  40. package/tests/Util_ShellConfigTest.res.mjs +42 -0
@@ -224,3 +224,54 @@ describe("Util_ShellConfig.fields — shellConfig passthrough", () => {
224
224
  }
225
225
  })
226
226
  })
227
+
228
+ // 🚨 The identity keys travel under both spellings through the rename. A shell
229
+ // reads config.json at runtime and CloudFront serves the previous bundle until
230
+ // someone invalidates it, so switching them in one deploy leaves a window where
231
+ // the served bundle and the served config disagree — and `cognitoClientId` is
232
+ // read into an option, so a bundle that cannot find its key does not error, it
233
+ // gets `None` and login silently stops working.
234
+ //
235
+ // These assert the property that removes that window, not the spelling.
236
+ describe("Util_ShellConfig.identityFields", () => {
237
+ let fields = Util_ShellConfig.identityFields(~providerId="eu-west-1_x", ~clientId="7cl13nt")
238
+ let get = key =>
239
+ fields->Array.find(((k, _)) => k == key)->Option.map(((_, v)) => v)
240
+
241
+ testSync("the new spelling is present", () =>
242
+ expect((get("identityProviderId"), get("identityProviderClientId")))->toEqual((
243
+ Some(JSON.Encode.string("eu-west-1_x")),
244
+ Some(JSON.Encode.string("7cl13nt")),
245
+ ))
246
+ )
247
+
248
+ // Not "still" — deliberately. Every shipped shell reads these, and dropping
249
+ // them is a later release gated on the pinned bundle, not on this one.
250
+ testSync("the deprecated spelling is present too", () =>
251
+ expect((get("cognitoUserPoolId"), get("cognitoClientId")))->toEqual((
252
+ Some(JSON.Encode.string("eu-west-1_x")),
253
+ Some(JSON.Encode.string("7cl13nt")),
254
+ ))
255
+ )
256
+
257
+ // The whole point: a bundle reading either name gets the same answer. Two keys
258
+ // carrying different values would be worse than one key, not better.
259
+ testSync("both spellings carry identical values", () =>
260
+ expect((
261
+ get("identityProviderId") == get("cognitoUserPoolId"),
262
+ get("identityProviderClientId") == get("cognitoClientId"),
263
+ ))->toEqual((true, true))
264
+ )
265
+
266
+ // The client id is the load-bearing one — it is what the shell's auth provider
267
+ // branches on. The pool id is currently discarded by the shell, which is
268
+ // exactly why a `cognito*` sweep is dangerous: the safe one gives no warning.
269
+ testSync("nothing else sneaks into the identity field set", () =>
270
+ expect(fields->Array.map(((k, _)) => k)->Array.toSorted(String.compare))->toEqual([
271
+ "cognitoClientId",
272
+ "cognitoUserPoolId",
273
+ "identityProviderClientId",
274
+ "identityProviderId",
275
+ ])
276
+ )
277
+ })
@@ -4,6 +4,8 @@ import * as JestGlobals from "@reventlessdev/rescript-jest/src/JestGlobals.res.m
4
4
  import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
5
5
  import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
6
6
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
7
+ import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
8
+ import * as Primitive_string from "@rescript/runtime/lib/es6/Primitive_string.js";
7
9
  import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
8
10
  import * as Util_ShellConfig$ReventlessAws from "../src/util/Util_ShellConfig.res.mjs";
9
11
  import * as Platform_BakedManifest$ReventlessCore from "@reventlessdev/reventless-core/src/admin/Platform_BakedManifest.res.mjs";
@@ -252,6 +254,46 @@ globalThis.describe("Util_ShellConfig.fields — shellConfig passthrough", () =>
252
254
  });
253
255
  });
254
256
 
257
+ globalThis.describe("Util_ShellConfig.identityFields", () => {
258
+ let fields = Util_ShellConfig$ReventlessAws.identityFields("eu-west-1_x", "7cl13nt");
259
+ let get = key => Stdlib_Option.map(fields.find(param => param[0] === key), param => param[1]);
260
+ globalThis.test("the new spelling is present", () => {
261
+ globalThis.expect([
262
+ get("identityProviderId"),
263
+ get("identityProviderClientId")
264
+ ]).toEqual([
265
+ "eu-west-1_x",
266
+ "7cl13nt"
267
+ ]);
268
+ });
269
+ globalThis.test("the deprecated spelling is present too", () => {
270
+ globalThis.expect([
271
+ get("cognitoUserPoolId"),
272
+ get("cognitoClientId")
273
+ ]).toEqual([
274
+ "eu-west-1_x",
275
+ "7cl13nt"
276
+ ]);
277
+ });
278
+ globalThis.test("both spellings carry identical values", () => {
279
+ globalThis.expect([
280
+ Primitive_object.equal(get("identityProviderId"), get("cognitoUserPoolId")),
281
+ Primitive_object.equal(get("identityProviderClientId"), get("cognitoClientId"))
282
+ ]).toEqual([
283
+ true,
284
+ true
285
+ ]);
286
+ });
287
+ globalThis.test("nothing else sneaks into the identity field set", () => {
288
+ globalThis.expect(fields.map(param => param[0]).toSorted(Primitive_string.compare)).toEqual([
289
+ "cognitoClientId",
290
+ "cognitoUserPoolId",
291
+ "identityProviderClientId",
292
+ "identityProviderId"
293
+ ]);
294
+ });
295
+ });
296
+
255
297
  export {
256
298
  computed,
257
299
  get,