@lafken/auth 0.10.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 (51) hide show
  1. package/LICENCE +21 -0
  2. package/README.md +493 -0
  3. package/lib/index.d.ts +2 -0
  4. package/lib/index.js +18 -0
  5. package/lib/main/attribute/attribute.d.ts +86 -0
  6. package/lib/main/attribute/attribute.js +109 -0
  7. package/lib/main/attribute/attribute.types.d.ts +90 -0
  8. package/lib/main/attribute/attribute.types.js +13 -0
  9. package/lib/main/attribute/index.d.ts +2 -0
  10. package/lib/main/attribute/index.js +18 -0
  11. package/lib/main/event/event.d.ts +19 -0
  12. package/lib/main/event/event.js +26 -0
  13. package/lib/main/extension/extension.d.ts +60 -0
  14. package/lib/main/extension/extension.js +74 -0
  15. package/lib/main/extension/extension.types.d.ts +37 -0
  16. package/lib/main/extension/extension.types.js +2 -0
  17. package/lib/main/extension/index.d.ts +1 -0
  18. package/lib/main/extension/index.js +2 -0
  19. package/lib/main/index.d.ts +1 -0
  20. package/lib/main/index.js +17 -0
  21. package/lib/resolver/auth/auth.d.ts +11 -0
  22. package/lib/resolver/auth/auth.js +50 -0
  23. package/lib/resolver/auth/auth.utils.d.ts +2 -0
  24. package/lib/resolver/auth/auth.utils.js +23 -0
  25. package/lib/resolver/auth/user-pool/extension/extension.d.ts +8 -0
  26. package/lib/resolver/auth/user-pool/extension/extension.js +51 -0
  27. package/lib/resolver/auth/user-pool/extension/extension.types.d.ts +6 -0
  28. package/lib/resolver/auth/user-pool/extension/extension.types.js +2 -0
  29. package/lib/resolver/auth/user-pool/external/external.d.ts +14 -0
  30. package/lib/resolver/auth/user-pool/external/external.js +14 -0
  31. package/lib/resolver/auth/user-pool/identity-provider/identity-provider.d.ts +13 -0
  32. package/lib/resolver/auth/user-pool/identity-provider/identity-provider.js +120 -0
  33. package/lib/resolver/auth/user-pool/identity-provider/identity-provider.types.d.ts +6 -0
  34. package/lib/resolver/auth/user-pool/identity-provider/identity-provider.types.js +2 -0
  35. package/lib/resolver/auth/user-pool/internal/internal.d.ts +30 -0
  36. package/lib/resolver/auth/user-pool/internal/internal.js +332 -0
  37. package/lib/resolver/auth/user-pool/user-pool.types.d.ts +263 -0
  38. package/lib/resolver/auth/user-pool/user-pool.types.js +2 -0
  39. package/lib/resolver/auth/user-pool-client/external/external.d.ts +7 -0
  40. package/lib/resolver/auth/user-pool-client/external/external.js +16 -0
  41. package/lib/resolver/auth/user-pool-client/internal/internal.d.ts +14 -0
  42. package/lib/resolver/auth/user-pool-client/internal/internal.js +115 -0
  43. package/lib/resolver/auth/user-pool-client/user-pool-client.types.d.ts +169 -0
  44. package/lib/resolver/auth/user-pool-client/user-pool-client.types.js +2 -0
  45. package/lib/resolver/index.d.ts +1 -0
  46. package/lib/resolver/index.js +17 -0
  47. package/lib/resolver/resolver.d.ts +12 -0
  48. package/lib/resolver/resolver.js +25 -0
  49. package/lib/resolver/resolver.types.d.ts +62 -0
  50. package/lib/resolver/resolver.types.js +2 -0
  51. package/package.json +87 -0
package/LICENCE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Aníbal Emilio Jorquera Cornejo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,493 @@
1
+ # @lafken/auth
2
+
3
+ Define and manage Amazon Cognito User Pools using TypeScript decorators. `@lafken/auth` lets you configure authentication flows, password policies, user attributes, MFA, identity providers, and Lambda triggers — all from a single resolver configuration.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @lafken/auth
9
+ ```
10
+
11
+ ## Getting Started
12
+
13
+ Configure `AuthResolver` with your User Pool settings, define attributes with `@Attributes`, and add Lambda triggers with `@AuthExtension`:
14
+
15
+ ```typescript
16
+ import { createApp } from '@lafken/main';
17
+ import { AuthResolver } from '@lafken/auth/resolver';
18
+ import { Attributes, Standard, Custom } from '@lafken/auth/main';
19
+ import { AuthExtension, Trigger, Event } from '@lafken/auth/main';
20
+
21
+ // 1. Define user attributes
22
+ @Attributes()
23
+ export class UserAttributes {
24
+ @Standard({ required: true })
25
+ email: string;
26
+
27
+ @Standard({ required: false })
28
+ phoneNumber: string;
29
+
30
+ @Custom({ minLen: 2, maxLen: 50 })
31
+ displayName: string;
32
+ }
33
+
34
+ // 2. Define Lambda triggers
35
+ @AuthExtension()
36
+ export class AuthTriggers {
37
+ @Trigger({ type: 'preSignUp' })
38
+ validateSignUp(@Event() event: any) {
39
+ return event;
40
+ }
41
+ }
42
+
43
+ // 3. Register in the app
44
+ createApp({
45
+ name: 'my-app',
46
+ resolvers: [
47
+ new AuthResolver({
48
+ name: 'app-auth',
49
+ userPool: {
50
+ attributes: UserAttributes,
51
+ selfSignUpEnabled: true,
52
+ signInAliases: ['email'],
53
+ passwordPolicy: {
54
+ minLength: 8,
55
+ requireUppercase: true,
56
+ requireDigits: true,
57
+ },
58
+ },
59
+ userClient: {
60
+ authFlows: ['allow_user_password_auth', 'allow_refresh_token_auth'],
61
+ },
62
+ extensions: [AuthTriggers],
63
+ }),
64
+ ],
65
+ });
66
+ ```
67
+
68
+ ## Features
69
+
70
+ ### User Pool
71
+
72
+ Configure the Cognito User Pool through the `userPool` option in `AuthResolver`:
73
+
74
+ ```typescript
75
+ new AuthResolver({
76
+ name: 'customer-auth',
77
+ userPool: {
78
+ selfSignUpEnabled: true,
79
+ signInAliases: ['email', 'phone'],
80
+ usernameAttributes: ['email'],
81
+ autoVerifyAttributes: ['email'],
82
+ signInCaseSensitive: false,
83
+ cognitoPlan: 'essentials',
84
+ },
85
+ });
86
+ ```
87
+
88
+ #### User Pool Options
89
+
90
+ | Option | Type | Description |
91
+ | ---------------------- | ------------------------ | ------------------------------------------------------------ |
92
+ | `attributes` | `ClassResource` | Class decorated with `@Attributes` defining user schema |
93
+ | `selfSignUpEnabled` | `boolean` | Allow users to sign up without admin intervention |
94
+ | `signInAliases` | `SignInAliases[]` | Identifiers for sign-in: `'email'`, `'phone'`, `'preferred_username'` |
95
+ | `usernameAttributes` | `string[]` | Attributes that can be used as the username |
96
+ | `autoVerifyAttributes` | `string[]` | Attributes to auto-verify during sign-up (`'email'`, `'phone'`) |
97
+ | `signInCaseSensitive` | `boolean` | Whether sign-in identifiers are case-sensitive |
98
+ | `cognitoPlan` | `CognitoPlan` | Pricing plan: `'lite'`, `'essentials'`, `'plus'` |
99
+ | `passwordPolicy` | `PasswordPolicy` | Password strength requirements |
100
+ | `accountRecovery` | `AccountRecovery[]` | Recovery methods: `'verified_email'`, `'verified_phone_number'`, `'admin_only'` |
101
+ | `email` | `EmailConfig` | Email sending configuration (Cognito or SES) |
102
+ | `mfa` | `Mfa` | Multi-factor authentication settings |
103
+ | `invitationMessage` | `InvitationMessage` | Custom message for admin-created users |
104
+ | `userVerification` | `UserVerification` | Verification message and method configuration |
105
+ | `identityProviders` | `IdentityProvider[]` | External identity providers (Google, Facebook, etc.) |
106
+
107
+ ### Password Policy
108
+
109
+ Control password strength requirements:
110
+
111
+ ```typescript
112
+ userPool: {
113
+ passwordPolicy: {
114
+ minLength: 12,
115
+ requireUppercase: true,
116
+ requireLowercase: true,
117
+ requireDigits: true,
118
+ requireSymbols: true,
119
+ validityDays: 90,
120
+ },
121
+ }
122
+ ```
123
+
124
+ | Option | Type | Description |
125
+ | ------------------ | --------- | ---------------------------------------------- |
126
+ | `minLength` | `number` | Minimum password length |
127
+ | `requireUppercase` | `boolean` | Require at least one uppercase letter |
128
+ | `requireLowercase` | `boolean` | Require at least one lowercase letter |
129
+ | `requireDigits` | `boolean` | Require at least one digit |
130
+ | `requireSymbols` | `boolean` | Require at least one special character |
131
+ | `validityDays` | `number` | Number of days before password expires |
132
+
133
+ ### User Attributes
134
+
135
+ Define the User Pool schema using a class decorated with `@Attributes`. Properties use `@Standard` for built-in Cognito attributes and `@Custom` for application-specific fields:
136
+
137
+ ```typescript
138
+ import { Attributes, Standard, Custom } from '@lafken/auth/main';
139
+
140
+ @Attributes()
141
+ export class UserAttributes {
142
+ @Standard({ required: true })
143
+ email: string;
144
+
145
+ @Standard({ required: false, mutable: true })
146
+ nickname: string;
147
+
148
+ @Custom({ minLen: 2, maxLen: 100 })
149
+ displayName: string;
150
+
151
+ @Custom({ min: 0, max: 999 })
152
+ score: number;
153
+
154
+ @Custom({ mutable: false })
155
+ isVerified: boolean;
156
+ }
157
+ ```
158
+
159
+ #### Standard Attributes
160
+
161
+ Predefined Cognito attributes following the OpenID Connect specification. Supported names:
162
+
163
+ `name`, `familyName`, `givenName`, `middleName`, `nickname`, `preferredUsername`, `profile`, `picture`, `website`, `gender`, `birthdate`, `zoneInfo`, `locale`, `updated_at`, `address`, `email`, `phoneNumber`, `sub`
164
+
165
+ | Option | Type | Default | Description |
166
+ | ---------- | --------- | ------- | ------------------------------------------------ |
167
+ | `required` | `boolean` | `true` | Whether the attribute is required during sign-up |
168
+ | `mutable` | `boolean` | `true` | Whether the value can be changed after creation |
169
+
170
+ #### Custom Attributes
171
+
172
+ Application-specific fields with type-aware constraints:
173
+
174
+ | Type | Options | Description |
175
+ | --------- | ---------------------- | ------------------------------------- |
176
+ | `string` | `minLen`, `maxLen` | String length constraints |
177
+ | `number` | `min`, `max` | Numeric range constraints |
178
+ | `boolean` | `mutable` | Mutability only |
179
+
180
+ All custom attributes default to `mutable: true`.
181
+
182
+ ### MFA (Multi-Factor Authentication)
183
+
184
+ Configure MFA for the User Pool:
185
+
186
+ ```typescript
187
+ userPool: {
188
+ mfa: {
189
+ status: 'required',
190
+ email: {
191
+ subject: 'Your verification code',
192
+ body: 'Your code is {####}',
193
+ },
194
+ sms: 'Your verification code is {####}',
195
+ opt: true,
196
+ },
197
+ }
198
+ ```
199
+
200
+ | Option | Type | Description |
201
+ | -------- | ------------------------------- | --------------------------------------------------- |
202
+ | `status` | `'off' \| 'optional' \| 'required'` | MFA enforcement level |
203
+ | `email` | `{ subject, body }` | Email-based MFA message template |
204
+ | `sms` | `string` | SMS-based MFA message template |
205
+ | `opt` | `boolean` | Enable TOTP (authenticator app) as an MFA option |
206
+
207
+ ### Email Configuration
208
+
209
+ Configure how Cognito sends verification and notification emails:
210
+
211
+ ```typescript
212
+ // Using the default Cognito email service
213
+ userPool: {
214
+ email: {
215
+ from: 'noreply@example.com',
216
+ reply: 'support@example.com',
217
+ },
218
+ }
219
+
220
+ // Using Amazon SES
221
+ userPool: {
222
+ email: {
223
+ account: 'ses',
224
+ arn: 'arn:aws:ses:us-east-1:123456789:identity/example.com',
225
+ from: 'auth@example.com',
226
+ configurationSet: 'my-ses-config',
227
+ },
228
+ }
229
+ ```
230
+
231
+ ### Verification & Invitation Messages
232
+
233
+ Customize messages sent during user verification and admin-created user invitations:
234
+
235
+ ```typescript
236
+ userPool: {
237
+ userVerification: {
238
+ email: {
239
+ subject: 'Verify your account',
240
+ body: 'Click this link to verify: {##Verify##}',
241
+ type: 'link',
242
+ },
243
+ sms: 'Your verification code is {####}',
244
+ },
245
+ invitationMessage: {
246
+ email: {
247
+ subject: 'Welcome to our platform',
248
+ body: 'Your username is {username} and temporary password is {####}',
249
+ },
250
+ sms: 'Your username is {username} and password is {####}',
251
+ },
252
+ }
253
+ ```
254
+
255
+ ### Identity Providers
256
+
257
+ Configure external identity providers so users can sign in with third-party accounts:
258
+
259
+ #### Google
260
+
261
+ ```typescript
262
+ userPool: {
263
+ identityProviders: [
264
+ {
265
+ type: 'google',
266
+ clientId: 'google-client-id',
267
+ clientSecret: 'google-client-secret',
268
+ scopes: ['openid', 'email', 'profile'],
269
+ attributes: {
270
+ email: 'email',
271
+ displayName: 'name',
272
+ },
273
+ },
274
+ ],
275
+ }
276
+ ```
277
+
278
+ #### Facebook
279
+
280
+ ```typescript
281
+ {
282
+ type: 'facebook',
283
+ clientId: 'fb-app-id',
284
+ clientSecret: 'fb-app-secret',
285
+ scopes: ['public_profile', 'email'],
286
+ apiVersion: 'v18.0',
287
+ attributes: {
288
+ email: 'email',
289
+ displayName: 'name',
290
+ },
291
+ }
292
+ ```
293
+
294
+ #### Apple
295
+
296
+ ```typescript
297
+ {
298
+ type: 'apple',
299
+ clientId: 'apple-service-id',
300
+ scopes: ['email', 'name'],
301
+ keyId: 'key-id',
302
+ teamId: 'team-id',
303
+ privateKeyValue: '-----BEGIN PRIVATE KEY-----...',
304
+ attributes: {
305
+ email: 'email',
306
+ displayName: 'first_name',
307
+ },
308
+ }
309
+ ```
310
+
311
+ #### Amazon
312
+
313
+ ```typescript
314
+ {
315
+ type: 'amazon',
316
+ clientId: 'amazon-client-id',
317
+ clientSecret: 'amazon-client-secret',
318
+ scopes: ['profile'],
319
+ attributes: {
320
+ email: 'email',
321
+ displayName: 'name',
322
+ },
323
+ }
324
+ ```
325
+
326
+ #### OIDC (OpenID Connect)
327
+
328
+ ```typescript
329
+ {
330
+ type: 'oidc',
331
+ name: 'my-oidc-provider',
332
+ clientId: 'oidc-client-id',
333
+ clientSecret: 'oidc-client-secret',
334
+ scopes: ['openid', 'email'],
335
+ attributesRequestMethod: 'GET',
336
+ authorizeUrl: 'https://provider.com/authorize',
337
+ tokenUrl: 'https://provider.com/token',
338
+ attributesUrl: 'https://provider.com/userinfo',
339
+ jwksUri: 'https://provider.com/.well-known/jwks.json',
340
+ attributes: {
341
+ email: 'email',
342
+ },
343
+ }
344
+ ```
345
+
346
+ Attribute mappings map your `@Attributes` class properties to the provider's attribute names.
347
+
348
+ ### User Pool Client
349
+
350
+ Configure the Cognito User Pool Client through the `userClient` option:
351
+
352
+ ```typescript
353
+ new AuthResolver({
354
+ name: 'app-auth',
355
+ userClient: {
356
+ authFlows: ['allow_user_password_auth', 'allow_refresh_token_auth'],
357
+ generateSecret: false,
358
+ preventUserExistenceErrors: true,
359
+ enableTokenRevocation: true,
360
+ validity: {
361
+ accessToken: { type: 'hours', value: 1 },
362
+ idToken: { type: 'hours', value: 1 },
363
+ refreshToken: { type: 'days', value: 30 },
364
+ authSession: 300,
365
+ },
366
+ readAttributes: ['email', 'displayName'],
367
+ writeAttributes: ['displayName', 'nickname'],
368
+ },
369
+ });
370
+ ```
371
+
372
+ #### Auth Flows
373
+
374
+ | Flow | Description |
375
+ | ------------------------------- | -------------------------------------------- |
376
+ | `allow_user_password_auth` | Username and password authentication |
377
+ | `allow_user_srp_auth` | Secure Remote Password authentication |
378
+ | `allow_admin_user_password_auth`| Admin-initiated password authentication |
379
+ | `allow_custom_auth` | Custom authentication flow |
380
+ | `allow_refresh_token_auth` | Token refresh flow |
381
+ | `allow_user_auth` | General user authentication |
382
+
383
+ #### OAuth Configuration
384
+
385
+ ```typescript
386
+ userClient: {
387
+ oauth: {
388
+ flows: ['code'],
389
+ scopes: ['openid', 'email', 'profile'],
390
+ callbackUrls: ['https://app.example.com/callback'],
391
+ logoutUrls: ['https://app.example.com/logout'],
392
+ defaultRedirectUri: 'https://app.example.com/callback',
393
+ },
394
+ }
395
+ ```
396
+
397
+ | Option | Type | Description |
398
+ | -------------------- | -------------- | ---------------------------------------- |
399
+ | `flows` | `OAuthFlow[]` | `'code'`, `'implicit'`, `'client_credentials'` |
400
+ | `scopes` | `string[]` | OAuth scopes (e.g. `'openid'`, `'email'`, `'profile'`) |
401
+ | `callbackUrls` | `string[]` | Allowed redirect URLs after sign-in |
402
+ | `logoutUrls` | `string[]` | Allowed redirect URLs after sign-out |
403
+ | `defaultRedirectUri` | `string` | Default redirect URL |
404
+
405
+ #### Token Validity
406
+
407
+ ```typescript
408
+ validity: {
409
+ authSession: 300,
410
+ accessToken: { type: 'minutes', value: 60 },
411
+ idToken: { type: 'minutes', value: 60 },
412
+ refreshToken: { type: 'days', value: 30 },
413
+ }
414
+ ```
415
+
416
+ `accessToken`, `idToken`, and `refreshToken` accept either a number (in minutes) or a `ValidityUnit` object with `type` (`'seconds'`, `'minutes'`, `'hours'`, `'days'`) and `value`.
417
+
418
+ ### Extensions (Lambda Triggers)
419
+
420
+ Extend Cognito behavior with Lambda triggers. Define an extension class with `@AuthExtension` and add `@Trigger` methods for each lifecycle event:
421
+
422
+ ```typescript
423
+ import { AuthExtension, Trigger, Event } from '@lafken/auth/main';
424
+
425
+ @AuthExtension()
426
+ export class AuthTriggers {
427
+ @Trigger({ type: 'preSignUp' })
428
+ validateSignUp(@Event() event: any) {
429
+ // Auto-confirm or reject users
430
+ event.response.autoConfirmUser = true;
431
+ return event;
432
+ }
433
+
434
+ @Trigger({ type: 'postConfirmation' })
435
+ onConfirmed(@Event() event: any) {
436
+ // Create user profile in database
437
+ return event;
438
+ }
439
+
440
+ @Trigger({ type: 'customMessage' })
441
+ customizeMessage(@Event() event: any) {
442
+ // Customize verification emails
443
+ return event;
444
+ }
445
+ }
446
+ ```
447
+
448
+ Register extensions in the resolver:
449
+
450
+ ```typescript
451
+ new AuthResolver({
452
+ name: 'app-auth',
453
+ extensions: [AuthTriggers],
454
+ });
455
+ ```
456
+
457
+ #### Available Trigger Types
458
+
459
+ | Trigger | Description |
460
+ | ------------------------------ | --------------------------------------------------- |
461
+ | `preSignUp` | Validate or modify sign-up data before registration |
462
+ | `preAuthentication` | Run logic before authentication completes |
463
+ | `preTokenGeneration` | Customize token claims before token issuance |
464
+ | `preTokenGenerationConfig` | Configure token generation settings |
465
+ | `postAuthentication` | Run logic after successful authentication |
466
+ | `postConfirmation` | Run logic after user account confirmation |
467
+ | `userMigration` | Migrate users from an external system on sign-in |
468
+ | `createAuthChallenge` | Create a custom authentication challenge |
469
+ | `defineAuthChallenge` | Define the flow of custom authentication challenges |
470
+ | `verifyAuthChallengeResponse` | Verify the response to a custom challenge |
471
+ | `customMessage` | Customize verification and MFA messages |
472
+ | `customEmailSender` | Custom email delivery logic |
473
+ | `customSmsSender` | Custom SMS delivery logic |
474
+
475
+ Each trigger method can accept a `lambda` option for custom Lambda settings:
476
+
477
+ ```typescript
478
+ @Trigger({ type: 'preSignUp', lambda: { memory: 512, timeout: 30 } })
479
+ validateSignUp(@Event() event: any) { }
480
+ ```
481
+
482
+ ### Extending the Auth Stack
483
+
484
+ Use the `extend` callback to access underlying CDKTN resources and apply advanced configuration:
485
+
486
+ ```typescript
487
+ new AuthResolver({
488
+ name: 'app-auth',
489
+ extend: ({ userPool, userPoolClient, scope }) => {
490
+ // Add custom domains, resource servers, or any CDKTN construct
491
+ },
492
+ });
493
+ ```
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './main';
2
+ export * from './resolver/resolver';
package/lib/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./main"), exports);
18
+ __exportStar(require("./resolver/resolver"), exports);
@@ -0,0 +1,86 @@
1
+ import 'reflect-metadata';
2
+ import type { AuthAttributes, CommonStandardAttribute, CustomAttributeProps } from './attribute.types';
3
+ export declare const authFieldKey: string;
4
+ export declare const authPayloadKey: string;
5
+ /**
6
+ * Class decorator that declares a class as a Cognito User Pool
7
+ * attributes definition.
8
+ *
9
+ * The decorated class groups standard and custom attributes that will
10
+ * be configured on the Cognito User Pool. Use `@Standard` and `@Custom`
11
+ * on its properties to describe each attribute.
12
+ *
13
+ * @param props - Optional payload configuration (e.g. a custom `name`).
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * @Attributes()
18
+ * export class UserAttributes {
19
+ * @Standard({ required: true })
20
+ * email: string;
21
+ *
22
+ * @Custom({ minLen: 2, maxLen: 50 })
23
+ * displayName: string;
24
+ * }
25
+ * ```
26
+ */
27
+ export declare const Attributes: (props?: import("@lafken/common").PayloadProps | undefined) => (target: Function) => void;
28
+ /**
29
+ * Property decorator that registers a custom attribute on the Cognito
30
+ * User Pool.
31
+ *
32
+ * Custom attributes are user-defined fields that extend the default
33
+ * Cognito schema. The decorator options are resolved based on the
34
+ * property type: string fields accept `minLen` / `maxLen`, number fields
35
+ * accept `min` / `max`, and all types support `mutable`.
36
+ *
37
+ * @typeParam T - The class type that owns the decorated property.
38
+ * @typeParam A - The property key being decorated.
39
+ * @param props - Optional type-specific constraints for the attribute.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * @Attributes()
44
+ * export class UserAttributes {
45
+ * @Custom({ minLen: 2, maxLen: 100 })
46
+ * displayName: string;
47
+ *
48
+ * @Custom({ min: 0, max: 200 })
49
+ * score: number;
50
+ *
51
+ * @Custom({ mutable: false })
52
+ * isVerified: boolean;
53
+ * }
54
+ * ```
55
+ */
56
+ export declare const Custom: <T extends Record<A, number | string | boolean | Date>, A extends keyof T>(props?: CustomAttributeProps<T[A]>) => (target: T, propertyName: A) => void;
57
+ /**
58
+ * Property decorator that marks a field as a standard Cognito User Pool
59
+ * attribute.
60
+ *
61
+ * Standard attributes are predefined by Cognito and follow the OpenID
62
+ * Connect specification. The property name must match one of the
63
+ * supported attribute keys:
64
+ *
65
+ * `name`, `familyName`, `givenName`, `middleName`, `nickname`,
66
+ * `preferredUsername`, `profile`, `picture`, `website`, `gender`,
67
+ * `birthdate`, `zoneInfo`, `locale`, `updated_at`, `address`,
68
+ * `email`, `phoneNumber`, `sub`.
69
+ *
70
+ * @param props - Optional settings for the attribute.
71
+ * @param props.required - Whether the attribute is required during sign-up. Defaults to `true`.
72
+ * @param props.mutable - Whether the attribute value can be changed after creation. Defaults to `true`.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * @Attributes()
77
+ * export class UserAttributes {
78
+ * @Standard({ required: true })
79
+ * email: string;
80
+ *
81
+ * @Standard({ required: false, mutable: true })
82
+ * nickname: string;
83
+ * }
84
+ * ```
85
+ */
86
+ export declare const Standard: (props?: CommonStandardAttribute) => (target: any, propertyKey: keyof AuthAttributes) => void;