alchemy 2.0.0-beta.75 → 2.0.0-beta.76

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 (69) hide show
  1. package/bin/exec.js +1 -1
  2. package/lib/AWS/Cognito/ManagedLoginBranding.d.ts +108 -0
  3. package/lib/AWS/Cognito/ManagedLoginBranding.d.ts.map +1 -0
  4. package/lib/AWS/Cognito/ManagedLoginBranding.js +200 -0
  5. package/lib/AWS/Cognito/ManagedLoginBranding.js.map +1 -0
  6. package/lib/AWS/Cognito/UserPool.d.ts +80 -0
  7. package/lib/AWS/Cognito/UserPool.d.ts.map +1 -1
  8. package/lib/AWS/Cognito/UserPool.js +72 -4
  9. package/lib/AWS/Cognito/UserPool.js.map +1 -1
  10. package/lib/AWS/Cognito/index.d.ts +1 -0
  11. package/lib/AWS/Cognito/index.d.ts.map +1 -1
  12. package/lib/AWS/Cognito/index.js +1 -0
  13. package/lib/AWS/Cognito/index.js.map +1 -1
  14. package/lib/AWS/Providers.d.ts.map +1 -1
  15. package/lib/AWS/Providers.js +2 -1
  16. package/lib/AWS/Providers.js.map +1 -1
  17. package/lib/AWS/Website/StaticSite.d.ts.map +1 -1
  18. package/lib/AWS/Website/StaticSite.js +8 -4
  19. package/lib/AWS/Website/StaticSite.js.map +1 -1
  20. package/lib/Cli/commands/dev.d.ts +13 -1
  21. package/lib/Cli/commands/dev.d.ts.map +1 -1
  22. package/lib/Cli/commands/dev.js +12 -5
  23. package/lib/Cli/commands/dev.js.map +1 -1
  24. package/lib/Cloudflare/Email/AllowPolicy.d.ts.map +1 -1
  25. package/lib/Cloudflare/Email/AllowPolicy.js +9 -3
  26. package/lib/Cloudflare/Email/AllowPolicy.js.map +1 -1
  27. package/lib/Cloudflare/Email/ImpersonationRegistryEntry.d.ts.map +1 -1
  28. package/lib/Cloudflare/Email/ImpersonationRegistryEntry.js +10 -1
  29. package/lib/Cloudflare/Email/ImpersonationRegistryEntry.js.map +1 -1
  30. package/lib/Cloudflare/Email/TrustedDomain.d.ts.map +1 -1
  31. package/lib/Cloudflare/Email/TrustedDomain.js +10 -1
  32. package/lib/Cloudflare/Email/TrustedDomain.js.map +1 -1
  33. package/lib/Cloudflare/Workers/Assets.d.ts +1 -1
  34. package/lib/Cloudflare/Workers/Assets.d.ts.map +1 -1
  35. package/lib/Cloudflare/Workers/Assets.js +14 -7
  36. package/lib/Cloudflare/Workers/Assets.js.map +1 -1
  37. package/lib/Cloudflare/Workers/WorkerProvider.d.ts.map +1 -1
  38. package/lib/Cloudflare/Workers/WorkerProvider.js +1 -1
  39. package/lib/Cloudflare/Workers/WorkerProvider.js.map +1 -1
  40. package/lib/Command/Dev.d.ts.map +1 -1
  41. package/lib/Command/Dev.js +6 -1
  42. package/lib/Command/Dev.js.map +1 -1
  43. package/lib/Planetscale/Postgres/PostgresDefaultRole.d.ts +8 -0
  44. package/lib/Planetscale/Postgres/PostgresDefaultRole.d.ts.map +1 -1
  45. package/lib/Planetscale/Postgres/PostgresDefaultRole.js +17 -5
  46. package/lib/Planetscale/Postgres/PostgresDefaultRole.js.map +1 -1
  47. package/lib/Planetscale/Postgres/PostgresRole.d.ts +8 -0
  48. package/lib/Planetscale/Postgres/PostgresRole.d.ts.map +1 -1
  49. package/lib/Planetscale/Postgres/PostgresRole.js +2 -0
  50. package/lib/Planetscale/Postgres/PostgresRole.js.map +1 -1
  51. package/lib/Website/Server.d.ts.map +1 -1
  52. package/lib/Website/Server.js +11 -1
  53. package/lib/Website/Server.js.map +1 -1
  54. package/package.json +6 -6
  55. package/src/AWS/Cognito/ManagedLoginBranding.ts +339 -0
  56. package/src/AWS/Cognito/UserPool.ts +144 -6
  57. package/src/AWS/Cognito/index.ts +1 -0
  58. package/src/AWS/Providers.ts +4 -0
  59. package/src/AWS/Website/StaticSite.ts +8 -4
  60. package/src/Cli/commands/dev.ts +13 -6
  61. package/src/Cloudflare/Email/AllowPolicy.ts +9 -3
  62. package/src/Cloudflare/Email/ImpersonationRegistryEntry.ts +9 -1
  63. package/src/Cloudflare/Email/TrustedDomain.ts +9 -1
  64. package/src/Cloudflare/Workers/Assets.ts +14 -6
  65. package/src/Cloudflare/Workers/WorkerProvider.ts +1 -0
  66. package/src/Command/Dev.ts +9 -1
  67. package/src/Planetscale/Postgres/PostgresDefaultRole.ts +27 -5
  68. package/src/Planetscale/Postgres/PostgresRole.ts +12 -0
  69. package/src/Website/Server.ts +16 -1
package/bin/exec.js CHANGED
@@ -3531,7 +3531,7 @@ const excludeDeletedBindings = (bindings) => bindings.flatMap(({ action, sid, da
3531
3531
  }]);
3532
3532
  //#endregion
3533
3533
  //#region package.json
3534
- var version = "2.0.0-beta.75";
3534
+ var version = "2.0.0-beta.76";
3535
3535
  //#endregion
3536
3536
  //#region lib/Telemetry/Attributes.js
3537
3537
  const ALCHEMY_DIR = nodePath.join(os$1.homedir(), ".alchemy");
@@ -0,0 +1,108 @@
1
+ import * as Provider from "../../Provider.ts";
2
+ import { Resource } from "../../Resource.ts";
3
+ import type { Providers } from "../Providers.ts";
4
+ /**
5
+ * An image asset (logo, favicon, background, …) attached to a managed login
6
+ * branding style, per color mode.
7
+ */
8
+ export interface ManagedLoginBrandingAsset {
9
+ /** Which slot of the managed login pages the asset fills. */
10
+ category: "FAVICON_ICO" | "FAVICON_SVG" | "EMAIL_GRAPHIC" | "SMS_GRAPHIC" | "AUTH_APP_GRAPHIC" | "PASSWORD_GRAPHIC" | "PASSKEY_GRAPHIC" | "PAGE_HEADER_LOGO" | "PAGE_HEADER_BACKGROUND" | "PAGE_FOOTER_LOGO" | "PAGE_FOOTER_BACKGROUND" | "PAGE_BACKGROUND" | "FORM_BACKGROUND" | "FORM_LOGO" | "IDP_BUTTON_ICON";
11
+ /** The color scheme the asset applies to. */
12
+ colorMode: "LIGHT" | "DARK" | "DYNAMIC";
13
+ /** The file type of the asset. */
14
+ extension: "ICO" | "JPEG" | "PNG" | "SVG" | "WEBP";
15
+ /** The image file, as bytes (max 2 MB). */
16
+ bytes?: Uint8Array;
17
+ /** For `IDP_BUTTON_ICON` assets, the identity provider the icon is for. */
18
+ resourceId?: string;
19
+ }
20
+ export interface ManagedLoginBrandingProps {
21
+ /**
22
+ * The ID of the user pool the branding style belongs to. Changing this
23
+ * triggers a replacement.
24
+ */
25
+ userPoolId: string;
26
+ /**
27
+ * The ID of the app client the branding style is assigned to. Each app
28
+ * client can have exactly one style. Changing this triggers a
29
+ * replacement.
30
+ */
31
+ clientId: string;
32
+ /**
33
+ * Apply Cognito's default branding instead of custom `settings` /
34
+ * `assets`. This is what makes a fresh pool's managed login pages render
35
+ * without a one-time console step.
36
+ * @default true when neither `settings` nor `assets` is provided
37
+ */
38
+ useCognitoProvidedValues?: boolean;
39
+ /**
40
+ * The branding settings JSON document (colors, component styles, …) in
41
+ * the shape produced by the managed login branding designer / returned by
42
+ * `DescribeManagedLoginBranding`.
43
+ */
44
+ settings?: Record<string, unknown>;
45
+ /**
46
+ * Image assets for the branding style (logos, favicons, backgrounds),
47
+ * one per category + color mode.
48
+ */
49
+ assets?: ManagedLoginBrandingAsset[];
50
+ }
51
+ export interface ManagedLoginBranding extends Resource<"AWS.Cognito.ManagedLoginBranding", ManagedLoginBrandingProps, {
52
+ /** The generated ID of the branding style. */
53
+ managedLoginBrandingId: string;
54
+ /** The ID of the user pool the style belongs to. */
55
+ userPoolId: string;
56
+ /** The ID of the app client the style is assigned to. */
57
+ clientId: string;
58
+ }, never, Providers> {
59
+ }
60
+ /**
61
+ * A managed login branding style for an Amazon Cognito user pool app
62
+ * client. Assigning a style (even just Cognito's provided defaults) is what
63
+ * activates the hosted managed login pages — a `UserPoolDomain` with
64
+ * `managedLoginVersion: 2` serves them end-to-end without any console step.
65
+ * ### Activating Managed Login
66
+ * **Example:** Default Branding for a Hosted Login Domain
67
+ * ```typescript
68
+ * import * as Cognito from "alchemy/AWS/Cognito";
69
+ *
70
+ * const pool = yield* Cognito.UserPool("Users", {});
71
+ * const client = yield* Cognito.UserPoolClient("Web", {
72
+ * userPoolId: pool.userPoolId,
73
+ * callbackUrls: ["https://example.com/callback"],
74
+ * allowedOAuthFlowsUserPoolClient: true,
75
+ * allowedOAuthFlows: ["code"],
76
+ * allowedOAuthScopes: ["openid", "email"],
77
+ * });
78
+ * const domain = yield* Cognito.UserPoolDomain("AuthDomain", {
79
+ * userPoolId: pool.userPoolId,
80
+ * managedLoginVersion: 2,
81
+ * });
82
+ * yield* Cognito.ManagedLoginBranding("Branding", {
83
+ * userPoolId: pool.userPoolId,
84
+ * clientId: client.clientId,
85
+ * });
86
+ * ```
87
+ *
88
+ * ### Custom Branding
89
+ * **Example:** Custom Settings and a Logo Asset
90
+ * ```typescript
91
+ * yield* Cognito.ManagedLoginBranding("Branding", {
92
+ * userPoolId: pool.userPoolId,
93
+ * clientId: client.clientId,
94
+ * settings: brandingSettings, // designer-exported JSON document
95
+ * assets: [{
96
+ * category: "FORM_LOGO",
97
+ * colorMode: "LIGHT",
98
+ * extension: "PNG",
99
+ * bytes: logoBytes,
100
+ * }],
101
+ * });
102
+ * ```
103
+ *
104
+ * @resource
105
+ */
106
+ export declare const ManagedLoginBranding: import("../../Resource.ts").ResourceClass<ManagedLoginBranding>;
107
+ export declare const ManagedLoginBrandingProvider: () => import("effect/Layer").Layer<Provider.Provider<ManagedLoginBranding>, never, import("@distilled.cloud/aws/Credentials").Credentials | import("effect/unstable/http/HttpClient").HttpClient>;
108
+ //# sourceMappingURL=ManagedLoginBranding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ManagedLoginBranding.d.ts","sourceRoot":"","sources":["../../../src/AWS/Cognito/ManagedLoginBranding.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,6DAA6D;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 import * as cip from "@distilled.cloud/aws/cognito-identity-provider";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Schedule from "effect/Schedule";
4
+ import { isResolved } from "../../Diff.js";
5
+ import * as Provider from "../../Provider.js";
6
+ import { Resource } from "../../Resource.js";
7
+ /**
8
+ * A managed login branding style for an Amazon Cognito user pool app
9
+ * client. Assigning a style (even just Cognito's provided defaults) is what
10
+ * activates the hosted managed login pages — a `UserPoolDomain` with
11
+ * `managedLoginVersion: 2` serves them end-to-end without any console step.
12
+ * ### Activating Managed Login
13
+ * **Example:** Default Branding for a Hosted Login Domain
14
+ * ```typescript
15
+ * import * as Cognito from "alchemy/AWS/Cognito";
16
+ *
17
+ * const pool = yield* Cognito.UserPool("Users", {});
18
+ * const client = yield* Cognito.UserPoolClient("Web", {
19
+ * userPoolId: pool.userPoolId,
20
+ * callbackUrls: ["https://example.com/callback"],
21
+ * allowedOAuthFlowsUserPoolClient: true,
22
+ * allowedOAuthFlows: ["code"],
23
+ * allowedOAuthScopes: ["openid", "email"],
24
+ * });
25
+ * const domain = yield* Cognito.UserPoolDomain("AuthDomain", {
26
+ * userPoolId: pool.userPoolId,
27
+ * managedLoginVersion: 2,
28
+ * });
29
+ * yield* Cognito.ManagedLoginBranding("Branding", {
30
+ * userPoolId: pool.userPoolId,
31
+ * clientId: client.clientId,
32
+ * });
33
+ * ```
34
+ *
35
+ * ### Custom Branding
36
+ * **Example:** Custom Settings and a Logo Asset
37
+ * ```typescript
38
+ * yield* Cognito.ManagedLoginBranding("Branding", {
39
+ * userPoolId: pool.userPoolId,
40
+ * clientId: client.clientId,
41
+ * settings: brandingSettings, // designer-exported JSON document
42
+ * assets: [{
43
+ * category: "FORM_LOGO",
44
+ * colorMode: "LIGHT",
45
+ * extension: "PNG",
46
+ * bytes: logoBytes,
47
+ * }],
48
+ * });
49
+ * ```
50
+ *
51
+ * @resource
52
+ */
53
+ export const ManagedLoginBranding = Resource("AWS.Cognito.ManagedLoginBranding");
54
+ const toWireAssets = (assets) => assets?.map((asset) => ({
55
+ Category: asset.category,
56
+ ColorMode: asset.colorMode,
57
+ Extension: asset.extension,
58
+ Bytes: asset.bytes,
59
+ ResourceId: asset.resourceId,
60
+ }));
61
+ /** Canonicalize an asset list for order-insensitive comparison; bytes are
62
+ * folded to base64. */
63
+ const canonicalAssets = (assets) => (assets ?? [])
64
+ .map((asset) => [
65
+ asset.Category,
66
+ asset.ColorMode,
67
+ asset.Extension,
68
+ asset.ResourceId ?? "",
69
+ asset.Bytes === undefined
70
+ ? ""
71
+ : Buffer.from(asset.Bytes).toString("base64"),
72
+ ].join(":"))
73
+ .sort()
74
+ .join(",");
75
+ /**
76
+ * Whether the style should carry Cognito's provided default values: an
77
+ * explicit prop wins, otherwise defaults to `true` exactly when no custom
78
+ * settings/assets are declared.
79
+ */
80
+ const desiredUseProvidedValues = (news) => news.useCognitoProvidedValues ??
81
+ (news.settings === undefined && news.assets === undefined);
82
+ /**
83
+ * Bounded retry over the concurrent-modification window (branding updates
84
+ * can race domain/pool operations). Explicitly typed so the conditional
85
+ * `Retry.Return` type never leaks into declaration emit.
86
+ */
87
+ const retryWhileConcurrent = (self) => Effect.retry(self, {
88
+ while: (e) => e._tag === "ConcurrentModificationException",
89
+ schedule: Schedule.max([Schedule.fixed("2 seconds"), Schedule.recurs(10)]),
90
+ });
91
+ export const ManagedLoginBrandingProvider = () => Provider.effect(ManagedLoginBranding, Effect.gen(function* () {
92
+ const describeById = Effect.fn(function* (userPoolId, managedLoginBrandingId) {
93
+ return yield* cip
94
+ .describeManagedLoginBranding({
95
+ UserPoolId: userPoolId,
96
+ ManagedLoginBrandingId: managedLoginBrandingId,
97
+ })
98
+ .pipe(Effect.map((r) => r.ManagedLoginBranding), Effect.catchTag("ResourceNotFoundException", () => Effect.succeed(undefined)));
99
+ });
100
+ const describeByClient = Effect.fn(function* (userPoolId, clientId) {
101
+ return yield* cip
102
+ .describeManagedLoginBrandingByClient({
103
+ UserPoolId: userPoolId,
104
+ ClientId: clientId,
105
+ })
106
+ .pipe(Effect.map((r) => r.ManagedLoginBranding), Effect.catchTag("ResourceNotFoundException", () => Effect.succeed(undefined)));
107
+ });
108
+ return ManagedLoginBranding.Provider.of({
109
+ stables: ["managedLoginBrandingId", "userPoolId", "clientId"],
110
+ // Sub-resource keyed entirely by its user pool (userPoolId) with no
111
+ // global enumeration API of its own — nuke reaches it through the
112
+ // parent's deletion, so enumeration returns empty per the
113
+ // ProviderService doctrine.
114
+ list: () => Effect.succeed([]),
115
+ read: Effect.fn(function* ({ olds, output }) {
116
+ const userPoolId = output?.userPoolId ?? olds?.userPoolId;
117
+ const clientId = output?.clientId ?? olds?.clientId;
118
+ if (userPoolId === undefined)
119
+ return undefined;
120
+ const observed = output?.managedLoginBrandingId !== undefined
121
+ ? yield* describeById(userPoolId, output.managedLoginBrandingId)
122
+ : clientId !== undefined
123
+ ? yield* describeByClient(userPoolId, clientId)
124
+ : undefined;
125
+ if (observed?.ManagedLoginBrandingId === undefined)
126
+ return undefined;
127
+ return {
128
+ managedLoginBrandingId: observed.ManagedLoginBrandingId,
129
+ userPoolId,
130
+ clientId: clientId,
131
+ };
132
+ }),
133
+ diff: Effect.fn(function* ({ news, olds }) {
134
+ if (!isResolved(news))
135
+ return undefined;
136
+ if (olds?.userPoolId !== news?.userPoolId ||
137
+ olds?.clientId !== news?.clientId) {
138
+ return { action: "replace" };
139
+ }
140
+ }),
141
+ reconcile: Effect.fn(function* ({ news, output, session }) {
142
+ const { userPoolId, clientId } = news;
143
+ const useProvided = desiredUseProvidedValues(news);
144
+ // 1. OBSERVE — output.managedLoginBrandingId is only a cache;
145
+ // fall back to the by-client lookup so state loss converges.
146
+ let observed = output?.managedLoginBrandingId !== undefined
147
+ ? yield* describeById(userPoolId, output.managedLoginBrandingId)
148
+ : undefined;
149
+ if (observed === undefined) {
150
+ observed = yield* describeByClient(userPoolId, clientId);
151
+ }
152
+ // 2. ENSURE — create when missing; a branding created out-of-band
153
+ // (or by a concurrent run) for the same client surfaces as
154
+ // ManagedLoginBrandingExistsException and is taken over.
155
+ if (observed === undefined) {
156
+ observed = yield* cip
157
+ .createManagedLoginBranding({
158
+ UserPoolId: userPoolId,
159
+ ClientId: clientId,
160
+ UseCognitoProvidedValues: useProvided,
161
+ Settings: news.settings,
162
+ Assets: toWireAssets(news.assets),
163
+ })
164
+ .pipe(Effect.map((r) => r.ManagedLoginBranding), Effect.catchTag("ManagedLoginBrandingExistsException", () => describeByClient(userPoolId, clientId)));
165
+ }
166
+ const managedLoginBrandingId = observed?.ManagedLoginBrandingId;
167
+ // 3. SYNC — diff observed style against desired; skip the update
168
+ // entirely on no-op.
169
+ const drift = (observed?.UseCognitoProvidedValues ?? false) !== useProvided ||
170
+ (news.settings !== undefined &&
171
+ JSON.stringify(news.settings) !==
172
+ JSON.stringify(observed?.Settings)) ||
173
+ (news.assets !== undefined &&
174
+ canonicalAssets(toWireAssets(news.assets)) !==
175
+ canonicalAssets(observed?.Assets));
176
+ if (drift) {
177
+ yield* cip
178
+ .updateManagedLoginBranding({
179
+ UserPoolId: userPoolId,
180
+ ManagedLoginBrandingId: managedLoginBrandingId,
181
+ UseCognitoProvidedValues: useProvided,
182
+ Settings: news.settings,
183
+ Assets: toWireAssets(news.assets),
184
+ })
185
+ .pipe(retryWhileConcurrent);
186
+ }
187
+ yield* session.note(managedLoginBrandingId);
188
+ return { managedLoginBrandingId, userPoolId, clientId };
189
+ }),
190
+ delete: Effect.fn(function* ({ output }) {
191
+ yield* cip
192
+ .deleteManagedLoginBranding({
193
+ UserPoolId: output.userPoolId,
194
+ ManagedLoginBrandingId: output.managedLoginBrandingId,
195
+ })
196
+ .pipe(Effect.catchTag("ResourceNotFoundException", () => Effect.void), retryWhileConcurrent);
197
+ }),
198
+ });
199
+ }));
200
+ //# sourceMappingURL=ManagedLoginBranding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ManagedLoginBranding.js","sourceRoot":"","sources":["../../../src/AWS/Cognito/ManagedLoginBranding.ts"],"names":[],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CAAC,CAAC;YAChC,CAAC;YAED,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAC5C,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;QAC1D,CAAC,CAAC;QAEF,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE;YACrC,KAAK,CAAC,CAAC,GAAG;iBACP,0BAA0B,CAAC;gBAC1B,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,sBAAsB,EAAE,MAAM,CAAC,sBAAsB;aACtD,CAAC;iBACD,IAAI,CACH,MAAM,CAAC,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAC/D,oBAAoB,CACrB,CAAC;QACN,CAAC,CAAC;KACH,CAAC,CAAC;AACL,CAAC,CAAC,CACH,CAAC"}
@@ -180,6 +180,46 @@ export interface UserPoolCustomEmailSender {
180
180
  */
181
181
  lambdaVersion?: "V1_0";
182
182
  }
183
+ /**
184
+ * How the user pool delivers its email messages (verification codes, OTPs,
185
+ * invitations): either Cognito's built-in, rate-limited delivery
186
+ * (`COGNITO_DEFAULT`) or your own verified Amazon SES identity
187
+ * (`DEVELOPER`). With `DEVELOPER`, the SES identity's policy must grant
188
+ * `cognito-idp.amazonaws.com` permission to send
189
+ * (`SES.EmailIdentityPolicy`).
190
+ */
191
+ export interface UserPoolEmailConfiguration {
192
+ /**
193
+ * Which sending account delivers the pool's email. `COGNITO_DEFAULT`
194
+ * uses Cognito's built-in delivery (limited daily volume);
195
+ * `DEVELOPER` sends through your own SES identity (`sourceArn`
196
+ * required) at your SES quota.
197
+ * @default "COGNITO_DEFAULT"
198
+ */
199
+ emailSendingAccount?: "COGNITO_DEFAULT" | "DEVELOPER";
200
+ /**
201
+ * ARN of a verified SES email identity (address or domain) in a
202
+ * supported region. Required when `emailSendingAccount` is `DEVELOPER`;
203
+ * with `COGNITO_DEFAULT` it customizes the FROM address while Cognito
204
+ * still handles delivery.
205
+ */
206
+ sourceArn?: string;
207
+ /**
208
+ * The FROM address, either bare (`no-reply@example.com`) or with a
209
+ * friendly display name (`"My App <no-reply@example.com>"`). Must be
210
+ * covered by the `sourceArn` identity.
211
+ */
212
+ from?: string;
213
+ /**
214
+ * The destination for replies to the pool's messages.
215
+ */
216
+ replyToEmailAddress?: string;
217
+ /**
218
+ * Name of an SES configuration set applied to email sent by the pool
219
+ * (event publishing, IP pool selection). `DEVELOPER` only.
220
+ */
221
+ configurationSet?: string;
222
+ }
183
223
  /**
184
224
  * An account recovery mechanism with its priority (1 is highest).
185
225
  */
@@ -283,6 +323,14 @@ export interface UserPoolProps {
283
323
  * never affected by adding or removing it.
284
324
  */
285
325
  customEmailSender?: UserPoolCustomEmailSender;
326
+ /**
327
+ * How the pool delivers its email messages: Cognito's built-in delivery
328
+ * (`COGNITO_DEFAULT`, the service default) or a verified SES identity
329
+ * (`DEVELOPER`) — no custom sender Lambda required. When omitted, an
330
+ * observed email configuration is preserved rather than reset to the
331
+ * service default.
332
+ */
333
+ emailConfiguration?: UserPoolEmailConfiguration;
286
334
  /**
287
335
  * ARN of the symmetric KMS key Cognito uses to encrypt the codes it
288
336
  * passes to the custom sender function(s) (`LambdaConfig.KMSKeyID`).
@@ -348,6 +396,38 @@ export interface UserPool extends Resource<"AWS.Cognito.UserPool", UserPoolProps
348
396
  * });
349
397
  * ```
350
398
  *
399
+ * ### Sending Email Through SES
400
+ * **Example:** OTP and Verification Email from a Verified SES Identity
401
+ * ```typescript
402
+ * const identity = yield* SES.EmailIdentity("Sender", {
403
+ * emailIdentity: "mail.example.com",
404
+ * });
405
+ * // allow Cognito to send through the identity
406
+ * yield* SES.EmailIdentityPolicy("CognitoSend", {
407
+ * emailIdentity: identity.emailIdentity,
408
+ * policyName: "cognito",
409
+ * policy: {
410
+ * Version: "2012-10-17",
411
+ * Statement: [{
412
+ * Effect: "Allow",
413
+ * Principal: { Service: "cognito-idp.amazonaws.com" },
414
+ * Action: ["ses:SendEmail", "ses:SendRawEmail"],
415
+ * Resource: identity.identityArn,
416
+ * }],
417
+ * },
418
+ * });
419
+ * const pool = yield* Cognito.UserPool("Users", {
420
+ * usernameAttributes: ["email"],
421
+ * autoVerifiedAttributes: ["email"],
422
+ * emailConfiguration: {
423
+ * emailSendingAccount: "DEVELOPER",
424
+ * sourceArn: identity.identityArn,
425
+ * from: "My App <no-reply@mail.example.com>",
426
+ * replyToEmailAddress: "support@example.com",
427
+ * },
428
+ * });
429
+ * ```
430
+ *
351
431
  * ### Email OTP with a Custom Email Sender
352
432
  * **Example:** Passwordless Email OTP Delivered by Your Own Lambda
353
433
  * ```typescript
@@ -1 +1 @@
1
- {"version":3,"file":"UserPool.d.ts","sourceRoot":"","sources":["../../../src/AWS/Cognito/UserPool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAMjD,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC;CAC5C;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC;;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AAM,CAAC;IACnB,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,YAAY,EAAE,MAAM,CAAC;CACtB,EACD,eAAe,EACf,SAAS,CACV;CAAG;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2GG;AACH,eAAO,MAAM,QAAQ,qDAA6C,CAAC;AA8JnE,eAAO,MAAM,gBAAgB,yPA2iB1B,CAAC"}
@@ -77,6 +77,38 @@ export class InvalidUserPoolConfiguration extends Data.TaggedError("InvalidUserP
77
77
  * });
78
78
  * ```
79
79
  *
80
+ * ### Sending Email Through SES
81
+ * **Example:** OTP and Verification Email from a Verified SES Identity
82
+ * ```typescript
83
+ * const identity = yield* SES.EmailIdentity("Sender", {
84
+ * emailIdentity: "mail.example.com",
85
+ * });
86
+ * // allow Cognito to send through the identity
87
+ * yield* SES.EmailIdentityPolicy("CognitoSend", {
88
+ * emailIdentity: identity.emailIdentity,
89
+ * policyName: "cognito",
90
+ * policy: {
91
+ * Version: "2012-10-17",
92
+ * Statement: [{
93
+ * Effect: "Allow",
94
+ * Principal: { Service: "cognito-idp.amazonaws.com" },
95
+ * Action: ["ses:SendEmail", "ses:SendRawEmail"],
96
+ * Resource: identity.identityArn,
97
+ * }],
98
+ * },
99
+ * });
100
+ * const pool = yield* Cognito.UserPool("Users", {
101
+ * usernameAttributes: ["email"],
102
+ * autoVerifiedAttributes: ["email"],
103
+ * emailConfiguration: {
104
+ * emailSendingAccount: "DEVELOPER",
105
+ * sourceArn: identity.identityArn,
106
+ * from: "My App <no-reply@mail.example.com>",
107
+ * replyToEmailAddress: "support@example.com",
108
+ * },
109
+ * });
110
+ * ```
111
+ *
80
112
  * ### Email OTP with a Custom Email Sender
81
113
  * **Example:** Passwordless Email OTP Delivered by Your Own Lambda
82
114
  * ```typescript
@@ -154,6 +186,25 @@ const toWireAccountRecovery = (mechanisms) => mechanisms === undefined
154
186
  const toWireSignInPolicy = (policy) => policy === undefined
155
187
  ? undefined
156
188
  : { AllowedFirstAuthFactors: policy.allowedFirstAuthFactors };
189
+ const toWireEmailConfiguration = (config) => config === undefined
190
+ ? undefined
191
+ : {
192
+ EmailSendingAccount: config.emailSendingAccount ?? "COGNITO_DEFAULT",
193
+ SourceArn: config.sourceArn,
194
+ From: config.from,
195
+ ReplyToEmailAddress: config.replyToEmailAddress,
196
+ ConfigurationSet: config.configurationSet,
197
+ };
198
+ /** Observed/desired email configuration with the service default filled in,
199
+ * for order- and absence-insensitive comparison (`JSON.stringify` drops the
200
+ * `undefined` members on both sides). */
201
+ const normalizedEmailConfiguration = (config) => ({
202
+ emailSendingAccount: config?.EmailSendingAccount ?? "COGNITO_DEFAULT",
203
+ sourceArn: config?.SourceArn,
204
+ from: config?.From,
205
+ replyToEmailAddress: config?.ReplyToEmailAddress,
206
+ configurationSet: config?.ConfigurationSet,
207
+ });
157
208
  const toWireCustomEmailSender = (sender) => sender === undefined
158
209
  ? undefined
159
210
  : {
@@ -173,12 +224,17 @@ const validateProps = (props) => props.customEmailSender !== undefined && props.
173
224
  ? Effect.fail(new InvalidUserPoolConfiguration({
174
225
  reason: "customEmailSender requires kmsKeyId — Cognito encrypts the codes it passes to the custom sender with that KMS key",
175
226
  }))
176
- : props.tier === "LITE" &&
177
- (props.signInPolicy?.allowedFirstAuthFactors ?? []).some((factor) => PASSWORDLESS_AUTH_FACTORS.includes(factor))
227
+ : props.emailConfiguration?.emailSendingAccount === "DEVELOPER" &&
228
+ props.emailConfiguration.sourceArn === undefined
178
229
  ? Effect.fail(new InvalidUserPoolConfiguration({
179
- reason: "passwordless first-auth factors (EMAIL_OTP / SMS_OTP / WEB_AUTHN) require the ESSENTIALS or PLUS tier, not LITE",
230
+ reason: "emailConfiguration with emailSendingAccount DEVELOPER requires sourceArn the ARN of the verified SES identity Cognito sends from",
180
231
  }))
181
- : Effect.void;
232
+ : props.tier === "LITE" &&
233
+ (props.signInPolicy?.allowedFirstAuthFactors ?? []).some((factor) => PASSWORDLESS_AUTH_FACTORS.includes(factor))
234
+ ? Effect.fail(new InvalidUserPoolConfiguration({
235
+ reason: "passwordless first-auth factors (EMAIL_OTP / SMS_OTP / WEB_AUTHN) require the ESSENTIALS or PLUS tier, not LITE",
236
+ }))
237
+ : Effect.void;
182
238
  const tagRecordOf = (tags) => Object.fromEntries(Object.entries(tags ?? {}).filter((entry) => entry[1] !== undefined));
183
239
  /**
184
240
  * The wire name an observed pool attribute would have for a declared custom
@@ -299,6 +355,12 @@ export const UserPoolProvider = () => Provider.effect(UserPool, Effect.gen(funct
299
355
  : toWireSignInPolicy(news.signInPolicy);
300
356
  return {
301
357
  LambdaConfig: lambdaConfig,
358
+ // updateUserPool resets an omitted EmailConfiguration to the
359
+ // service default — echo the OBSERVED configuration back when the
360
+ // prop is undefined so unrelated updates never clear it.
361
+ EmailConfiguration: news.emailConfiguration === undefined
362
+ ? observed.EmailConfiguration
363
+ : toWireEmailConfiguration(news.emailConfiguration),
302
364
  Policies: PasswordPolicy === undefined && SignInPolicy === undefined
303
365
  ? undefined
304
366
  : { PasswordPolicy, SignInPolicy },
@@ -389,6 +451,11 @@ export const UserPoolProvider = () => Provider.effect(UserPool, Effect.gen(funct
389
451
  (observed.MfaConfiguration ?? "OFF")) {
390
452
  return true;
391
453
  }
454
+ if (news.emailConfiguration !== undefined &&
455
+ JSON.stringify(normalizedEmailConfiguration(toWireEmailConfiguration(news.emailConfiguration))) !==
456
+ JSON.stringify(normalizedEmailConfiguration(observed.EmailConfiguration))) {
457
+ return true;
458
+ }
392
459
  if (news.adminCreateUserOnly !== undefined &&
393
460
  news.adminCreateUserOnly !==
394
461
  (observed.AdminCreateUserConfig?.AllowAdminCreateUserOnly ?? false)) {
@@ -501,6 +568,7 @@ export const UserPoolProvider = () => Provider.effect(UserPool, Effect.gen(funct
501
568
  DeletionProtection: news.deletionProtection
502
569
  ? "ACTIVE"
503
570
  : "INACTIVE",
571
+ EmailConfiguration: toWireEmailConfiguration(news.emailConfiguration),
504
572
  UsernameAttributes: news.usernameAttributes,
505
573
  AliasAttributes: news.aliasAttributes,
506
574
  AutoVerifiedAttributes: news.autoVerifiedAttributes,