@reventlessdev/reventless-aws 3.0.0-alpha.345 → 3.0.0-alpha.346
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.
- package/CHANGELOG.md +28 -0
- package/package.json +12 -9
- package/run-provision-accounts.mjs +3 -0
- package/run-provision-admin.mjs +3 -0
- package/scripts/ProvisionAccounts.res +325 -0
- package/scripts/ProvisionAccounts.res.mjs +337 -0
- package/scripts/ProvisionAdmin.res +275 -0
- package/scripts/ProvisionAdmin.res.mjs +289 -0
- package/scripts/ProvisionCognito.res +149 -0
- package/scripts/ProvisionCognito.res.mjs +98 -0
- package/scripts/ProvisionIdentity.res +76 -11
- package/scripts/ProvisionIdentity.res.mjs +72 -7
- package/scripts/ProvisionProvider.res +104 -0
- package/scripts/ProvisionProvider.res.mjs +123 -0
- package/src/Platform.res +32 -2
- package/src/Platform.res.mjs +20 -10
- package/src/Platform_Stack.res +119 -9
- package/src/Platform_Stack.res.mjs +42 -4
- package/src/adapter/Auth/Auth_LoginIdentifier.res +66 -0
- package/src/adapter/Auth/Auth_LoginIdentifier.res.mjs +70 -0
- package/src/adapter/Auth/Auth_SignUpMode.res +78 -0
- package/src/adapter/Auth/Auth_SignUpMode.res.mjs +56 -0
- package/src/adapter/Runtime/AutomationSliceEntryPoint_Ops.res +5 -0
- package/src/adapter/Runtime/AutomationSliceEntryPoint_Ops.res.mjs +5 -1
- package/src/components/Api/AppSync_Adapter.res +56 -72
- package/src/components/Api/AppSync_Adapter.res.mjs +26 -60
- package/src/components/Api/AppSync_SdlDecorate.res +80 -1
- package/src/components/Api/AppSync_SdlDecorate.res.mjs +45 -0
- package/tests/AppSync_AdapterTest.res +83 -0
- package/tests/AppSync_AdapterTest.res.mjs +69 -0
- package/tests/Auth_LoginIdentifierTest.res +51 -0
- package/tests/Auth_LoginIdentifierTest.res.mjs +51 -0
- package/tests/Auth_SignUpModeTest.res +56 -0
- package/tests/Auth_SignUpModeTest.res.mjs +53 -0
- package/tests/ProvisionAccountsTest.res +142 -0
- package/tests/ProvisionAccountsTest.res.mjs +153 -0
- package/tests/ProvisionAdminTest.res +55 -0
- package/tests/ProvisionAdminTest.res.mjs +66 -0
- package/tests/ProvisionIdentityTest.res +89 -3
- package/tests/ProvisionIdentityTest.res.mjs +66 -1
- package/tests/Util_OwnerScopeEnvTest.res +25 -0
- package/tests/Util_OwnerScopeEnvTest.res.mjs +13 -0
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
3
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
4
|
+
import * as Stdlib_Result from "@rescript/runtime/lib/es6/Stdlib_Result.js";
|
|
4
5
|
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
5
6
|
import * as ClientDynamodb from "@aws-sdk/client-dynamodb";
|
|
6
7
|
import * as DynamoDb_DynamoDb$AwsSdk from "@reventlessdev/rescript-aws-sdk/src/DynamoDb_DynamoDb.res.mjs";
|
|
7
8
|
import * as Util_AwsError$ReventlessAws from "../src/util/Util_AwsError.res.mjs";
|
|
9
|
+
import * as Auth_SignUpMode$ReventlessAws from "../src/adapter/Auth/Auth_SignUpMode.res.mjs";
|
|
10
|
+
import * as Auth_LoginIdentifier$ReventlessAws from "../src/adapter/Auth/Auth_LoginIdentifier.res.mjs";
|
|
8
11
|
import * as CognitoIdentityServiceProvider$AwsSdk from "@reventlessdev/rescript-aws-sdk/src/CognitoIdentityServiceProvider.res.mjs";
|
|
9
12
|
import * as ClientCognitoIdentityProvider from "@aws-sdk/client-cognito-identity-provider";
|
|
10
13
|
import * as Auth_ActiveRoleStore_Schema$ReventlessAws from "../src/adapter/Auth/Auth_ActiveRoleStore_Schema.res.mjs";
|
|
@@ -17,6 +20,8 @@ function parseArgs(argv) {
|
|
|
17
20
|
_0: {
|
|
18
21
|
poolName: defaultPoolName,
|
|
19
22
|
providerId: undefined,
|
|
23
|
+
loginIdentifier: Auth_LoginIdentifier$ReventlessAws.default,
|
|
24
|
+
signUpMode: Auth_SignUpMode$ReventlessAws.default,
|
|
20
25
|
help: false
|
|
21
26
|
}
|
|
22
27
|
};
|
|
@@ -31,6 +36,20 @@ function parseArgs(argv) {
|
|
|
31
36
|
let a = match._0;
|
|
32
37
|
let exit$1 = 0;
|
|
33
38
|
switch (flag) {
|
|
39
|
+
case "--login-identifier" :
|
|
40
|
+
if (value !== undefined) {
|
|
41
|
+
acc = Stdlib_Result.map(Auth_LoginIdentifier$ReventlessAws.parse(value), loginIdentifier => ({
|
|
42
|
+
poolName: a.poolName,
|
|
43
|
+
providerId: a.providerId,
|
|
44
|
+
loginIdentifier: loginIdentifier,
|
|
45
|
+
signUpMode: a.signUpMode,
|
|
46
|
+
help: a.help
|
|
47
|
+
}));
|
|
48
|
+
i = i + 2 | 0;
|
|
49
|
+
} else {
|
|
50
|
+
exit = 1;
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
34
53
|
case "--name" :
|
|
35
54
|
if (value !== undefined) {
|
|
36
55
|
acc = {
|
|
@@ -38,6 +57,8 @@ function parseArgs(argv) {
|
|
|
38
57
|
_0: {
|
|
39
58
|
poolName: value,
|
|
40
59
|
providerId: a.providerId,
|
|
60
|
+
loginIdentifier: a.loginIdentifier,
|
|
61
|
+
signUpMode: a.signUpMode,
|
|
41
62
|
help: a.help
|
|
42
63
|
}
|
|
43
64
|
};
|
|
@@ -53,6 +74,8 @@ function parseArgs(argv) {
|
|
|
53
74
|
_0: {
|
|
54
75
|
poolName: a.poolName,
|
|
55
76
|
providerId: value,
|
|
77
|
+
loginIdentifier: a.loginIdentifier,
|
|
78
|
+
signUpMode: a.signUpMode,
|
|
56
79
|
help: a.help
|
|
57
80
|
}
|
|
58
81
|
};
|
|
@@ -61,6 +84,20 @@ function parseArgs(argv) {
|
|
|
61
84
|
exit = 1;
|
|
62
85
|
}
|
|
63
86
|
break;
|
|
87
|
+
case "--sign-up-mode" :
|
|
88
|
+
if (value !== undefined) {
|
|
89
|
+
acc = Stdlib_Result.map(Auth_SignUpMode$ReventlessAws.parse(value), signUpMode => ({
|
|
90
|
+
poolName: a.poolName,
|
|
91
|
+
providerId: a.providerId,
|
|
92
|
+
loginIdentifier: a.loginIdentifier,
|
|
93
|
+
signUpMode: signUpMode,
|
|
94
|
+
help: a.help
|
|
95
|
+
}));
|
|
96
|
+
i = i + 2 | 0;
|
|
97
|
+
} else {
|
|
98
|
+
exit = 1;
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
64
101
|
case "--help" :
|
|
65
102
|
case "-h" :
|
|
66
103
|
exit$1 = 2;
|
|
@@ -77,6 +114,8 @@ function parseArgs(argv) {
|
|
|
77
114
|
_0: {
|
|
78
115
|
poolName: a.poolName,
|
|
79
116
|
providerId: a.providerId,
|
|
117
|
+
loginIdentifier: a.loginIdentifier,
|
|
118
|
+
signUpMode: a.signUpMode,
|
|
80
119
|
help: true
|
|
81
120
|
}
|
|
82
121
|
};
|
|
@@ -95,21 +134,36 @@ function parseArgs(argv) {
|
|
|
95
134
|
return acc;
|
|
96
135
|
}
|
|
97
136
|
|
|
137
|
+
let _loginIdentifiers = Auth_LoginIdentifier$ReventlessAws.all.map(Auth_LoginIdentifier$ReventlessAws.toString).join(" | ");
|
|
138
|
+
|
|
139
|
+
let _defaultLoginIdentifier = Auth_LoginIdentifier$ReventlessAws.toString(Auth_LoginIdentifier$ReventlessAws.default);
|
|
140
|
+
|
|
141
|
+
let _signUpModes = Auth_SignUpMode$ReventlessAws.all.map(Auth_SignUpMode$ReventlessAws.toString).join(" | ");
|
|
142
|
+
|
|
143
|
+
let _defaultSignUpMode = Auth_SignUpMode$ReventlessAws.toString(Auth_SignUpMode$ReventlessAws.default);
|
|
144
|
+
|
|
98
145
|
let usage = `
|
|
99
146
|
Provision a Reventless identity provider and its active-role store.
|
|
100
147
|
|
|
101
148
|
--name <name> Pool name to create or adopt (default: ` + defaultPoolName + `)
|
|
102
149
|
--provider-id <id> Use this existing pool instead of creating one; only the
|
|
103
150
|
store is provisioned
|
|
151
|
+
--login-identifier <a> Sign-in attribute for a pool this creates: ` + _loginIdentifiers + `
|
|
152
|
+
(default: ` + _defaultLoginIdentifier + `). Fixed at creation —
|
|
153
|
+
no later change is possible without replacing the pool
|
|
154
|
+
and losing every account in it.
|
|
155
|
+
--sign-up-mode <m> Whether a stranger may register themselves: ` + _signUpModes + `
|
|
156
|
+
(default: ` + _defaultSignUpMode + `). Correctable later, but on a
|
|
157
|
+
pool shared between stacks it applies to all of them.
|
|
104
158
|
|
|
105
159
|
Creates nothing that a platform stack owns, and never attaches a trigger.
|
|
106
160
|
Region and credentials come from the environment, as for any AWS SDK call.
|
|
107
161
|
`;
|
|
108
162
|
|
|
109
|
-
function poolSettings(poolName) {
|
|
163
|
+
function poolSettings(poolName, loginIdentifier, signUpMode) {
|
|
110
164
|
return {
|
|
111
165
|
PoolName: poolName,
|
|
112
|
-
UsernameAttributes:
|
|
166
|
+
UsernameAttributes: Auth_LoginIdentifier$ReventlessAws.usernameAttributes(loginIdentifier),
|
|
113
167
|
MfaConfiguration: "OFF",
|
|
114
168
|
Policies: {
|
|
115
169
|
PasswordPolicy: {
|
|
@@ -120,7 +174,7 @@ function poolSettings(poolName) {
|
|
|
120
174
|
}
|
|
121
175
|
},
|
|
122
176
|
AdminCreateUserConfig: {
|
|
123
|
-
AllowAdminCreateUserOnly:
|
|
177
|
+
AllowAdminCreateUserOnly: Auth_SignUpMode$ReventlessAws.allowAdminCreateUserOnly(signUpMode)
|
|
124
178
|
}
|
|
125
179
|
};
|
|
126
180
|
}
|
|
@@ -194,10 +248,10 @@ async function resolvePool(args) {
|
|
|
194
248
|
_0: existing
|
|
195
249
|
};
|
|
196
250
|
}
|
|
197
|
-
let created = await CognitoIdentityServiceProvider$AwsSdk.CreateUserPoolCommand.send(new ClientCognitoIdentityProvider.CreateUserPoolCommand(poolSettings(args.poolName)));
|
|
251
|
+
let created = await CognitoIdentityServiceProvider$AwsSdk.CreateUserPoolCommand.send(new ClientCognitoIdentityProvider.CreateUserPoolCommand(poolSettings(args.poolName, args.loginIdentifier, args.signUpMode)));
|
|
198
252
|
let id$1 = Stdlib_Option.flatMap(created.UserPool, p => p.Id);
|
|
199
253
|
if (id$1 !== undefined) {
|
|
200
|
-
console.log(`pool ` + id$1 + ` (created, named "` + args.poolName + `")`);
|
|
254
|
+
console.log(`pool ` + id$1 + ` (created, named "` + args.poolName + `", sign-in on ` + Auth_LoginIdentifier$ReventlessAws.toString(args.loginIdentifier) + `, sign-up ` + Auth_SignUpMode$ReventlessAws.toString(args.signUpMode) + `)`);
|
|
201
255
|
return {
|
|
202
256
|
TAG: "Ok",
|
|
203
257
|
_0: id$1
|
|
@@ -305,7 +359,14 @@ or set REVENTLESS_IDENTITY_PROVIDER_ID in CI. Every stack on this provider
|
|
|
305
359
|
derives the same store, so there is nothing else to configure.
|
|
306
360
|
|
|
307
361
|
The pre-token-generation trigger is attached by the deploy, not by this script.
|
|
308
|
-
|
|
362
|
+
|
|
363
|
+
Once a stack has deployed against this provider, make the first administrator:
|
|
364
|
+
|
|
365
|
+
pnpm exec provision-admin --provider-id ` + providerId + ` --email you@example.com
|
|
366
|
+
|
|
367
|
+
That is a separate bin because it provisions nothing a stack owns, and because it
|
|
368
|
+
is needed on a pool created here and on one a stack created for itself alike. See
|
|
369
|
+
[ProvisionAdmin].`;
|
|
309
370
|
}
|
|
310
371
|
|
|
311
372
|
async function run() {
|
|
@@ -361,6 +422,10 @@ export {
|
|
|
361
422
|
Schema,
|
|
362
423
|
defaultPoolName,
|
|
363
424
|
parseArgs,
|
|
425
|
+
_loginIdentifiers,
|
|
426
|
+
_defaultLoginIdentifier,
|
|
427
|
+
_signUpModes,
|
|
428
|
+
_defaultSignUpMode,
|
|
364
429
|
usage,
|
|
365
430
|
poolSettings,
|
|
366
431
|
findPoolByName,
|
|
@@ -373,4 +438,4 @@ export {
|
|
|
373
438
|
run,
|
|
374
439
|
main,
|
|
375
440
|
}
|
|
376
|
-
/*
|
|
441
|
+
/* _loginIdentifiers Not a pure module */
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/***
|
|
2
|
+
Which identity provider a provisioning run is about.
|
|
3
|
+
|
|
4
|
+
Both bins ask the same question and neither should make the operator answer it
|
|
5
|
+
twice. The docs used to say `--provider-id $(pulumi stack output
|
|
6
|
+
identityProviderId)`, which is a command substitution a tool can perform.
|
|
7
|
+
|
|
8
|
+
🚨 **Three sources, in this order, and the last is a fallback rather than the
|
|
9
|
+
path.** An explicit `--provider-id` wins, then `REVENTLESS_IDENTITY_PROVIDER_ID`
|
|
10
|
+
— the variable [Platform_Stack] reads for the same value, so a CI shell that
|
|
11
|
+
already exports it needs no second spelling — and only then the stack.
|
|
12
|
+
|
|
13
|
+
Reading the stack works in *both* modes, which is the fact that makes this worth
|
|
14
|
+
doing rather than a convenience for auto deployments only: [Platform_Stack]
|
|
15
|
+
exports `identityProviderId` whether it created the pool or was handed one, so a
|
|
16
|
+
BYO deployment re-exports the provider it was given.
|
|
17
|
+
|
|
18
|
+
🚨 **It always reports which source answered, and which stack.** `pulumi stack
|
|
19
|
+
output` with no `--stack` reads whichever stack happens to be selected, so a run
|
|
20
|
+
against `alpha` while the operator believes they are on `beta` would succeed —
|
|
21
|
+
in the wrong pool, leaving working accounts somewhere nobody is looking. That is
|
|
22
|
+
worse than failing. So the stack is resolved by name, named in the output, and
|
|
23
|
+
overridable with `--stack`.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** Where an id came from, so a run can say so rather than leave it inferred. */
|
|
27
|
+
type source =
|
|
28
|
+
| Flag
|
|
29
|
+
| Environment
|
|
30
|
+
| Stack(string)
|
|
31
|
+
|
|
32
|
+
let describe = (source: source): string =>
|
|
33
|
+
switch source {
|
|
34
|
+
| Flag => "--provider-id"
|
|
35
|
+
| Environment => "REVENTLESS_IDENTITY_PROVIDER_ID"
|
|
36
|
+
| Stack(stack) => `stack ${stack}`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The same variable [Platform_Stack] reads for the same value. */
|
|
40
|
+
let envKey = "REVENTLESS_IDENTITY_PROVIDER_ID"
|
|
41
|
+
|
|
42
|
+
/** `stdio` leaves stderr to the caller's terminal but keeps stdout, so a Pulumi
|
|
43
|
+
failure is legible where it happens instead of being swallowed and re-reported
|
|
44
|
+
as a vaguer message here. */
|
|
45
|
+
let pulumi = (args: array<string>): string =>
|
|
46
|
+
NodeChildProcess.execFileSync(
|
|
47
|
+
"pulumi",
|
|
48
|
+
args,
|
|
49
|
+
{encoding: "utf8", stdio: ["ignore", "pipe", "ignore"]},
|
|
50
|
+
)->String.trim
|
|
51
|
+
|
|
52
|
+
/** The stack the working directory currently has selected. `None` when there is
|
|
53
|
+
no Pulumi project here, no stack selected, or no `pulumi` on the PATH — all of
|
|
54
|
+
which are ordinary for someone running against a BYO pool, and none of which
|
|
55
|
+
should be an error until the id is actually needed. */
|
|
56
|
+
let selectedStack = (): option<string> =>
|
|
57
|
+
switch pulumi(["stack", "--show-name"]) {
|
|
58
|
+
| "" => None
|
|
59
|
+
| name => Some(name)
|
|
60
|
+
| exception _ => None
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
The provider id a stack exports.
|
|
65
|
+
|
|
66
|
+
`--stack` is passed explicitly even when it names the already-selected stack, so
|
|
67
|
+
the value read and the name reported cannot drift apart between the two calls.
|
|
68
|
+
*/
|
|
69
|
+
let fromStack = (~stack: string): result<string, string> =>
|
|
70
|
+
switch pulumi(["stack", "output", "identityProviderId", "--stack", stack]) {
|
|
71
|
+
| "" =>
|
|
72
|
+
Error(
|
|
73
|
+
`stack "${stack}" exports no identityProviderId — deploy the platform stack first, or pass --provider-id`,
|
|
74
|
+
)
|
|
75
|
+
| id => Ok(id)
|
|
76
|
+
| exception _ =>
|
|
77
|
+
Error(
|
|
78
|
+
`could not read identityProviderId from stack "${stack}" — is pulumi installed, logged in, and the stack deployed? Pass --provider-id to skip this lookup`,
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
The provider this run is about, and where the answer came from.
|
|
84
|
+
|
|
85
|
+
The error names all three sources rather than only the one that was tried last:
|
|
86
|
+
someone who has no Pulumi project here needs to be told about the flag, and
|
|
87
|
+
someone who has one needs to be told it was consulted and came back empty.
|
|
88
|
+
*/
|
|
89
|
+
let resolve = (~given: option<string>, ~stack: option<string>): result<(string, source), string> =>
|
|
90
|
+
switch given {
|
|
91
|
+
| Some(id) => Ok((id, Flag))
|
|
92
|
+
| None =>
|
|
93
|
+
switch NodeProcess.env->Dict.get(envKey) {
|
|
94
|
+
| Some(id) if id->String.trim != "" => Ok((id, Environment))
|
|
95
|
+
| _ =>
|
|
96
|
+
switch stack->Option.orElse(selectedStack()) {
|
|
97
|
+
| None =>
|
|
98
|
+
Error(
|
|
99
|
+
`--provider-id is required (or set ${envKey}). It is also read from a deployed stack, but no Pulumi stack is selected here — run this from the platform package, or pass --stack`,
|
|
100
|
+
)
|
|
101
|
+
| Some(stack) => fromStack(~stack)->Result.map(id => (id, Stack(stack)))
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
4
|
+
import * as Stdlib_Result from "@rescript/runtime/lib/es6/Stdlib_Result.js";
|
|
5
|
+
import * as Nodechild_process from "node:child_process";
|
|
6
|
+
|
|
7
|
+
function describe(source) {
|
|
8
|
+
if (typeof source !== "object") {
|
|
9
|
+
if (source === "Flag") {
|
|
10
|
+
return "--provider-id";
|
|
11
|
+
} else {
|
|
12
|
+
return "REVENTLESS_IDENTITY_PROVIDER_ID";
|
|
13
|
+
}
|
|
14
|
+
} else {
|
|
15
|
+
return `stack ` + source._0;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let envKey = "REVENTLESS_IDENTITY_PROVIDER_ID";
|
|
20
|
+
|
|
21
|
+
function pulumi(args) {
|
|
22
|
+
return Nodechild_process.execFileSync("pulumi", args, {
|
|
23
|
+
encoding: "utf8",
|
|
24
|
+
stdio: [
|
|
25
|
+
"ignore",
|
|
26
|
+
"pipe",
|
|
27
|
+
"ignore"
|
|
28
|
+
]
|
|
29
|
+
}).trim();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function selectedStack() {
|
|
33
|
+
let name;
|
|
34
|
+
try {
|
|
35
|
+
name = pulumi([
|
|
36
|
+
"stack",
|
|
37
|
+
"--show-name"
|
|
38
|
+
]);
|
|
39
|
+
} catch (exn) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (name === "") {
|
|
43
|
+
return;
|
|
44
|
+
} else {
|
|
45
|
+
return name;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function fromStack(stack) {
|
|
50
|
+
let id;
|
|
51
|
+
try {
|
|
52
|
+
id = pulumi([
|
|
53
|
+
"stack",
|
|
54
|
+
"output",
|
|
55
|
+
"identityProviderId",
|
|
56
|
+
"--stack",
|
|
57
|
+
stack
|
|
58
|
+
]);
|
|
59
|
+
} catch (exn) {
|
|
60
|
+
return {
|
|
61
|
+
TAG: "Error",
|
|
62
|
+
_0: `could not read identityProviderId from stack "` + stack + `" — is pulumi installed, logged in, and the stack deployed? Pass --provider-id to skip this lookup`
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (id === "") {
|
|
66
|
+
return {
|
|
67
|
+
TAG: "Error",
|
|
68
|
+
_0: `stack "` + stack + `" exports no identityProviderId — deploy the platform stack first, or pass --provider-id`
|
|
69
|
+
};
|
|
70
|
+
} else {
|
|
71
|
+
return {
|
|
72
|
+
TAG: "Ok",
|
|
73
|
+
_0: id
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function resolve(given, stack) {
|
|
79
|
+
if (given !== undefined) {
|
|
80
|
+
return {
|
|
81
|
+
TAG: "Ok",
|
|
82
|
+
_0: [
|
|
83
|
+
given,
|
|
84
|
+
"Flag"
|
|
85
|
+
]
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
let id = process.env[envKey];
|
|
89
|
+
if (id !== undefined && id.trim() !== "") {
|
|
90
|
+
return {
|
|
91
|
+
TAG: "Ok",
|
|
92
|
+
_0: [
|
|
93
|
+
id,
|
|
94
|
+
"Environment"
|
|
95
|
+
]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
let stack$1 = Stdlib_Option.orElse(stack, selectedStack());
|
|
99
|
+
if (stack$1 !== undefined) {
|
|
100
|
+
return Stdlib_Result.map(fromStack(stack$1), id => [
|
|
101
|
+
id,
|
|
102
|
+
{
|
|
103
|
+
TAG: "Stack",
|
|
104
|
+
_0: stack$1
|
|
105
|
+
}
|
|
106
|
+
]);
|
|
107
|
+
} else {
|
|
108
|
+
return {
|
|
109
|
+
TAG: "Error",
|
|
110
|
+
_0: `--provider-id is required (or set ` + envKey + `). It is also read from a deployed stack, but no Pulumi stack is selected here — run this from the platform package, or pass --stack`
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
describe,
|
|
117
|
+
envKey,
|
|
118
|
+
pulumi,
|
|
119
|
+
selectedStack,
|
|
120
|
+
fromStack,
|
|
121
|
+
resolve,
|
|
122
|
+
}
|
|
123
|
+
/* node:child_process Not a pure module */
|
package/src/Platform.res
CHANGED
|
@@ -121,6 +121,31 @@ module MakeWithConfig = (
|
|
|
121
121
|
): (
|
|
122
122
|
ReventlessInfra.Platform.T with type api = Types.AppSync.api and type role = Types.AppSync.role
|
|
123
123
|
) => {
|
|
124
|
+
// The administrator group reads across every owner, unless the deployment says
|
|
125
|
+
// otherwise.
|
|
126
|
+
//
|
|
127
|
+
// Authorization and owner scoping decide admin-ness independently and nothing
|
|
128
|
+
// checks that they agree: without this, a deployment gets an administrator who
|
|
129
|
+
// passes every authorization check and then reads *empty* owner-scoped views.
|
|
130
|
+
// `Util_OwnerScopeEnv.applyElevatedGroupsDefault` already carries whatever
|
|
131
|
+
// `OwnerScope.elevatedGroups()` holds into every Lambda's environment — the pipe
|
|
132
|
+
// was laid and nothing ever put a value in.
|
|
133
|
+
//
|
|
134
|
+
// 🚨 **Here, at the entry point, rather than beside the pool that declares the
|
|
135
|
+
// group.** The value has to be set before the runtime builder composes any
|
|
136
|
+
// Lambda's environment, and this functor's body runs when the functor is
|
|
137
|
+
// applied — necessarily before any plugin is built through it. Written into
|
|
138
|
+
// `Platform_Stack.resolveCognitoUserPool` it would instead depend on *which
|
|
139
|
+
// caller resolved the pool first*, which is precisely how a feature once
|
|
140
|
+
// vanished from a deploy with no error and no resource; see the note on
|
|
141
|
+
// `_resolveUncached`. Ordering that is structural beats ordering that happens
|
|
142
|
+
// to hold.
|
|
143
|
+
//
|
|
144
|
+
// A default, never a forcing: an explicit `setElevatedGroups` in a platform
|
|
145
|
+
// root — including one naming nobody — means what it says and wins. See
|
|
146
|
+
// [Reventless.OwnerScope.defaultElevatedGroups].
|
|
147
|
+
Reventless.OwnerScope.defaultElevatedGroups([Reventless.AdminGroup.name])
|
|
148
|
+
|
|
124
149
|
// Dispatch per-flavor commandHandlerConfig records to the four runtime
|
|
125
150
|
// builders. Every sub-record is optional; only branches the caller actually
|
|
126
151
|
// supplied propagate, and within each sub-record every field is optional too
|
|
@@ -287,7 +312,7 @@ module MakeWithConfig = (
|
|
|
287
312
|
assembleCanonicalSourceSdl(
|
|
288
313
|
~baseFragment=AppSync_Adapter.injectAwsAuthAll(
|
|
289
314
|
ReventlessCore.Platform_AdminApi.baseFragment(~cloner=Config.cloner),
|
|
290
|
-
~group=
|
|
315
|
+
~group=Reventless.AdminGroup.name,
|
|
291
316
|
),
|
|
292
317
|
)
|
|
293
318
|
|
|
@@ -1759,7 +1784,8 @@ module MakeWithConfig = (
|
|
|
1759
1784
|
switch c {
|
|
1760
1785
|
| ObjectStore({plugin, store}) => Some((plugin, store))
|
|
1761
1786
|
| Geocoding
|
|
1762
|
-
| Messaging
|
|
1787
|
+
| Messaging
|
|
1788
|
+
| IdentityProvider =>
|
|
1763
1789
|
None
|
|
1764
1790
|
}
|
|
1765
1791
|
)
|
|
@@ -2826,6 +2852,10 @@ module MakeWithConfig = (
|
|
|
2826
2852
|
`as \`~messagingSender\`. The sender itself is configuration and has no ` ++
|
|
2827
2853
|
`default: set \`platform:messagingEmailSender\` in Pulumi.<stack>.yaml (or ` ++
|
|
2828
2854
|
`REVENTLESS_MESSAGING_EMAIL_SENDER), then verify the address with SES — or ` ++ `\`platform:messagingEmailProvider: log\` to log every message and send none.`
|
|
2855
|
+
| IdentityProvider =>
|
|
2856
|
+
`\n IdentityProvider has no backend on any platform yet — the seam and the ` ++
|
|
2857
|
+
`refusal exist, the Cognito and local implementations do not. A plugin ` ++
|
|
2858
|
+
`declaring this need cannot be deployed until one lands; nothing about this ` ++ `deployment's configuration will change that.`
|
|
2829
2859
|
}
|
|
2830
2860
|
)
|
|
2831
2861
|
// One line per capability, not per declaring component: two slices
|
package/src/Platform.res.mjs
CHANGED
|
@@ -16,7 +16,9 @@ import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
|
|
|
16
16
|
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
17
17
|
import * as Plugin$ReventlessAws from "./components/Plugin.res.mjs";
|
|
18
18
|
import * as Util_Sury$Reventless from "@reventlessdev/reventless-spec/src/util/Util_Sury.res.mjs";
|
|
19
|
+
import * as AdminGroup$Reventless from "@reventlessdev/reventless-spec/src/types/AdminGroup.res.mjs";
|
|
19
20
|
import * as Logger$ReventlessCore from "@reventlessdev/reventless-core/src/util/Logger.res.mjs";
|
|
21
|
+
import * as OwnerScope$Reventless from "@reventlessdev/reventless-spec/src/types/OwnerScope.res.mjs";
|
|
20
22
|
import * as Plugin$ReventlessCore from "@reventlessdev/reventless-core/src/plugin/component/Plugin.res.mjs";
|
|
21
23
|
import * as AWS_Tags$ReventlessAws from "./adapter/AWS_Tags.res.mjs";
|
|
22
24
|
import * as Message$ReventlessCore from "@reventlessdev/reventless-core/src/Message.res.mjs";
|
|
@@ -150,6 +152,7 @@ let messagingEmailProviderRef = {
|
|
|
150
152
|
};
|
|
151
153
|
|
|
152
154
|
function MakeWithConfig(Config) {
|
|
155
|
+
OwnerScope$Reventless.defaultElevatedGroups([AdminGroup$Reventless.name]);
|
|
153
156
|
Stdlib_Option.forEach(Config.commandHandlerConfig.aggregates, param => {
|
|
154
157
|
Stdlib_Option.forEach(param.sync, AggregateRuntime_Builder_Single$ReventlessAws.setConfig);
|
|
155
158
|
Stdlib_Option.forEach(param.async, AggregateRuntime_Builder_Single_Async$ReventlessAws.setConfig);
|
|
@@ -211,7 +214,7 @@ function MakeWithConfig(Config) {
|
|
|
211
214
|
subscriptionSources: []
|
|
212
215
|
});
|
|
213
216
|
let adminSourceSdl = () => {
|
|
214
|
-
let baseFragment = AppSync_Adapter$ReventlessAws.injectAwsAuthAll(Platform_AdminApi$ReventlessCore.baseFragment(Config.cloner),
|
|
217
|
+
let baseFragment = AppSync_Adapter$ReventlessAws.injectAwsAuthAll(Platform_AdminApi$ReventlessCore.baseFragment(Config.cloner), AdminGroup$Reventless.name, undefined);
|
|
215
218
|
return AppSync_SdlDecorate$ReventlessAws.stampCanonicalTypes(AppSync_Adapter$ReventlessAws.stitchStandaloneWithAwsDirectives(baseFragment));
|
|
216
219
|
};
|
|
217
220
|
let match;
|
|
@@ -1439,10 +1442,13 @@ function MakeWithConfig(Config) {
|
|
|
1439
1442
|
if (missing.length !== 0) {
|
|
1440
1443
|
Stdlib_JsError.throwWithMessage(CapabilityNeed$Reventless.unmetMessage(missing) + Belt_SetString.toArray(Belt_SetString.fromArray(missing.map(u => {
|
|
1441
1444
|
let match = u.need;
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1445
|
+
switch (match) {
|
|
1446
|
+
case "Geocoding" :
|
|
1447
|
+
return `\n Geocoding is \`Capability_Geocoding_AwsLocation.make\`, passed to the platform as \`~geocoderPlaceIndex\`.`;
|
|
1448
|
+
case "Messaging" :
|
|
1449
|
+
return `\n Messaging is \`Capability_Messaging.make\`, passed to the platform as \`~messagingSender\`. The sender itself is configuration and has no default: set \`platform:messagingEmailSender\` in Pulumi.<stack>.yaml (or REVENTLESS_MESSAGING_EMAIL_SENDER), then verify the address with SES — or \`platform:messagingEmailProvider: log\` to log every message and send none.`;
|
|
1450
|
+
case "IdentityProvider" :
|
|
1451
|
+
return `\n IdentityProvider has no backend on any platform yet — the seam and the refusal exist, the Cognito and local implementations do not. A plugin declaring this need cannot be deployed until one lands; nothing about this deployment's configuration will change that.`;
|
|
1446
1452
|
}
|
|
1447
1453
|
}))).join(""));
|
|
1448
1454
|
}
|
|
@@ -1550,6 +1556,7 @@ function MakeWithConfig(Config) {
|
|
|
1550
1556
|
|
|
1551
1557
|
function Make($star) {
|
|
1552
1558
|
let commandHandlerConfig = {};
|
|
1559
|
+
OwnerScope$Reventless.defaultElevatedGroups([AdminGroup$Reventless.name]);
|
|
1553
1560
|
Stdlib_Option.forEach(commandHandlerConfig.aggregates, param => {
|
|
1554
1561
|
Stdlib_Option.forEach(param.sync, AggregateRuntime_Builder_Single$ReventlessAws.setConfig);
|
|
1555
1562
|
Stdlib_Option.forEach(param.async, AggregateRuntime_Builder_Single_Async$ReventlessAws.setConfig);
|
|
@@ -1611,7 +1618,7 @@ function Make($star) {
|
|
|
1611
1618
|
subscriptionSources: []
|
|
1612
1619
|
});
|
|
1613
1620
|
let adminSourceSdl = () => {
|
|
1614
|
-
let baseFragment = AppSync_Adapter$ReventlessAws.injectAwsAuthAll(Platform_AdminApi$ReventlessCore.baseFragment(false),
|
|
1621
|
+
let baseFragment = AppSync_Adapter$ReventlessAws.injectAwsAuthAll(Platform_AdminApi$ReventlessCore.baseFragment(false), AdminGroup$Reventless.name, undefined);
|
|
1615
1622
|
return AppSync_SdlDecorate$ReventlessAws.stampCanonicalTypes(AppSync_Adapter$ReventlessAws.stitchStandaloneWithAwsDirectives(baseFragment));
|
|
1616
1623
|
};
|
|
1617
1624
|
let match;
|
|
@@ -2814,10 +2821,13 @@ function Make($star) {
|
|
|
2814
2821
|
if (missing.length !== 0) {
|
|
2815
2822
|
Stdlib_JsError.throwWithMessage(CapabilityNeed$Reventless.unmetMessage(missing) + Belt_SetString.toArray(Belt_SetString.fromArray(missing.map(u => {
|
|
2816
2823
|
let match = u.need;
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2824
|
+
switch (match) {
|
|
2825
|
+
case "Geocoding" :
|
|
2826
|
+
return `\n Geocoding is \`Capability_Geocoding_AwsLocation.make\`, passed to the platform as \`~geocoderPlaceIndex\`.`;
|
|
2827
|
+
case "Messaging" :
|
|
2828
|
+
return `\n Messaging is \`Capability_Messaging.make\`, passed to the platform as \`~messagingSender\`. The sender itself is configuration and has no default: set \`platform:messagingEmailSender\` in Pulumi.<stack>.yaml (or REVENTLESS_MESSAGING_EMAIL_SENDER), then verify the address with SES — or \`platform:messagingEmailProvider: log\` to log every message and send none.`;
|
|
2829
|
+
case "IdentityProvider" :
|
|
2830
|
+
return `\n IdentityProvider has no backend on any platform yet — the seam and the refusal exist, the Cognito and local implementations do not. A plugin declaring this need cannot be deployed until one lands; nothing about this deployment's configuration will change that.`;
|
|
2821
2831
|
}
|
|
2822
2832
|
}))).join(""));
|
|
2823
2833
|
}
|