@bett3r-dev/pv3-types 1.0.0 → 1.4.0

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 (137) hide show
  1. package/CHANGELOG.md +305 -0
  2. package/build/adminPlugin.d.ts +24 -0
  3. package/build/adminPlugin.d.ts.map +1 -0
  4. package/build/{eventsourcing/utils.js → adminPlugin.js} +1 -1
  5. package/build/adminPlugin.js.map +1 -0
  6. package/build/aggregateSchema.d.ts +94 -0
  7. package/build/aggregateSchema.d.ts.map +1 -0
  8. package/build/aggregateSchema.js +287 -0
  9. package/build/aggregateSchema.js.map +1 -0
  10. package/build/authentication.d.ts +179 -78
  11. package/build/authentication.d.ts.map +1 -1
  12. package/build/authentication.js +62 -19
  13. package/build/authentication.js.map +1 -1
  14. package/build/cache.d.ts +50 -4
  15. package/build/cache.d.ts.map +1 -1
  16. package/build/clusterAdministration.d.ts +712 -225
  17. package/build/clusterAdministration.d.ts.map +1 -1
  18. package/build/clusterAdministration.js +175 -52
  19. package/build/clusterAdministration.js.map +1 -1
  20. package/build/configuration.d.ts +26 -5
  21. package/build/configuration.d.ts.map +1 -1
  22. package/build/database.d.ts +240 -56
  23. package/build/database.d.ts.map +1 -1
  24. package/build/database.js +102 -20
  25. package/build/database.js.map +1 -1
  26. package/build/endpoints.d.ts +141 -41
  27. package/build/endpoints.d.ts.map +1 -1
  28. package/build/endpoints.js +50 -26
  29. package/build/endpoints.js.map +1 -1
  30. package/build/errors.d.ts +166 -0
  31. package/build/errors.d.ts.map +1 -0
  32. package/build/errors.js +276 -0
  33. package/build/errors.js.map +1 -0
  34. package/build/evenstore.d.ts +47 -7
  35. package/build/evenstore.d.ts.map +1 -1
  36. package/build/eventsourcing/aggregateBuilder.d.ts +17 -8
  37. package/build/eventsourcing/aggregateBuilder.d.ts.map +1 -1
  38. package/build/eventsourcing/commandBuilder.d.ts +20 -13
  39. package/build/eventsourcing/commandBuilder.d.ts.map +1 -1
  40. package/build/eventsourcing/commandHandlers.d.ts +155 -33
  41. package/build/eventsourcing/commandHandlers.d.ts.map +1 -1
  42. package/build/eventsourcing/commandHandlers.js +62 -14
  43. package/build/eventsourcing/commandHandlers.js.map +1 -1
  44. package/build/eventsourcing/eventHandlers.d.ts +173 -44
  45. package/build/eventsourcing/eventHandlers.d.ts.map +1 -1
  46. package/build/eventsourcing/eventHandlers.js +29 -21
  47. package/build/eventsourcing/eventHandlers.js.map +1 -1
  48. package/build/eventsourcing/eventHandlersBuilder.d.ts +18 -12
  49. package/build/eventsourcing/eventHandlersBuilder.d.ts.map +1 -1
  50. package/build/eventsourcing/eventHandlersBuilder.js.map +1 -1
  51. package/build/eventsourcing/eventsourcing.types.d.ts +322 -0
  52. package/build/eventsourcing/eventsourcing.types.d.ts.map +1 -0
  53. package/build/eventsourcing/eventsourcing.types.js +26 -0
  54. package/build/eventsourcing/eventsourcing.types.js.map +1 -0
  55. package/build/eventsourcing/externalSystemBuilder.d.ts +8 -7
  56. package/build/eventsourcing/externalSystemBuilder.d.ts.map +1 -1
  57. package/build/eventsourcing/index.d.ts +2 -378
  58. package/build/eventsourcing/index.d.ts.map +1 -1
  59. package/build/eventsourcing/index.js +2 -23
  60. package/build/eventsourcing/index.js.map +1 -1
  61. package/build/eventsourcing/invariants.d.ts +34 -10
  62. package/build/eventsourcing/invariants.d.ts.map +1 -1
  63. package/build/eventsourcing/shapeChangeForSubscriber.d.ts +33 -0
  64. package/build/eventsourcing/shapeChangeForSubscriber.d.ts.map +1 -0
  65. package/build/eventsourcing/shapeChangeForSubscriber.js +47 -0
  66. package/build/eventsourcing/shapeChangeForSubscriber.js.map +1 -0
  67. package/build/index.d.ts +6 -1
  68. package/build/index.d.ts.map +1 -1
  69. package/build/index.js +6 -1
  70. package/build/index.js.map +1 -1
  71. package/build/infrastructure.d.ts +9 -1
  72. package/build/infrastructure.d.ts.map +1 -1
  73. package/build/infrastructure.js +33 -1
  74. package/build/infrastructure.js.map +1 -1
  75. package/build/livenessWatchdog.d.ts +28 -0
  76. package/build/livenessWatchdog.d.ts.map +1 -0
  77. package/build/livenessWatchdog.js +43 -0
  78. package/build/livenessWatchdog.js.map +1 -0
  79. package/build/logger.d.ts +8 -9
  80. package/build/logger.d.ts.map +1 -1
  81. package/build/logger.js +18 -6
  82. package/build/logger.js.map +1 -1
  83. package/build/outboxManager.d.ts +858 -14
  84. package/build/outboxManager.d.ts.map +1 -1
  85. package/build/outboxManager.js +173 -15
  86. package/build/outboxManager.js.map +1 -1
  87. package/build/permissions.d.ts +47 -0
  88. package/build/permissions.d.ts.map +1 -0
  89. package/build/permissions.js +3 -0
  90. package/build/permissions.js.map +1 -0
  91. package/build/ports.d.ts +10 -10
  92. package/build/ports.d.ts.map +1 -1
  93. package/build/routesAuth.d.ts +17 -25
  94. package/build/routesAuth.d.ts.map +1 -1
  95. package/build/routesAuth.js +4 -14
  96. package/build/routesAuth.js.map +1 -1
  97. package/build/typedEventEmitter.d.ts +7 -13
  98. package/build/typedEventEmitter.d.ts.map +1 -1
  99. package/build/typedEventEmitter.js +2 -2
  100. package/build/typedEventEmitter.js.map +1 -1
  101. package/build/userSession.d.ts +8 -0
  102. package/build/userSession.d.ts.map +1 -0
  103. package/build/userSession.js +3 -0
  104. package/build/userSession.js.map +1 -0
  105. package/package.json +22 -7
  106. package/build/eventsourcing/utils.d.ts +0 -4
  107. package/build/eventsourcing/utils.d.ts.map +0 -1
  108. package/build/eventsourcing/utils.js.map +0 -1
  109. package/build/validation.d.ts +0 -64
  110. package/build/validation.d.ts.map +0 -1
  111. package/build/validation.js +0 -57
  112. package/build/validation.js.map +0 -1
  113. package/src/authentication.ts +0 -273
  114. package/src/cache.ts +0 -109
  115. package/src/clusterAdministration.ts +0 -216
  116. package/src/configuration.ts +0 -71
  117. package/src/database.ts +0 -157
  118. package/src/endpoints.ts +0 -198
  119. package/src/evenstore.ts +0 -27
  120. package/src/eventsourcing/aggregateBuilder.ts +0 -11
  121. package/src/eventsourcing/commandBuilder.ts +0 -64
  122. package/src/eventsourcing/commandHandlers.ts +0 -137
  123. package/src/eventsourcing/eventHandlers.ts +0 -118
  124. package/src/eventsourcing/eventHandlersBuilder.ts +0 -42
  125. package/src/eventsourcing/externalSystemBuilder.ts +0 -20
  126. package/src/eventsourcing/index.ts +0 -111
  127. package/src/eventsourcing/invariants.ts +0 -27
  128. package/src/eventsourcing/utils.ts +0 -4
  129. package/src/index.ts +0 -15
  130. package/src/infrastructure.ts +0 -41
  131. package/src/logger.ts +0 -45
  132. package/src/outboxManager.ts +0 -36
  133. package/src/ports.ts +0 -42
  134. package/src/routesAuth.ts +0 -58
  135. package/src/typedEventEmitter.ts +0 -73
  136. package/src/validation.ts +0 -89
  137. package/tsconfig.json +0 -15
@@ -1,8 +1,8 @@
1
- /// <reference types="ramda/node_modules/ts-toolbelt" />
2
- import { RoutesAuthManagerType } from './routesAuth';
3
- import { ClusterRoutesConfigType } from './clusterAdministration';
4
1
  import { AdapterBase, PortEmitter } from './ports';
5
- import { Ports } from './ports';
2
+ import { AuthorizationResult } from './permissions';
3
+ import { RouteAuthManagerFactory, RoutesAuthManagerType } from './routesAuth';
4
+ import { CollectionQueryParams } from './database';
5
+ import { Document } from './database';
6
6
  /**
7
7
  * @category Schemas
8
8
  */
@@ -27,13 +27,21 @@ export type AuthenticationPassword = typeof AuthenticationPasswordSchema.type;
27
27
  * @category Schemas
28
28
  */
29
29
  export declare const AuthenticationRoleSchema: import("@bett3r-dev/jsonschema-definer").ObjectSchema<{
30
- role: string;
30
+ name: string;
31
+ description?: string | undefined;
32
+ }, true>;
33
+ export type AuthenticationRoleType = typeof AuthenticationRoleSchema.type;
34
+ export declare const AuthenticationUserRoleSchema: import("@bett3r-dev/jsonschema-definer").ObjectSchema<{
35
+ name: string;
31
36
  }, true>;
37
+ export type AuthenticationUserRoleType = typeof AuthenticationUserRoleSchema.type;
32
38
  /**
33
39
  * @category Schemas
34
40
  */
35
41
  export declare const AuthenticationRolesSchema: import("@bett3r-dev/jsonschema-definer").ObjectSchema<{
36
- roles: string[];
42
+ roles: {
43
+ name: string;
44
+ }[];
37
45
  }, true>;
38
46
  export type AuthenticationRolesType = typeof AuthenticationRolesSchema.type;
39
47
  /**
@@ -56,17 +64,27 @@ export declare const AuthenticationProviderUserSchema: import("@bett3r-dev/jsons
56
64
  * @category Schemas
57
65
  */
58
66
  export declare const UserLoginSchema: import("@bett3r-dev/jsonschema-definer").ObjectSchema<{
59
- email: string;
60
- password: string;
67
+ password?: string | undefined;
68
+ token?: string | undefined;
69
+ usernameOrEmail?: string | undefined;
70
+ organizationId?: string | undefined;
71
+ type: "magiclink" | "password" | "social";
72
+ provider?: "google" | undefined;
61
73
  }, true>;
62
- export type UserLogin = typeof UserLoginSchema.type;
74
+ export type UserLoginType = typeof UserLoginSchema.type;
63
75
  /**
64
76
  * @category Schemas
65
77
  */
66
78
  export declare const AuthenticationRegistrationSchema: import("@bett3r-dev/jsonschema-definer").ObjectSchema<{
67
- email: string;
68
- password: string;
69
- roles: string[];
79
+ password?: string | undefined;
80
+ roles: {
81
+ name: string;
82
+ }[];
83
+ token?: string | undefined;
84
+ usernameOrEmail?: string | undefined;
85
+ organizationId?: string | undefined;
86
+ type?: "magiclink" | "password" | "social" | undefined;
87
+ provider?: "google" | undefined;
70
88
  }, true>;
71
89
  export type AuthenticationRegistrationType = typeof AuthenticationRegistrationSchema.type;
72
90
  /**
@@ -82,7 +100,9 @@ export type AuthenticationCustomAttributesType = typeof AuthenticationCustomAttr
82
100
  export declare const AuthenticationUserSchema: import("@bett3r-dev/jsonschema-definer").ObjectSchema<{
83
101
  id: string;
84
102
  email: string;
85
- roles: string[];
103
+ roles: {
104
+ name: string;
105
+ }[];
86
106
  attributes?: {} | undefined;
87
107
  }, true>;
88
108
  export type AuthenticationUser = typeof AuthenticationUserSchema.type;
@@ -90,121 +110,183 @@ export type AuthenticationUser = typeof AuthenticationUserSchema.type;
90
110
  * @category Schemas
91
111
  */
92
112
  export declare const AuthenticationCreateUserCommandSchema: import("@bett3r-dev/jsonschema-definer").ObjectSchema<{
113
+ roles?: {
114
+ name: string;
115
+ }[] | undefined;
93
116
  id: string;
117
+ app_id?: string | undefined;
118
+ password?: string | undefined;
94
119
  email: string;
95
- roles: string[];
96
- attributes?: {} | undefined;
97
- password: string;
120
+ firstName?: string | undefined;
121
+ lastName?: string | undefined;
122
+ accountId?: string | undefined;
123
+ planTier?: string | undefined;
98
124
  }, true>;
99
125
  export type AuthenticationCreateUserCommand = typeof AuthenticationCreateUserCommandSchema.type;
100
126
  export declare const AuthenticationUpdateUserCommandSchema: import("@bett3r-dev/jsonschema-definer").ObjectSchema<{
101
- email?: string | undefined;
102
- attributes?: import("Object/Optional").OptionalDeep<{} | undefined>;
103
- providerId: string;
127
+ id: string;
128
+ app_id: string;
129
+ email: string;
130
+ firstName: string;
131
+ lastName: string;
132
+ accountId: string;
133
+ planTier: string;
104
134
  }, true>;
105
135
  export type AuthenticationUpdateUserCommand = typeof AuthenticationUpdateUserCommandSchema.type;
106
136
  /**
107
137
  * @category Schemas
108
138
  */
109
139
  export declare const AuthenticationResponseSchema: import("@bett3r-dev/jsonschema-definer").ObjectSchema<{
110
- roles: string[];
140
+ roles: {
141
+ name: string;
142
+ }[];
111
143
  expires_in: number;
144
+ provider_id: string;
112
145
  refresh_expires_in: number;
113
- 'not-before-policy': number;
146
+ 'not-before-policy'?: number | undefined;
114
147
  access_token: string;
115
148
  refresh_token: string;
116
149
  token_type: string;
117
- session_state: string;
118
- scope: string;
150
+ session_state?: string | undefined;
151
+ scope?: string | undefined;
119
152
  }, true>;
120
153
  export type AuthenticationResponseType = typeof AuthenticationResponseSchema.type;
154
+ /**
155
+ * @category Schemas
156
+ */
157
+ export declare const AuthenticationAssignRolesCommandSchema: import("@bett3r-dev/jsonschema-definer").ObjectSchema<{
158
+ id?: string | undefined;
159
+ email: string;
160
+ roles: {
161
+ name: string;
162
+ }[];
163
+ tenant?: string | undefined;
164
+ }, true>;
165
+ export type AuthenticationAssignRolesCommand = typeof AuthenticationAssignRolesCommandSchema.type;
166
+ /**
167
+ * Token payload after JWT verification.
168
+ * Roles are NOT in the JWT - they are resolved at authorization time from the DB.
169
+ * This is intentional: role changes take effect immediately without re-issuing tokens.
170
+ * @category Authentication Port
171
+ */
172
+ export type TokenPayload = {
173
+ sub: string;
174
+ organizationId?: string;
175
+ iss: string;
176
+ aud: string;
177
+ exp: number;
178
+ iat: number;
179
+ };
180
+ /**
181
+ * JWKS response containing public keys for JWT verification.
182
+ * @category Authentication Port
183
+ */
184
+ export type JwksResponse = {
185
+ keys: Record<string, unknown>[];
186
+ };
121
187
  /**
122
188
  * Logs a user in the Application.
123
189
  * @category Authentication Port
124
190
  * @param email Email of the user
125
191
  * @param password Password of the user
126
192
  */
127
- export declare function loginUser(email: string, password: string): Promise<AuthenticationResponseType>;
193
+ export declare function LoginUserFunction(params: UserLoginType): Promise<AuthenticationResponseType | undefined>;
128
194
  /**
129
195
  * Inits the Recover Password process for the user with the given email.
130
196
  * @category Authentication Port
131
197
  * @param email Email of the user
132
198
  */
133
- export declare function recoverPassword(email: string): Promise<void>;
199
+ export declare function RecoverPasswordFunction(email: string): Promise<void>;
134
200
  /**
135
201
  * Marks the user email address as validated.
136
202
  * @category Authentication Port
137
203
  * @param email Email of the user
138
204
  */
139
- export declare function verifyEmail(email: string): Promise<void>;
205
+ export declare function VerifyEmailFunction(email: string): Promise<void>;
140
206
  /**
141
207
  * Logs out a user from the application
142
208
  * @category Authentication Port
143
- * @param token Session Token to mark as logged out
209
+ * @param userId User ID to mark as logged out
210
+ * @param organizationId Optional organization context
144
211
  */
145
- export declare function logoutUser(token: string): Promise<void>;
212
+ export declare function LogoutUserFunction(userId: string, organizationId?: string): Promise<void>;
146
213
  /**
147
- * Refreshes the user sesssion given the refresh token.
214
+ * Refreshes the user session given the refresh token.
148
215
  * @category Authentication Port
149
216
  * @param refreshToken Session Refresh Token
150
217
  */
151
- export declare function refreshToken(refreshToken: string): Promise<AuthenticationResponseType>;
218
+ export declare function RefreshTokenFunction(refreshToken: string): Promise<AuthenticationResponseType>;
152
219
  /**
153
220
  * Changes the password of the user
154
221
  * @category Authentication Port
155
222
  * @param email User Email Address
156
223
  * @param password New Password for the User
157
224
  */
158
- export declare function resetPassword(email: string, password: string): Promise<void>;
225
+ export declare function ResetPasswordFunction(email: string, password: string): Promise<void>;
226
+ /**
227
+ * Creates a new User in the Authentication Provider
228
+ * @category Authentication Port
229
+ * @param id Application Id of the User to create
230
+ * @param email The Email address of the user
231
+ * @param roles The roles to create the user with
232
+ * @param attributes Additional Attributes to add to the auth token
233
+ */
234
+ export declare function CreateUserFunction(params: AuthenticationCreateUserCommand): Promise<string>;
159
235
  /**
160
- * Creates a new Role in the Application in the Authentication Provider
236
+ * Updates a User in the Authentication Provider
161
237
  * @category Authentication Port
162
- * @param name The name of the Role To Create
238
+ * @param id Provider Id of the User to update
239
+ * @param email The Email address of the user
240
+ * @param attributes Additional Attributes to add to the auth token
163
241
  */
164
- export declare function createRole(name: string): Promise<void>;
242
+ export declare function UpdateUserFunction(params: AuthenticationUpdateUserCommand): Promise<string>;
165
243
  /**
166
- * Fetches from the Authentication Provider the list of existing Roles for the given tenant or the default one.
244
+ * Fetches a list of users from the Authentication Provider
167
245
  * @category Authentication Port
168
- * @param tenant [Optional] The tenant for the role list to be retrieved
246
+ * @param query The query to fetch the users
169
247
  */
170
- export declare function getRoles(tenant?: string): Promise<void>;
248
+ export declare function GetUsersFunction<USER extends Document>(query: CollectionQueryParams<USER>): Promise<USER[]>;
171
249
  /**
172
- * Deletes a Role from the Authentication Provider.
250
+ * Fetches a user from the Authentication Provider by email
173
251
  * @category Authentication Port
174
- * @param name The name of the Role to Delete
252
+ * @param email The email of the user to fetch
175
253
  */
176
- export declare function deleteRole(name: string): Promise<void>;
254
+ export declare function GetUserByEmailFunction(email: string): Promise<AuthenticationUser | null>;
177
255
  /**
178
- * Creates a new User in the Authentication Provider
256
+ * Fetches a user from the Authentication Provider by id
179
257
  * @category Authentication Port
180
- * @param id Application Id of the User to create
181
- * @param email The Email address of the user
182
- * @param roles The roles to create the user with
183
- * @param attributes Additional Attributes to add to the auth token
258
+ * @param id The id of the user to fetch
184
259
  */
185
- export declare function createUser(id: string, email: string, password: string, roles: string[], attributes?: Record<string, any>): Promise<string>;
260
+ export declare function GetUserByIdFunction(id: string): Promise<AuthenticationUser | null>;
186
261
  /**
187
- * Creates a new User in the Authentication Provider
262
+ * Deletes a user from the Authentication Provider
263
+ * @category Authentication Port
264
+ * @param id The id of the user to delete
265
+ */
266
+ export declare function DeleteUserFunction(id: string): Promise<void>;
267
+ /**
268
+ * Verifies a JWT token and returns the decoded payload.
269
+ * @category Authentication Port
270
+ * @param token The JWT token to verify
271
+ */
272
+ export declare function VerifyTokenFunction(token: string): Promise<TokenPayload>;
273
+ /**
274
+ * Returns the JWKS (JSON Web Key Set) for JWT verification.
188
275
  * @category Authentication Port
189
- * @param id Provider Id of the User to create
190
- * @param email The Email address of the user
191
- * @param attributes Additional Attributes to add to the auth token
192
276
  */
193
- export declare function updateUser(providerId: string, email?: string, attributes?: Record<string, any>): Promise<string>;
277
+ export declare function GetJwksFunction(): Promise<JwksResponse>;
194
278
  /**
195
- * Assigns a list of roles to a given user
279
+ * Starts an impersonation session as the target user.
196
280
  * @category Authentication Port
197
- * @param email The User Email Address
198
- * @param roles The Roles to assign to the user
281
+ * @param userId The id of the user to impersonate
199
282
  */
200
- export declare function assignUserRoles(email: string, roles: string[]): Promise<void>;
283
+ export declare function ImpersonateUserFunction(userId: string): Promise<AuthenticationResponseType>;
201
284
  /**
202
- * Removes a list of roles from a given user
285
+ * Stops an active impersonation session.
203
286
  * @category Authentication Port
204
- * @param email The User Email Address
205
- * @param roles The roles to remove from the user
287
+ * @param sessionId The session id to stop impersonation for
206
288
  */
207
- export declare function removeUserRoles(email: string, roles: string[]): Promise<void>;
289
+ export declare function StopImpersonationFunction(sessionId: string): Promise<void>;
208
290
  /**
209
291
  * Performs the Authorization process for a request to a resource given the user Access Token.
210
292
  * This function is the response of the `authorizeRequest` curried execution.
@@ -213,7 +295,7 @@ export declare function removeUserRoles(email: string, roles: string[]): Promise
213
295
  * @param uri The resource uri
214
296
  * @see {@link authorizeRequest}
215
297
  */
216
- export declare function authorizeRequestFunction(accessToken: string, method: string, uri: string): Promise<void>;
298
+ export declare function AuthorizeRequestFunction(accessToken: string, method: string, uri: string): Promise<AuthorizationResult>;
217
299
  /**
218
300
  * Curried function that will receive the routeManager as parameter and
219
301
  * return another function with the actual authorization functionality
@@ -221,32 +303,49 @@ export declare function authorizeRequestFunction(accessToken: string, method: st
221
303
  * @param routeManager The route manager to use to perform the authorization process of the resource requested.
222
304
  * @see {@link authorizeRequestFunction}
223
305
  */
224
- export declare function authorizeRequest(routeManager: RoutesAuthManagerType): typeof authorizeRequestFunction;
306
+ export declare function AuthorizeRequest(routeManager: RoutesAuthManagerType): typeof AuthorizeRequestFunction;
307
+ /**
308
+ * Sends a magic link to the user
309
+ * @category Authentication Port
310
+ * @param params The user to send the magic link to
311
+ */
312
+ export declare function SendMagicLinkFunction(params: UserLoginType): Promise<void>;
313
+ /**
314
+ * Generates a magic link for the user
315
+ * @category Authentication Port
316
+ * @param params The user to generate the magic link for
317
+ */
318
+ export declare function GenerateMagicLinkFunction(params: UserLoginType, expiration?: number): Promise<string>;
225
319
  /**
226
320
  * @category Main Types
227
321
  */
228
- export type AuthenticationType = {
322
+ export type AuthenticationType<USER extends Document = Document> = {
229
323
  name: string;
230
- loginUser: typeof loginUser;
231
- recoverPassword: typeof recoverPassword;
232
- verifyEmail: typeof verifyEmail;
233
- logoutUser: typeof logoutUser;
234
- refreshToken: typeof refreshToken;
235
- resetPassword: typeof resetPassword;
236
- createRole: typeof createRole;
237
- getRoles: typeof getRoles;
238
- deleteRole: typeof deleteRole;
239
- createUser: typeof createUser;
240
- updateUser: typeof updateUser;
241
- assignUserRoles: typeof assignUserRoles;
242
- removeUserRoles: typeof removeUserRoles;
243
- authorizeRequest: typeof authorizeRequest;
324
+ loginUser: typeof LoginUserFunction;
325
+ logoutUser: typeof LogoutUserFunction;
326
+ refreshToken: typeof RefreshTokenFunction;
327
+ recoverPassword?: typeof RecoverPasswordFunction;
328
+ resetPassword?: typeof ResetPasswordFunction;
329
+ verifyEmail?: typeof VerifyEmailFunction;
330
+ sendMagicLink?: typeof SendMagicLinkFunction;
331
+ generateMagicLink?: typeof GenerateMagicLinkFunction;
332
+ createUser: typeof CreateUserFunction;
333
+ updateUser: typeof UpdateUserFunction;
334
+ deleteUser: typeof DeleteUserFunction;
335
+ getUsers: typeof GetUsersFunction<USER>;
336
+ getUserByEmail: typeof GetUserByEmailFunction;
337
+ getUserById: typeof GetUserByIdFunction;
338
+ impersonateUser?: typeof ImpersonateUserFunction;
339
+ stopImpersonation?: typeof StopImpersonationFunction;
340
+ verifyToken: typeof VerifyTokenFunction;
341
+ getJwks?: typeof GetJwksFunction;
342
+ authorizeRequest: typeof AuthorizeRequest;
244
343
  };
245
344
  /**
246
345
  * @category Main Types
247
346
  */
248
347
  export type AuthenticationPort = PortEmitter & AuthenticationType & {
249
- RouteManager: (ports: Pick<Ports, 'database' | 'eventstore'>, config: ClusterRoutesConfigType, eventstore?: Ports['eventstore']) => RoutesAuthManagerType;
348
+ RouteManager: RouteAuthManagerFactory;
250
349
  };
251
350
  /**
252
351
  * Defines the concrete implementation for the Authentication Port.
@@ -257,5 +356,7 @@ export type AuthenticationPort = PortEmitter & AuthenticationType & {
257
356
  * __stop__ Disconnects the Service Account from the Authentication Provider
258
357
  * @category Main Types
259
358
  */
260
- export type AuthenticationAdapter = AuthenticationType & AdapterBase;
359
+ export type AuthenticationAdapter = AuthenticationType & AdapterBase & {
360
+ getHandler?: () => (req: unknown, res: unknown) => Promise<void>;
361
+ };
261
362
  //# sourceMappingURL=authentication.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.d.ts","sourceRoot":"","sources":["../src/authentication.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAA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AAkB,CAAA;IACrC,YAAY,EAAE,OAAO,oBAAoB,CAAA;IACzC,eAAe,CAAC,EAAE,OAAO,uBAAuB,CAAA;IAChD,aAAa,CAAC,EAAE,OAAO,qBAAqB,CAAA;IAC5C,WAAW,CAAC,EAAE,OAAO,mBAAmB,CAAA;IACxC,aAAa,CAAC,EAAE,OAAO,qBAAqB,CAAA;IAC5C,iBAAiB,CAAC,EAAE,OAAO,yBAAyB,CAAA;IAGpD,UAAU,EAAE,OAAO,kBAAkB,CAAA;IACrC,UAAU,EAAE,OAAO,kBAAkB,CAAA;IACrC,UAAU,EAAE,OAAO,kBAAkB,CAAA;IACrC,QAAQ,EAAE,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAA;IACvC,cAAc,EAAE,OAAO,sBAAsB,CAAA;IAC7C,WAAW,EAAE,OAAO,mBAAmB,CAAA;IAGvC,eAAe,CAAC,EAAE,OAAO,uBAAuB,CAAA;IAChD,iBAAiB,CAAC,EAAE,OAAO,yBAAyB,CAAA;IAGpD,WAAW,EAAE,OAAO,mBAAmB,CAAA;IACvC,OAAO,CAAC,EAAE,OAAO,eAAe,CAAA;IAGhC,gBAAgB,EAAE,OAAO,gBAAgB,CAAA;CAC1C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,kBAAkB,GAAG;IAClE,YAAY,EAAE,uBAAuB,CAAA;CACtC,CAAC;AAEF;;;;;;;;EAQE;AACF,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,GAAG,WAAW,GAAG;IACrE,UAAU,CAAC,EAAE,MAAM,CAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,KAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACpE,CAAC"}
@@ -15,15 +15,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.AuthenticationResponseSchema = exports.AuthenticationUpdateUserCommandSchema = exports.AuthenticationCreateUserCommandSchema = exports.AuthenticationUserSchema = exports.AuthenticationCustomAttributesSchema = exports.AuthenticationRegistrationSchema = exports.UserLoginSchema = exports.AuthenticationProviderUserSchema = exports.AuthenticationProviderIdSchema = exports.AuthenticationRolesSchema = exports.AuthenticationRoleSchema = exports.AuthenticationPasswordSchema = exports.AuthenticationEmailSchema = exports.AuthenticationIdSchema = void 0;
36
+ exports.AuthenticationAssignRolesCommandSchema = exports.AuthenticationResponseSchema = exports.AuthenticationUpdateUserCommandSchema = exports.AuthenticationCreateUserCommandSchema = exports.AuthenticationUserSchema = exports.AuthenticationCustomAttributesSchema = exports.AuthenticationRegistrationSchema = exports.UserLoginSchema = exports.AuthenticationProviderUserSchema = exports.AuthenticationProviderIdSchema = exports.AuthenticationRolesSchema = exports.AuthenticationUserRoleSchema = exports.AuthenticationRoleSchema = exports.AuthenticationPasswordSchema = exports.AuthenticationEmailSchema = exports.AuthenticationIdSchema = void 0;
27
37
  const jsonschema_definer_1 = __importStar(require("@bett3r-dev/jsonschema-definer"));
28
38
  //*******************************************
29
39
  // Schemas
@@ -50,20 +60,27 @@ exports.AuthenticationPasswordSchema = jsonschema_definer_1.default.shape({
50
60
  * @category Schemas
51
61
  */
52
62
  exports.AuthenticationRoleSchema = jsonschema_definer_1.default.shape({
53
- role: jsonschema_definer_1.default.string(),
63
+ /** The name of the role */
64
+ name: jsonschema_definer_1.default.string(),
65
+ /** The description of the role */
66
+ description: jsonschema_definer_1.default.string().optional()
67
+ });
68
+ exports.AuthenticationUserRoleSchema = jsonschema_definer_1.default.shape({
69
+ /** The name of the role the user has */
70
+ name: jsonschema_definer_1.default.string()
54
71
  });
55
72
  /**
56
73
  * @category Schemas
57
74
  */
58
75
  exports.AuthenticationRolesSchema = jsonschema_definer_1.default.shape({
59
- roles: jsonschema_definer_1.default.array().items(jsonschema_definer_1.default.string()),
76
+ roles: jsonschema_definer_1.default.array().items(exports.AuthenticationUserRoleSchema)
60
77
  });
61
78
  /**
62
79
  * @category Schemas
63
80
  */
64
81
  exports.AuthenticationProviderIdSchema = jsonschema_definer_1.default.shape({
65
82
  providerId: jsonschema_definer_1.default.string(),
66
- providerName: jsonschema_definer_1.default.string(),
83
+ providerName: jsonschema_definer_1.default.string()
67
84
  });
68
85
  /**
69
86
  * @category Schemas
@@ -72,16 +89,27 @@ exports.AuthenticationProviderUserSchema = (0, jsonschema_definer_1.mergeSchemas
72
89
  /**
73
90
  * @category Schemas
74
91
  */
75
- exports.UserLoginSchema = (0, jsonschema_definer_1.mergeSchemas)(exports.AuthenticationEmailSchema, exports.AuthenticationPasswordSchema);
92
+ exports.UserLoginSchema = (0, jsonschema_definer_1.mergeMultipleSchemas)(
93
+ // AuthenticationIdSchema,
94
+ // AuthenticationEmailSchema,
95
+ exports.AuthenticationPasswordSchema.notRequired(['password']), jsonschema_definer_1.default.shape({
96
+ token: jsonschema_definer_1.default.string().optional(),
97
+ usernameOrEmail: jsonschema_definer_1.default.string().optional(),
98
+ organizationId: jsonschema_definer_1.default.string().optional(),
99
+ type: jsonschema_definer_1.default.string().enum('magiclink', 'password', 'social'),
100
+ provider: jsonschema_definer_1.default.string().enum('google')
101
+ .optional()
102
+ }));
76
103
  /**
77
104
  * @category Schemas
78
105
  */
79
- exports.AuthenticationRegistrationSchema = (0, jsonschema_definer_1.mergeSchemas)(exports.UserLoginSchema, exports.AuthenticationRolesSchema);
106
+ exports.AuthenticationRegistrationSchema = (0, jsonschema_definer_1.mergeSchemas)(exports.UserLoginSchema.notRequired(['type', 'password', 'id']), exports.AuthenticationRolesSchema);
80
107
  /**
81
108
  * @category Schemas
82
109
  */
83
110
  exports.AuthenticationCustomAttributesSchema = jsonschema_definer_1.default.shape({
84
- attributes: jsonschema_definer_1.default.shape({}).additionalProperties(true).optional()
111
+ attributes: jsonschema_definer_1.default.shape({}).additionalProperties(true)
112
+ .optional()
85
113
  });
86
114
  /**
87
115
  * @category Schemas
@@ -90,19 +118,34 @@ exports.AuthenticationUserSchema = (0, jsonschema_definer_1.mergeMultipleSchemas
90
118
  /**
91
119
  * @category Schemas
92
120
  */
93
- exports.AuthenticationCreateUserCommandSchema = (0, jsonschema_definer_1.mergeSchemas)(exports.AuthenticationUserSchema, exports.AuthenticationPasswordSchema);
94
- exports.AuthenticationUpdateUserCommandSchema = (0, jsonschema_definer_1.mergeSchemas)((0, jsonschema_definer_1.omitFromSchema)(exports.AuthenticationCreateUserCommandSchema, ['password', 'id', 'roles']).partial(), jsonschema_definer_1.default.shape({ providerId: jsonschema_definer_1.default.string() }));
121
+ exports.AuthenticationCreateUserCommandSchema = (0, jsonschema_definer_1.mergeSchemas)(exports.AuthenticationRolesSchema.notRequired(['roles']), jsonschema_definer_1.default.shape({
122
+ id: jsonschema_definer_1.default.string(),
123
+ app_id: jsonschema_definer_1.default.string().optional(),
124
+ password: jsonschema_definer_1.default.string().optional(),
125
+ email: jsonschema_definer_1.default.string(),
126
+ firstName: jsonschema_definer_1.default.string().optional(),
127
+ lastName: jsonschema_definer_1.default.string().optional(),
128
+ accountId: jsonschema_definer_1.default.string().optional(),
129
+ planTier: jsonschema_definer_1.default.string().optional()
130
+ }).additionalProperties(true));
131
+ exports.AuthenticationUpdateUserCommandSchema = (0, jsonschema_definer_1.omitFromSchema)(exports.AuthenticationCreateUserCommandSchema, ['password', 'roles']).partial()
132
+ .required(['id']);
95
133
  /**
96
134
  * @category Schemas
97
135
  */
98
136
  exports.AuthenticationResponseSchema = (0, jsonschema_definer_1.mergeSchemas)(exports.AuthenticationRolesSchema, jsonschema_definer_1.default.shape({
99
137
  'expires_in': jsonschema_definer_1.default.number(),
138
+ 'provider_id': jsonschema_definer_1.default.string(),
100
139
  'refresh_expires_in': jsonschema_definer_1.default.number(),
101
- 'not-before-policy': jsonschema_definer_1.default.number(),
140
+ 'not-before-policy': jsonschema_definer_1.default.number().optional(),
102
141
  'access_token': jsonschema_definer_1.default.string(),
103
142
  'refresh_token': jsonschema_definer_1.default.string(),
104
143
  'token_type': jsonschema_definer_1.default.string(),
105
- 'session_state': jsonschema_definer_1.default.string(),
106
- 'scope': jsonschema_definer_1.default.string(),
144
+ 'session_state': jsonschema_definer_1.default.string().optional(),
145
+ 'scope': jsonschema_definer_1.default.string().optional()
107
146
  }));
147
+ /**
148
+ * @category Schemas
149
+ */
150
+ exports.AuthenticationAssignRolesCommandSchema = (0, jsonschema_definer_1.mergeMultipleSchemas)(exports.AuthenticationIdSchema.notRequired(['id']), exports.AuthenticationEmailSchema, exports.AuthenticationRolesSchema, jsonschema_definer_1.default.shape({ tenant: jsonschema_definer_1.default.string().optional() }));
108
151
  //# sourceMappingURL=authentication.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.js","sourceRoot":"","sources":["../src/authentication.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qFAAuG;AAMvG,6CAA6C;AAC7C,UAAU;AACV,6CAA6C;AAC7C;;GAEG;AACU,QAAA,sBAAsB,GAAG,4BAAC,CAAC,KAAK,CAAC;IAC5C,E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