@venturekit/auth 0.0.0-dev.20260307234057

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 (46) hide show
  1. package/LICENSE +191 -0
  2. package/dist/cognito/config.d.ts +29 -0
  3. package/dist/cognito/config.d.ts.map +1 -0
  4. package/dist/cognito/config.js +74 -0
  5. package/dist/cognito/config.js.map +1 -0
  6. package/dist/cognito/index.d.ts +9 -0
  7. package/dist/cognito/index.d.ts.map +1 -0
  8. package/dist/cognito/index.js +8 -0
  9. package/dist/cognito/index.js.map +1 -0
  10. package/dist/cognito/user-pool.d.ts +81 -0
  11. package/dist/cognito/user-pool.d.ts.map +1 -0
  12. package/dist/cognito/user-pool.js +70 -0
  13. package/dist/cognito/user-pool.js.map +1 -0
  14. package/dist/index.d.ts +11 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +14 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/roles/index.d.ts +27 -0
  19. package/dist/roles/index.d.ts.map +1 -0
  20. package/dist/roles/index.js +58 -0
  21. package/dist/roles/index.js.map +1 -0
  22. package/dist/session/index.d.ts +33 -0
  23. package/dist/session/index.d.ts.map +1 -0
  24. package/dist/session/index.js +126 -0
  25. package/dist/session/index.js.map +1 -0
  26. package/dist/types/config.d.ts +95 -0
  27. package/dist/types/config.d.ts.map +1 -0
  28. package/dist/types/config.js +5 -0
  29. package/dist/types/config.js.map +1 -0
  30. package/dist/types/index.d.ts +10 -0
  31. package/dist/types/index.d.ts.map +1 -0
  32. package/dist/types/index.js +10 -0
  33. package/dist/types/index.js.map +1 -0
  34. package/dist/types/role.d.ts +34 -0
  35. package/dist/types/role.d.ts.map +1 -0
  36. package/dist/types/role.js +5 -0
  37. package/dist/types/role.js.map +1 -0
  38. package/dist/types/session.d.ts +72 -0
  39. package/dist/types/session.d.ts.map +1 -0
  40. package/dist/types/session.js +5 -0
  41. package/dist/types/session.js.map +1 -0
  42. package/dist/types/user.d.ts +83 -0
  43. package/dist/types/user.d.ts.map +1 -0
  44. package/dist/types/user.js +5 -0
  45. package/dist/types/user.js.map +1 -0
  46. package/package.json +39 -0
package/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2025 VentureKit Contributors
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Cognito Configuration
3
+ */
4
+ import type { CognitoConfig, PasswordPolicy, MfaConfig, TokenConfig } from '../types';
5
+ /**
6
+ * Default password policy
7
+ */
8
+ export declare const DEFAULT_PASSWORD_POLICY: PasswordPolicy;
9
+ /**
10
+ * Default MFA configuration
11
+ */
12
+ export declare const DEFAULT_MFA_CONFIG: MfaConfig;
13
+ /**
14
+ * Default token configuration
15
+ */
16
+ export declare const DEFAULT_TOKEN_CONFIG: TokenConfig;
17
+ /**
18
+ * Default Cognito configuration
19
+ */
20
+ export declare const DEFAULT_COGNITO_CONFIG: CognitoConfig;
21
+ /**
22
+ * Create Cognito configuration from partial input
23
+ */
24
+ export declare function createCognitoConfig(input?: Partial<CognitoConfig> & {
25
+ passwordPolicy?: Partial<PasswordPolicy>;
26
+ mfa?: Partial<MfaConfig>;
27
+ tokens?: Partial<TokenConfig>;
28
+ }): CognitoConfig;
29
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/cognito/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEtF;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAOrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAGhC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAIlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAapC,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACzC,GAAG,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC/B,GACA,aAAa,CAuBf"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Cognito Configuration
3
+ */
4
+ /**
5
+ * Default password policy
6
+ */
7
+ export const DEFAULT_PASSWORD_POLICY = {
8
+ minLength: 8,
9
+ requireLowercase: true,
10
+ requireUppercase: true,
11
+ requireNumbers: true,
12
+ requireSymbols: false,
13
+ tempPasswordValidityDays: 7,
14
+ };
15
+ /**
16
+ * Default MFA configuration
17
+ */
18
+ export const DEFAULT_MFA_CONFIG = {
19
+ mode: 'optional',
20
+ methods: ['totp'],
21
+ };
22
+ /**
23
+ * Default token configuration
24
+ */
25
+ export const DEFAULT_TOKEN_CONFIG = {
26
+ accessTokenValidityMinutes: 60,
27
+ idTokenValidityMinutes: 60,
28
+ refreshTokenValidityDays: 30,
29
+ };
30
+ /**
31
+ * Default Cognito configuration
32
+ */
33
+ export const DEFAULT_COGNITO_CONFIG = {
34
+ signInAliases: {
35
+ email: true,
36
+ phone: false,
37
+ username: false,
38
+ },
39
+ selfSignUpEnabled: true,
40
+ autoVerifyEmail: true,
41
+ autoVerifyPhone: false,
42
+ passwordPolicy: DEFAULT_PASSWORD_POLICY,
43
+ mfa: DEFAULT_MFA_CONFIG,
44
+ tokens: DEFAULT_TOKEN_CONFIG,
45
+ accountRecovery: 'email',
46
+ };
47
+ /**
48
+ * Create Cognito configuration from partial input
49
+ */
50
+ export function createCognitoConfig(input) {
51
+ if (!input)
52
+ return DEFAULT_COGNITO_CONFIG;
53
+ return {
54
+ ...DEFAULT_COGNITO_CONFIG,
55
+ ...input,
56
+ signInAliases: {
57
+ ...DEFAULT_COGNITO_CONFIG.signInAliases,
58
+ ...input.signInAliases,
59
+ },
60
+ passwordPolicy: {
61
+ ...DEFAULT_PASSWORD_POLICY,
62
+ ...input.passwordPolicy,
63
+ },
64
+ mfa: {
65
+ ...DEFAULT_MFA_CONFIG,
66
+ ...input.mfa,
67
+ },
68
+ tokens: {
69
+ ...DEFAULT_TOKEN_CONFIG,
70
+ ...input.tokens,
71
+ },
72
+ };
73
+ }
74
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/cognito/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAmB;IACrD,SAAS,EAAE,CAAC;IACZ,gBAAgB,EAAE,IAAI;IACtB,gBAAgB,EAAE,IAAI;IACtB,cAAc,EAAE,IAAI;IACpB,cAAc,EAAE,KAAK;IACrB,wBAAwB,EAAE,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAc;IAC3C,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,CAAC,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgB;IAC/C,0BAA0B,EAAE,EAAE;IAC9B,sBAAsB,EAAE,EAAE;IAC1B,wBAAwB,EAAE,EAAE;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAkB;IACnD,aAAa,EAAE;QACb,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,KAAK;KAChB;IACD,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,IAAI;IACrB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,uBAAuB;IACvC,GAAG,EAAE,kBAAkB;IACvB,MAAM,EAAE,oBAAoB;IAC5B,eAAe,EAAE,OAAO;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAIC;IAED,IAAI,CAAC,KAAK;QAAE,OAAO,sBAAsB,CAAC;IAE1C,OAAO;QACL,GAAG,sBAAsB;QACzB,GAAG,KAAK;QACR,aAAa,EAAE;YACb,GAAG,sBAAsB,CAAC,aAAa;YACvC,GAAG,KAAK,CAAC,aAAa;SACvB;QACD,cAAc,EAAE;YACd,GAAG,uBAAuB;YAC1B,GAAG,KAAK,CAAC,cAAc;SACxB;QACD,GAAG,EAAE;YACH,GAAG,kBAAkB;YACrB,GAAG,KAAK,CAAC,GAAG;SACb;QACD,MAAM,EAAE;YACN,GAAG,oBAAoB;YACvB,GAAG,KAAK,CAAC,MAAM;SAChB;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Cognito Construct
3
+ *
4
+ * Creates and configures AWS Cognito User Pool for VentureKit.
5
+ */
6
+ export { createCognitoConfig, DEFAULT_COGNITO_CONFIG } from './config';
7
+ export { buildUserPoolConfig } from './user-pool';
8
+ export type { UserPoolOutputs, UserPoolInfraConfig } from './user-pool';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cognito/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Cognito Construct
3
+ *
4
+ * Creates and configures AWS Cognito User Pool for VentureKit.
5
+ */
6
+ export { createCognitoConfig, DEFAULT_COGNITO_CONFIG } from './config';
7
+ export { buildUserPoolConfig } from './user-pool';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cognito/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Cognito User Pool Configuration Builder
3
+ *
4
+ * @deprecated Use intent-based infrastructure instead:
5
+ * ```typescript
6
+ * defineVenture({
7
+ * infrastructure: {
8
+ * auth: [{ id: 'main', signInWith: ['email'], allowSignUp: true }]
9
+ * }
10
+ * })
11
+ * ```
12
+ *
13
+ * This file is kept for backward compatibility.
14
+ * New projects should use the intent-based API in @venturekit/infra.
15
+ */
16
+ import type { CognitoConfig } from '../types';
17
+ /**
18
+ * User Pool outputs
19
+ */
20
+ export interface UserPoolOutputs {
21
+ userPoolId: string;
22
+ userPoolArn: string;
23
+ userPoolClientId: string;
24
+ userPoolDomain?: string;
25
+ }
26
+ /**
27
+ * User Pool configuration for infrastructure layer
28
+ */
29
+ export interface UserPoolInfraConfig {
30
+ name: string;
31
+ signInAliases: {
32
+ email: boolean;
33
+ phone: boolean;
34
+ preferredUsername: boolean;
35
+ };
36
+ selfSignUpEnabled: boolean;
37
+ autoVerify: {
38
+ email: boolean;
39
+ phone: boolean;
40
+ };
41
+ passwordPolicy: {
42
+ minLength: number;
43
+ requireLowercase: boolean;
44
+ requireUppercase: boolean;
45
+ requireDigits: boolean;
46
+ requireSymbols: boolean;
47
+ tempPasswordValidity: {
48
+ days: number;
49
+ };
50
+ };
51
+ mfa: 'on' | 'optional' | 'off';
52
+ mfaSecondFactor: {
53
+ sms: boolean;
54
+ otp: boolean;
55
+ };
56
+ accountRecovery: string;
57
+ customAttributes?: Record<string, {
58
+ dataType: string;
59
+ mutable: boolean;
60
+ }>;
61
+ tokens: {
62
+ accessTokenValidityMinutes: number;
63
+ idTokenValidityMinutes: number;
64
+ refreshTokenValidityDays: number;
65
+ };
66
+ appClients: Array<{
67
+ name: string;
68
+ allowedScopes: string[];
69
+ }>;
70
+ }
71
+ /**
72
+ * Build Cognito User Pool configuration for infrastructure layer
73
+ *
74
+ * This returns a configuration object that @venturekit/infra uses
75
+ * to create the actual Cognito resources via SST.
76
+ */
77
+ export declare function buildUserPoolConfig(name: string, config: CognitoConfig, appClients: Array<{
78
+ name: string;
79
+ allowedScopes: string[];
80
+ }>): UserPoolInfraConfig;
81
+ //# sourceMappingURL=user-pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-pool.d.ts","sourceRoot":"","sources":["../../src/cognito/user-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE;QACb,KAAK,EAAE,OAAO,CAAC;QACf,KAAK,EAAE,OAAO,CAAC;QACf,iBAAiB,EAAE,OAAO,CAAC;KAC5B,CAAC;IACF,iBAAiB,EAAE,OAAO,CAAC;IAC3B,UAAU,EAAE;QACV,KAAK,EAAE,OAAO,CAAC;QACf,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,cAAc,EAAE;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,gBAAgB,EAAE,OAAO,CAAC;QAC1B,aAAa,EAAE,OAAO,CAAC;QACvB,cAAc,EAAE,OAAO,CAAC;QACxB,oBAAoB,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;KACxC,CAAC;IACF,GAAG,EAAE,IAAI,GAAG,UAAU,GAAG,KAAK,CAAC;IAC/B,eAAe,EAAE;QACf,GAAG,EAAE,OAAO,CAAC;QACb,GAAG,EAAE,OAAO,CAAC;KACd,CAAC;IACF,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC1E,MAAM,EAAE;QACN,0BAA0B,EAAE,MAAM,CAAC;QACnC,sBAAsB,EAAE,MAAM,CAAC;QAC/B,wBAAwB,EAAE,MAAM,CAAC;KAClC,CAAC;IACF,UAAU,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;CAC9D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,GAC3D,mBAAmB,CA+CrB"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Cognito User Pool Configuration Builder
3
+ *
4
+ * @deprecated Use intent-based infrastructure instead:
5
+ * ```typescript
6
+ * defineVenture({
7
+ * infrastructure: {
8
+ * auth: [{ id: 'main', signInWith: ['email'], allowSignUp: true }]
9
+ * }
10
+ * })
11
+ * ```
12
+ *
13
+ * This file is kept for backward compatibility.
14
+ * New projects should use the intent-based API in @venturekit/infra.
15
+ */
16
+ /**
17
+ * Build Cognito User Pool configuration for infrastructure layer
18
+ *
19
+ * This returns a configuration object that @venturekit/infra uses
20
+ * to create the actual Cognito resources via SST.
21
+ */
22
+ export function buildUserPoolConfig(name, config, appClients) {
23
+ return {
24
+ name: `${name}-users`,
25
+ signInAliases: {
26
+ email: config.signInAliases.email,
27
+ phone: config.signInAliases.phone,
28
+ preferredUsername: config.signInAliases.username,
29
+ },
30
+ selfSignUpEnabled: config.selfSignUpEnabled,
31
+ autoVerify: {
32
+ email: config.autoVerifyEmail,
33
+ phone: config.autoVerifyPhone,
34
+ },
35
+ passwordPolicy: {
36
+ minLength: config.passwordPolicy.minLength,
37
+ requireLowercase: config.passwordPolicy.requireLowercase,
38
+ requireUppercase: config.passwordPolicy.requireUppercase,
39
+ requireDigits: config.passwordPolicy.requireNumbers,
40
+ requireSymbols: config.passwordPolicy.requireSymbols,
41
+ tempPasswordValidity: {
42
+ days: config.passwordPolicy.tempPasswordValidityDays,
43
+ },
44
+ },
45
+ mfa: config.mfa.mode === 'required' ? 'on' : config.mfa.mode === 'optional' ? 'optional' : 'off',
46
+ mfaSecondFactor: {
47
+ sms: config.mfa.methods.includes('sms'),
48
+ otp: config.mfa.methods.includes('totp'),
49
+ },
50
+ accountRecovery: config.accountRecovery === 'both'
51
+ ? 'EMAIL_AND_PHONE_WITHOUT_MFA'
52
+ : config.accountRecovery === 'phone'
53
+ ? 'PHONE_ONLY_WITHOUT_MFA'
54
+ : 'EMAIL_ONLY',
55
+ customAttributes: config.customAttributes?.reduce((acc, attr) => {
56
+ acc[attr.name] = {
57
+ dataType: attr.type === 'number' ? 'Number' : attr.type === 'boolean' ? 'Boolean' : 'String',
58
+ mutable: attr.mutable,
59
+ };
60
+ return acc;
61
+ }, {}),
62
+ tokens: {
63
+ accessTokenValidityMinutes: config.tokens.accessTokenValidityMinutes,
64
+ idTokenValidityMinutes: config.tokens.idTokenValidityMinutes,
65
+ refreshTokenValidityDays: config.tokens.refreshTokenValidityDays,
66
+ },
67
+ appClients,
68
+ };
69
+ }
70
+ //# sourceMappingURL=user-pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-pool.js","sourceRoot":"","sources":["../../src/cognito/user-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAoDH;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAY,EACZ,MAAqB,EACrB,UAA4D;IAE5D,OAAO;QACL,IAAI,EAAE,GAAG,IAAI,QAAQ;QACrB,aAAa,EAAE;YACb,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,KAAK;YACjC,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,KAAK;YACjC,iBAAiB,EA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AQ,EAAE,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ;gBAC5F,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB,CAAC;YACF,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAA4D,CAAC;QAChE,MAAM,EAAE;YACN,0BAA0B,EAAE,MAAM,CAAC,MAAM,CAAC,0BAA0B;YACpE,sBAAsB,EAAE,MAAM,CAAC,MAAM,CAAC,sBAAsB;YAC5D,wBAAwB,EAAE,MAAM,CAAC,MAAM,CAAC,wBAAwB;SACjE;QACD,UAAU;KACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @venturekit/auth
3
+ *
4
+ * Authentication and authorization for VentureKit.
5
+ */
6
+ export * from './types';
7
+ export { createCognitoConfig, DEFAULT_COGNITO_CONFIG, buildUserPoolConfig, } from './cognito';
8
+ export type { UserPoolOutputs, UserPoolInfraConfig } from './cognito/user-pool';
9
+ export { hasScope, hasAnyScope, hasAllScopes, getScopesForRoles, validateRolesConfig, } from './roles';
10
+ export { decodeToken, extractUserFromToken, isTokenExpired, getTokenExpiry, } from './session';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,SAAS,CAAC;AAGxB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAGhF,OAAO,EACL,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,cAAc,GACf,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @venturekit/auth
3
+ *
4
+ * Authentication and authorization for VentureKit.
5
+ */
6
+ // Types
7
+ export * from './types';
8
+ // Cognito
9
+ export { createCognitoConfig, DEFAULT_COGNITO_CONFIG, buildUserPoolConfig, } from './cognito';
10
+ // Roles
11
+ export { hasScope, hasAnyScope, hasAllScopes, getScopesForRoles, validateRolesConfig, } from './roles';
12
+ // Session
13
+ export { decodeToken, extractUserFromToken, isTokenExpired, getTokenExpiry, } from './session';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,QAAQ;AACR,cAAc,SAAS,CAAC;AAExB,UAAU;AACV,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AAGnB,QAAQ;AACR,OAAO,EACL,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAEjB,UAAU;AACV,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,cAAc,GACf,MAAM,WAAW,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Roles
3
+ *
4
+ * Utilities for managing roles and scopes.
5
+ */
6
+ import type { RolesConfig } from '../types';
7
+ /**
8
+ * Check if user roles grant a specific scope
9
+ */
10
+ export declare function hasScope(userRoles: string[], scope: string, config: RolesConfig): boolean;
11
+ /**
12
+ * Check if user roles grant any of the specified scopes
13
+ */
14
+ export declare function hasAnyScope(userRoles: string[], scopes: string[], config: RolesConfig): boolean;
15
+ /**
16
+ * Check if user roles grant all of the specified scopes
17
+ */
18
+ export declare function hasAllScopes(userRoles: string[], scopes: string[], config: RolesConfig): boolean;
19
+ /**
20
+ * Get all scopes granted by a set of roles
21
+ */
22
+ export declare function getScopesForRoles(roleNames: string[], config: RolesConfig): string[];
23
+ /**
24
+ * Validate roles configuration
25
+ */
26
+ export declare function validateRolesConfig(config: RolesConfig): string[];
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/roles/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAQ,WAAW,EAAE,MAAM,UAAU,CAAC;AAElD;;GAEG;AACH,wBAAgB,QAAQ,CACtB,SAAS,EAAE,MAAM,EAAE,EACnB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,WAAW,GAClB,OAAO,CAQT;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,MAAM,EAAE,EACnB,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,EAAE,WAAW,GAClB,OAAO,CAET;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EAAE,EACnB,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,EAAE,WAAW,GAClB,OAAO,CAET;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EAAE,EACnB,MAAM,EAAE,WAAW,GAClB,MAAM,EAAE,CAWV;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE,CAejE"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Roles
3
+ *
4
+ * Utilities for managing roles and scopes.
5
+ */
6
+ /**
7
+ * Check if user roles grant a specific scope
8
+ */
9
+ export function hasScope(userRoles, scope, config) {
10
+ // Super admin has all scopes
11
+ if (config.superAdminRole && userRoles.includes(config.superAdminRole)) {
12
+ return true;
13
+ }
14
+ const userScopes = getScopesForRoles(userRoles, config);
15
+ return userScopes.includes(scope);
16
+ }
17
+ /**
18
+ * Check if user roles grant any of the specified scopes
19
+ */
20
+ export function hasAnyScope(userRoles, scopes, config) {
21
+ return scopes.some(s => hasScope(userRoles, s, config));
22
+ }
23
+ /**
24
+ * Check if user roles grant all of the specified scopes
25
+ */
26
+ export function hasAllScopes(userRoles, scopes, config) {
27
+ return scopes.every(s => hasScope(userRoles, s, config));
28
+ }
29
+ /**
30
+ * Get all scopes granted by a set of roles
31
+ */
32
+ export function getScopesForRoles(roleNames, config) {
33
+ const scopes = new Set();
34
+ for (const roleName of roleNames) {
35
+ const role = config.roles.find((r) => r.name === roleName);
36
+ if (role) {
37
+ role.scopes.forEach((s) => scopes.add(s));
38
+ }
39
+ }
40
+ return Array.from(scopes);
41
+ }
42
+ /**
43
+ * Validate roles configuration
44
+ */
45
+ export function validateRolesConfig(config) {
46
+ const errors = [];
47
+ const roleNames = new Set(config.roles.map((r) => r.name));
48
+ // Check default role exists
49
+ if (config.defaultRole && !roleNames.has(config.defaultRole)) {
50
+ errors.push(`Default role "${config.defaultRole}" is not defined`);
51
+ }
52
+ // Check super admin role exists
53
+ if (config.superAdminRole && !roleNames.has(config.superAdminRole)) {
54
+ errors.push(`Super admin role "${config.superAdminRole}" is not defined`);
55
+ }
56
+ return errors;
57
+ }
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/roles/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,UAAU,QAAQ,CACtB,SAAmB,EACnB,KAAa,EACb,MAAmB;IAEnB,6BAA6B;IAC7B,IAAI,MAAM,CAAC,cAAc,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;QACvE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GAAG,iBAAiB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACxD,OAAO,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACpC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,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7D,MAAM,CAAC,IAAI,CAAC,iBAAiB,MAAM,CAAC,WAAW,kBAAkB,CAAC,CAAC;IACrE,CAAC;IAED,gCAAgC;IAChC,IAAI,MAAM,CAAC,cAAc,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;QACnE,MAAM,CAAC,IAAI,CAAC,qBAAqB,MAAM,CAAC,cAAc,kBAAkB,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Session Management
3
+ *
4
+ * Utilities for managing user sessions and tokens.
5
+ */
6
+ import type { User } from '../types';
7
+ /**
8
+ * Decode JWT token payload (without verification)
9
+ *
10
+ * ⚠️ SECURITY WARNING: This function does NOT verify the token signature.
11
+ * It only decodes the payload for reading claims.
12
+ *
13
+ * Token verification should be handled by:
14
+ * - API Gateway Cognito Authorizer (recommended)
15
+ * - AWS ALB with OIDC authentication
16
+ * - Manual verification using cognito-jwt-verifier
17
+ *
18
+ * Never trust decoded claims for authorization without proper verification.
19
+ */
20
+ export declare function decodeToken(token: string): Record<string, unknown> | null;
21
+ /**
22
+ * Extract user from ID token claims
23
+ */
24
+ export declare function extractUserFromToken(idToken: string): User | null;
25
+ /**
26
+ * Check if a token is expired
27
+ */
28
+ export declare function isTokenExpired(token: string): boolean;
29
+ /**
30
+ * Get token expiry time
31
+ */
32
+ export declare function getTokenExpiry(token: string): Date | null;
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAkB,MAAM,UAAU,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAWzE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAwBjE;AAuDD;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAMrD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAKzD"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Session Management
3
+ *
4
+ * Utilities for managing user sessions and tokens.
5
+ */
6
+ /**
7
+ * Decode JWT token payload (without verification)
8
+ *
9
+ * ⚠️ SECURITY WARNING: This function does NOT verify the token signature.
10
+ * It only decodes the payload for reading claims.
11
+ *
12
+ * Token verification should be handled by:
13
+ * - API Gateway Cognito Authorizer (recommended)
14
+ * - AWS ALB with OIDC authentication
15
+ * - Manual verification using cognito-jwt-verifier
16
+ *
17
+ * Never trust decoded claims for authorization without proper verification.
18
+ */
19
+ export function decodeToken(token) {
20
+ try {
21
+ const parts = token.split('.');
22
+ if (parts.length !== 3)
23
+ return null;
24
+ const payload = parts[1];
25
+ const decoded = Buffer.from(payload, 'base64url').toString('utf-8');
26
+ return JSON.parse(decoded);
27
+ }
28
+ catch {
29
+ return null;
30
+ }
31
+ }
32
+ /**
33
+ * Extract user from ID token claims
34
+ */
35
+ export function extractUserFromToken(idToken) {
36
+ const claims = decodeToken(idToken);
37
+ if (!claims)
38
+ return null;
39
+ // Determine identifier type and value
40
+ const { identifierType, identifier } = determineIdentifier(claims);
41
+ return {
42
+ id: claims.sub,
43
+ identifierType,
44
+ identifier,
45
+ email: claims.email,
46
+ emailVerified: claims.email_verified,
47
+ phone: claims.phone_number,
48
+ phoneVerified: claims.phone_number_verified,
49
+ username: claims.preferred_username ?? claims['cognito:username'],
50
+ name: claims.name,
51
+ locale: claims.locale,
52
+ tenantId: claims['custom:tenant_id'],
53
+ roles: parseRoles(claims),
54
+ attributes: extractCustomAttributes(claims),
55
+ createdAt: new Date(),
56
+ updatedAt: new Date(),
57
+ };
58
+ }
59
+ /**
60
+ * Determine primary identifier from claims
61
+ */
62
+ function determineIdentifier(claims) {
63
+ // Check for email first
64
+ if (claims.email) {
65
+ return { identifierType: 'email', identifier: claims.email };
66
+ }
67
+ // Check for phone
68
+ if (claims.phone_number) {
69
+ return { identifierType: 'phone', identifier: claims.phone_number };
70
+ }
71
+ // Check for username
72
+ if (claims.preferred_username || claims['cognito:username']) {
73
+ return {
74
+ identifierType: 'username',
75
+ identifier: (claims.preferred_username || claims['cognito:username'])
76
+ };
77
+ }
78
+ // Federated identity (use sub as identifier)
79
+ return { identifierType: 'federated', identifier: claims.sub };
80
+ }
81
+ /**
82
+ * Parse roles from token claims
83
+ */
84
+ function parseRoles(claims) {
85
+ const roles = claims['custom:roles'] || claims['cognito:groups'];
86
+ if (!roles)
87
+ return [];
88
+ if (Array.isArray(roles))
89
+ return roles;
90
+ if (typeof roles === 'string')
91
+ return roles.split(',').map(r => r.trim());
92
+ return [];
93
+ }
94
+ /**
95
+ * Extract custom attributes from claims
96
+ */
97
+ function extractCustomAttributes(claims) {
98
+ const attributes = {};
99
+ for (const [key, value] of Object.entries(claims)) {
100
+ if (key.startsWith('custom:') && key !== 'custom:tenant_id' && key !== 'custom:roles') {
101
+ const attrName = key.replace('custom:', '');
102
+ attributes[attrName] = String(value);
103
+ }
104
+ }
105
+ return attributes;
106
+ }
107
+ /**
108
+ * Check if a token is expired
109
+ */
110
+ export function isTokenExpired(token) {
111
+ const claims = decodeToken(token);
112
+ if (!claims || !claims.exp)
113
+ return true;
114
+ const expiry = claims.exp * 1000;
115
+ return Date.now() >= expiry;
116
+ }
117
+ /**
118
+ * Get token expiry time
119
+ */
120
+ export function getTokenExpiry(token) {
121
+ const claims = decodeToken(token);
122
+ if (!claims || !claims.exp)
123
+ return null;
124
+ return new Date(claims.exp * 1000);
125
+ }
126
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAEpC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzB,sCAAsC;IACtC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAEnE,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,GAAa;QACxB,cAAc;QACd,UAAU;QACV,KAAK,EAAE,MAAM,CAAC,KAA2B;QACzC,aAAa,EAAE,MAAM,CAAC,cAAqC;QAC3D,KAAK,EAAE,MAAM,CAAC,YAAkC;QAChD,aAAa,EAAE,MAAM,CAAC,qBAA4C;QAClE,QAAQ,EAAE,MAAM,CAAC,kBAAwC,IAAI,MAAM,CAAC,kBAAkB,CAAuB;QAC7G,IAAI,EAAE,MAAM,CAAC,I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c,GAAG,IAAI,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Auth Configuration Types
3
+ */
4
+ /**
5
+ * Password policy
6
+ */
7
+ export interface PasswordPolicy {
8
+ /** Minimum password length */
9
+ minLength: number;
10
+ /** Require lowercase letters */
11
+ requireLowercase: boolean;
12
+ /** Require uppercase letters */
13
+ requireUppercase: boolean;
14
+ /** Require numbers */
15
+ requireNumbers: boolean;
16
+ /** Require special characters */
17
+ requireSymbols: boolean;
18
+ /** Temporary password validity in days */
19
+ tempPasswordValidityDays: number;
20
+ }
21
+ /**
22
+ * MFA configuration
23
+ */
24
+ export interface MfaConfig {
25
+ /** MFA mode */
26
+ mode: 'off' | 'optional' | 'required';
27
+ /** Allowed MFA methods */
28
+ methods: ('totp' | 'sms')[];
29
+ }
30
+ /**
31
+ * Token configuration
32
+ */
33
+ export interface TokenConfig {
34
+ /** Access token validity in minutes */
35
+ accessTokenValidityMinutes: number;
36
+ /** ID token validity in minutes */
37
+ idTokenValidityMinutes: number;
38
+ /** Refresh token validity in days */
39
+ refreshTokenValidityDays: number;
40
+ }
41
+ /**
42
+ * Cognito User Pool configuration
43
+ */
44
+ export interface CognitoConfig {
45
+ /** User pool name suffix (full name: {projectName}-{env}-users) */
46
+ poolNameSuffix?: string;
47
+ /** Sign-in aliases */
48
+ signInAliases: {
49
+ email: boolean;
50
+ phone: boolean;
51
+ username: boolean;
52
+ };
53
+ /** Self sign-up enabled */
54
+ selfSignUpEnabled: boolean;
55
+ /** Auto-verify email */
56
+ autoVerifyEmail: boolean;
57
+ /** Auto-verify phone */
58
+ autoVerifyPhone: boolean;
59
+ /** Password policy */
60
+ passwordPolicy: PasswordPolicy;
61
+ /** MFA configuration */
62
+ mfa: MfaConfig;
63
+ /** Token configuration */
64
+ tokens: TokenConfig;
65
+ /** Account recovery methods */
66
+ accountRecovery: 'email' | 'phone' | 'both';
67
+ /** Custom attributes */
68
+ customAttributes?: Array<{
69
+ name: string;
70
+ type: 'string' | 'number' | 'boolean';
71
+ mutable: boolean;
72
+ }>;
73
+ }
74
+ /**
75
+ * Auth environment configuration
76
+ */
77
+ export interface AuthEnvConfig {
78
+ /** Cognito configuration */
79
+ cognito: CognitoConfig;
80
+ /** Roles configuration (project-specific) */
81
+ roles?: RolesConfig;
82
+ }
83
+ /**
84
+ * Auth environment configuration input (partial for overrides)
85
+ */
86
+ export interface AuthEnvConfigInput {
87
+ cognito?: Partial<CognitoConfig> & {
88
+ passwordPolicy?: Partial<PasswordPolicy>;
89
+ mfa?: Partial<MfaConfig>;
90
+ tokens?: Partial<TokenConfig>;
91
+ };
92
+ roles?: Partial<RolesConfig>;
93
+ }
94
+ import type { RolesConfig } from './role';
95
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAElB,gCAAgC;IAChC,gBAAgB,EAAE,OAAO,CAAC;IAE1B,gCAAgC;IAChC,gBAAgB,EAAE,OAAO,CAAC;IAE1B,sBAAsB;IACtB,cAAc,EAAE,OAAO,CAAC;IAExB,iCAAiC;IACjC,cAAc,EAAE,OAAO,CAAC;IAExB,0CAA0C;IAC1C,wBAAwB,EAAE,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,eAAe;IACf,IAAI,EAAE,KAAK,GAAG,UAAU,GAAG,UAAU,CAAC;IAEtC,0BAA0B;IAC1B,OAAO,EAAE,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uCAAuC;IACvC,0BAA0B,EAAE,MAAM,CAAC;IAEnC,mCAAmC;IACnC,sBAAsB,EAAE,MAAM,CAAC;IAE/B,qCAAqC;IACr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CAAC,WAAW,CAAC,CAAC;CAC9B;AAGD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Auth Configuration Types
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Auth Types
3
+ *
4
+ * Core authentication and authorization types for VentureKit.
5
+ */
6
+ export * from './user';
7
+ export * from './session';
8
+ export * from './role';
9
+ export * from './config';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Auth Types
3
+ *
4
+ * Core authentication and authorization types for VentureKit.
5
+ */
6
+ export * from './user';
7
+ export * from './session';
8
+ export * from './role';
9
+ export * from './config';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Role Types
3
+ */
4
+ /**
5
+ * Role definition
6
+ *
7
+ * A role grants access to a set of scopes.
8
+ * Scopes control API access (e.g., 'projects.read', 'users.admin').
9
+ */
10
+ export interface Role {
11
+ /** Role name (e.g., 'admin', 'member', 'viewer') */
12
+ name: string;
13
+ /** Human-readable description */
14
+ description: string;
15
+ /** Scopes granted by this role */
16
+ scopes: string[];
17
+ /** Whether this is a system role (cannot be deleted) */
18
+ isSystem?: boolean;
19
+ }
20
+ /**
21
+ * Roles configuration
22
+ *
23
+ * Project-specific roles configuration.
24
+ * VentureKit does not define default roles - each project defines its own.
25
+ */
26
+ export interface RolesConfig {
27
+ /** Available roles (project-specific) */
28
+ roles: Role[];
29
+ /** Default role for new users */
30
+ defaultRole?: string;
31
+ /** Super admin role (has all scopes) */
32
+ superAdminRole?: string;
33
+ }
34
+ //# sourceMappingURL=role.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role.d.ts","sourceRoot":"","sources":["../../src/types/role.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,IAAI;IACnB,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IAEb,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IAEpB,kCAAkC;IAClC,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,KAAK,EAAE,IAAI,EAAE,CAAC;IAEd,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,wCAAwC;IACxC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Role Types
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=role.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role.js","sourceRoot":"","sources":["../../src/types/role.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Session Types
3
+ */
4
+ /**
5
+ * Authentication tokens
6
+ */
7
+ export interface AuthTokens {
8
+ /** JWT access token */
9
+ accessToken: string;
10
+ /** JWT ID token */
11
+ idToken: string;
12
+ /** Refresh token (if enabled) */
13
+ refreshToken?: string;
14
+ /** Token type (always "Bearer") */
15
+ tokenType: 'Bearer';
16
+ /** Access token expiry in seconds */
17
+ expiresIn: number;
18
+ }
19
+ /**
20
+ * Active session
21
+ */
22
+ export interface Session {
23
+ /** Session ID */
24
+ id: string;
25
+ /** User ID */
26
+ userId: string;
27
+ /** Tenant ID */
28
+ tenantId?: string;
29
+ /** Client ID that created this session */
30
+ clientId: string;
31
+ /** OAuth scopes for this session */
32
+ scopes: string[];
33
+ /** When the session was created */
34
+ createdAt: Date;
35
+ /** When the session expires */
36
+ expiresAt: Date;
37
+ /** Last activity timestamp */
38
+ lastActivityAt: Date;
39
+ /** IP address */
40
+ ipAddress?: string;
41
+ /** User agent */
42
+ userAgent?: string;
43
+ }
44
+ /**
45
+ * Login credentials
46
+ */
47
+ export interface LoginCredentials {
48
+ email: string;
49
+ password: string;
50
+ }
51
+ /**
52
+ * Password reset request
53
+ */
54
+ export interface PasswordResetRequest {
55
+ email: string;
56
+ }
57
+ /**
58
+ * Password reset confirmation
59
+ */
60
+ export interface PasswordResetConfirmation {
61
+ email: string;
62
+ code: string;
63
+ newPassword: string;
64
+ }
65
+ /**
66
+ * Change password request
67
+ */
68
+ export interface ChangePasswordRequest {
69
+ oldPassword: string;
70
+ newPassword: string;
71
+ }
72
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/types/session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,uBAAuB;IACvB,WAAW,EAAE,MAAM,CAAC;IAEpB,mBAAmB;IACnB,OAAO,EAAE,MAAM,CAAC;IAEhB,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,mCAAmC;IACnC,SAAS,EAAE,QAAQ,CAAC;IAEpB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,iBAAiB;IACjB,EAAE,EAAE,MAAM,CAAC;IAEX,cAAc;IACd,MAAM,EAAE,MAAM,CAAC;IAEf,gBAAgB;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IAEjB,oCAAoC;IACpC,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB,mCAAmC;IACnC,SAAS,EAAE,IAAI,CAAC;IAEhB,+BAA+B;IAC/B,SAAS,EAAE,IAAI,CAAC;IAEhB,8BAA8B;IAC9B,cAAc,EAAE,IAAI,CAAC;IAErB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Session Types
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/types/session.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * User Types
3
+ */
4
+ /**
5
+ * User identifier type
6
+ */
7
+ export type IdentifierType = 'email' | 'phone' | 'username' | 'federated';
8
+ /**
9
+ * User identity from Cognito
10
+ *
11
+ * Users can be identified by email, phone, username, or federated identity.
12
+ * Roles grant access to scopes - scopes are not stored on the user directly.
13
+ */
14
+ export interface User {
15
+ /** Cognito user ID (sub) */
16
+ id: string;
17
+ /** Primary identifier type */
18
+ identifierType: IdentifierType;
19
+ /** Primary identifier value (email, phone, username, or federated ID) */
20
+ identifier: string;
21
+ /** Email address (optional) */
22
+ email?: string;
23
+ /** Whether email is verified */
24
+ emailVerified?: boolean;
25
+ /** Phone number (optional) */
26
+ phone?: string;
27
+ /** Whether phone is verified */
28
+ phoneVerified?: boolean;
29
+ /** Username (optional) */
30
+ username?: string;
31
+ /** User's display name */
32
+ name?: string;
33
+ /** User's preferred locale */
34
+ locale?: string;
35
+ /** Tenant ID for multi-tenant apps */
36
+ tenantId?: string;
37
+ /** User's roles (roles grant scopes) */
38
+ roles: string[];
39
+ /** Custom attributes */
40
+ attributes: Record<string, string>;
41
+ /** When the user was created */
42
+ createdAt: Date;
43
+ /** When the user was last updated */
44
+ updatedAt: Date;
45
+ }
46
+ /**
47
+ * User creation input
48
+ */
49
+ export interface CreateUserInput {
50
+ /** Primary identifier type */
51
+ identifierType: IdentifierType;
52
+ /** Primary identifier value */
53
+ identifier: string;
54
+ /** Password (optional for federated users) */
55
+ password?: string;
56
+ /** Display name */
57
+ name?: string;
58
+ /** Email (if not primary identifier) */
59
+ email?: string;
60
+ /** Phone (if not primary identifier) */
61
+ phone?: string;
62
+ /** Preferred locale */
63
+ locale?: string;
64
+ /** Tenant ID */
65
+ tenantId?: string;
66
+ /** Initial roles */
67
+ roles?: string[];
68
+ /** Custom attributes */
69
+ attributes?: Record<string, string>;
70
+ /** Send welcome message */
71
+ sendInvite?: boolean;
72
+ }
73
+ /**
74
+ * User update input
75
+ */
76
+ export interface UpdateUserInput {
77
+ name?: string;
78
+ phone?: string;
79
+ locale?: string;
80
+ roles?: string[];
81
+ attributes?: Record<string, string>;
82
+ }
83
+ //# sourceMappingURL=user.d.ts.map
@@ -0,0 +1 @@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AAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,uBAAuB;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,gBAAgB;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAEjB,wBAAwB;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEpC,2BAA2B;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * User Types
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/types/user.ts"],"names":[],"mappings":"AAAA;;GAEG"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@venturekit/auth",
3
+ "version": "0.0.0-dev.20260307234057",
4
+ "description": "Authentication and authorization for VentureKit",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/venturekit-dev/venturekit.private.git",
14
+ "directory": "packages/auth"
15
+ },
16
+ "publishConfig": {
17
+ "registry": "https://registry.npmjs.org",
18
+ "access": "public"
19
+ },
20
+ "license": "Apache-2.0",
21
+ "exports": {
22
+ ".": {
23
+ "import": "./dist/index.js",
24
+ "types": "./dist/index.d.ts"
25
+ }
26
+ },
27
+ "dependencies": {
28
+ "@venturekit/core": "0.0.0-dev.20260307234057"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^20.10.0",
32
+ "typescript": "^5.3.0"
33
+ },
34
+ "scripts": {
35
+ "build": "tsc",
36
+ "dev": "tsc --watch",
37
+ "clean": "rm -rf dist"
38
+ }
39
+ }