@reventlessdev/reventless-spec 3.0.0-alpha.134 → 3.0.0-alpha.136

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 (36) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/package.json +4 -3
  3. package/run-check-lifecycle.mjs +2 -1
  4. package/run-prepare-accounts.mjs +3 -0
  5. package/src/components/CapabilityManifest.res +4 -0
  6. package/src/components/CapabilityManifest.res.mjs +13 -2
  7. package/src/components/DcbScopeInference.res +224 -73
  8. package/src/components/DcbScopeInference.res.mjs +187 -49
  9. package/src/components/DcbTag.res +142 -186
  10. package/src/components/DcbTag.res.mjs +137 -128
  11. package/src/components/DcbValidation.res +50 -0
  12. package/src/components/DcbValidation.res.mjs +51 -0
  13. package/src/generator/Codegen.res +2 -1
  14. package/src/generator/Codegen.res.mjs +1 -1
  15. package/src/generator/PlatformCodegen.res +1 -0
  16. package/src/generator/PlatformCodegen.res.mjs +5 -0
  17. package/src/lifecycle/CheckLifecycleModel.res +148 -8
  18. package/src/lifecycle/CheckLifecycleModel.res.mjs +154 -7
  19. package/src/semantic/Capabilities.res +17 -0
  20. package/src/semantic/Capabilities.res.mjs +9 -1
  21. package/src/semantic/CapabilityNeed.res +12 -0
  22. package/src/semantic/CapabilityNeed.res.mjs +9 -4
  23. package/src/semantic/IdentityProvider.res +127 -0
  24. package/src/semantic/IdentityProvider.res.mjs +65 -0
  25. package/src/semantic/Secrets.res +76 -0
  26. package/src/semantic/Secrets.res.mjs +49 -0
  27. package/src/types/AccountsManifest.res +287 -0
  28. package/src/types/AccountsManifest.res.mjs +312 -0
  29. package/src/types/AdminGroup.res +27 -0
  30. package/src/types/AdminGroup.res.mjs +9 -0
  31. package/src/types/OwnerScope.res +27 -0
  32. package/src/types/OwnerScope.res.mjs +12 -0
  33. package/src/types/PrepareAccounts.res +119 -0
  34. package/src/types/PrepareAccounts.res.mjs +148 -0
  35. package/src/util/Util_Password.res +60 -0
  36. package/src/util/Util_Password.res.mjs +53 -0
@@ -0,0 +1,60 @@
1
+ /***
2
+ A password a Reventless pool will accept, minted rather than chosen.
3
+
4
+ Here rather than beside the AWS provisioning script because two callers need it
5
+ and only one of them is AWS: `provision-admin` mints the first administrator's
6
+ credential, and [AccountsManifest.prepare] fills a manifest's empty password
7
+ fields on any platform, with no cloud account involved. A generator living in
8
+ `reventless/aws` would make the platform-neutral half reach into the AWS package
9
+ for arithmetic that has nothing to do with AWS.
10
+ */
11
+
12
+ /** Excludes the glyphs a person confuses when retyping a printed credential —
13
+ `l`/`I`/`1` and `O`/`0`. These passwords are read off a terminal or out of a
14
+ file once, and a bootstrap that fails on a misread character sends the operator
15
+ back to the console this exists to avoid. */
16
+ let lower = "abcdefghijkmnopqrstuvwxyz"
17
+ let upper = "ABCDEFGHJKLMNPQRSTUVWXYZ"
18
+ let digits = "23456789"
19
+ let alphabet = lower ++ upper ++ digits
20
+
21
+ /** Comfortably over the 12 every Reventless pool is created with, since nobody
22
+ has to remember it. */
23
+ let length = 24
24
+
25
+ /** `count` uniform bytes as ints.
26
+
27
+ Via the hex encoding because that is what [NodeCrypto] exposes of a Buffer, and
28
+ a binding returning raw byte values would be a new one added for this alone.
29
+ Two hex digits always parse, so the fallback below is unreachable — it is there
30
+ because the parse is *typed* as partial, not because it can fail. */
31
+ let randomInts = (count: int): array<int> => {
32
+ let hex = NodeCrypto.randomBytes(count)->NodeCrypto.bufferToString("hex")
33
+ Array.fromInitializer(~length=count, i =>
34
+ hex->String.substring(~start=i * 2, ~end=i * 2 + 2)->Int.fromString(~radix=16)->Option.getOr(0)
35
+ )
36
+ }
37
+
38
+ let charAt = (source: string, n: int): string =>
39
+ source->String.charAt(mod(n, source->String.length))
40
+
41
+ /**
42
+ A password that satisfies the pool policy every Reventless pool is created with
43
+ (12+ characters, with a lowercase, an uppercase and a digit).
44
+
45
+ Satisfies it *by construction*: the three required classes are written into three
46
+ non-overlapping thirds of the string, so one of each is always present. The
47
+ obvious alternative — generate, test, regenerate — would leave a branch that
48
+ almost never runs and, when it did, would hand Cognito a password it refuses.
49
+ Almost-never is exactly the branch nobody has tested.
50
+ */
51
+ let generate = (): string => {
52
+ let ints = randomInts(length + 6)
53
+ let chars = ints->Array.slice(~start=0, ~end=length)->Array.map(n => alphabet->charAt(n))
54
+ let third = length / 3
55
+ [lower, upper, digits]->Array.forEachWithIndex((classAlphabet, block) => {
56
+ let position = block * third + mod(ints->Array.getUnsafe(length + block), third)
57
+ chars->Array.set(position, classAlphabet->charAt(ints->Array.getUnsafe(length + 3 + block)))
58
+ })
59
+ chars->Array.join("")
60
+ }
@@ -0,0 +1,53 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Stdlib_Int from "@rescript/runtime/lib/es6/Stdlib_Int.js";
4
+ import * as Nodecrypto from "node:crypto";
5
+ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
6
+ import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.js";
7
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
8
+
9
+ let lower = "abcdefghijkmnopqrstuvwxyz";
10
+
11
+ let upper = "ABCDEFGHJKLMNPQRSTUVWXYZ";
12
+
13
+ let digits = "23456789";
14
+
15
+ let alphabet = lower + upper + digits;
16
+
17
+ function randomInts(count) {
18
+ let hex = Nodecrypto.randomBytes(count).toString("hex");
19
+ return Stdlib_Array.fromInitializer(count, i => Stdlib_Option.getOr(Stdlib_Int.fromString(hex.substring((i << 1), (i << 1) + 2 | 0), 16), 0));
20
+ }
21
+
22
+ function charAt(source, n) {
23
+ return source.charAt(Primitive_int.mod_(n, source.length));
24
+ }
25
+
26
+ function generate() {
27
+ let ints = randomInts(30);
28
+ let chars = ints.slice(0, 24).map(n => charAt(alphabet, n));
29
+ let third = 8;
30
+ [
31
+ lower,
32
+ upper,
33
+ digits
34
+ ].forEach((classAlphabet, block) => {
35
+ let position = (block * third | 0) + Primitive_int.mod_(ints[24 + block | 0], third) | 0;
36
+ chars[position] = charAt(classAlphabet, ints[27 + block | 0]);
37
+ });
38
+ return chars.join("");
39
+ }
40
+
41
+ let length = 24;
42
+
43
+ export {
44
+ lower,
45
+ upper,
46
+ digits,
47
+ alphabet,
48
+ length,
49
+ randomInts,
50
+ charAt,
51
+ generate,
52
+ }
53
+ /* node:crypto Not a pure module */