alepha 0.11.9 → 0.11.10

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 (166) hide show
  1. package/README.md +55 -17
  2. package/dist/index.cjs +15805 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +1 -0
  5. package/dist/index.d.ts +2 -0
  6. package/dist/index.js +15804 -0
  7. package/dist/index.js.map +1 -0
  8. package/package.json +36 -365
  9. package/src/assets/biomeJson.ts +33 -0
  10. package/src/assets/tsconfigJson.ts +17 -0
  11. package/src/assets/viteConfigTs.ts +14 -0
  12. package/src/commands/BiomeCommands.ts +60 -0
  13. package/src/commands/CoreCommands.ts +266 -0
  14. package/src/commands/DrizzleCommands.ts +403 -0
  15. package/src/commands/VerifyCommands.ts +48 -0
  16. package/src/commands/ViteCommands.ts +152 -0
  17. package/src/index.ts +35 -0
  18. package/src/services/ProcessRunner.ts +89 -0
  19. package/src/version.ts +7 -0
  20. package/api/files.cjs +0 -8
  21. package/api/files.d.ts +0 -438
  22. package/api/files.js +0 -1
  23. package/api/jobs.cjs +0 -8
  24. package/api/jobs.d.ts +0 -327
  25. package/api/jobs.js +0 -1
  26. package/api/notifications.cjs +0 -8
  27. package/api/notifications.d.ts +0 -263
  28. package/api/notifications.js +0 -1
  29. package/api/users.cjs +0 -8
  30. package/api/users.d.ts +0 -923
  31. package/api/users.js +0 -1
  32. package/api/verifications.cjs +0 -8
  33. package/api/verifications.d.ts +0 -1
  34. package/api/verifications.js +0 -1
  35. package/batch.cjs +0 -8
  36. package/batch.d.ts +0 -154
  37. package/batch.js +0 -1
  38. package/bucket.cjs +0 -8
  39. package/bucket.d.ts +0 -520
  40. package/bucket.js +0 -1
  41. package/cache/redis.cjs +0 -8
  42. package/cache/redis.d.ts +0 -40
  43. package/cache/redis.js +0 -1
  44. package/cache.cjs +0 -8
  45. package/cache.d.ts +0 -288
  46. package/cache.js +0 -1
  47. package/command.cjs +0 -8
  48. package/command.d.ts +0 -269
  49. package/command.js +0 -1
  50. package/core.cjs +0 -8
  51. package/core.d.ts +0 -1904
  52. package/core.js +0 -1
  53. package/datetime.cjs +0 -8
  54. package/datetime.d.ts +0 -144
  55. package/datetime.js +0 -1
  56. package/devtools.cjs +0 -8
  57. package/devtools.d.ts +0 -252
  58. package/devtools.js +0 -1
  59. package/email.cjs +0 -8
  60. package/email.d.ts +0 -187
  61. package/email.js +0 -1
  62. package/fake.cjs +0 -8
  63. package/fake.d.ts +0 -73
  64. package/fake.js +0 -1
  65. package/file.cjs +0 -8
  66. package/file.d.ts +0 -528
  67. package/file.js +0 -1
  68. package/lock/redis.cjs +0 -8
  69. package/lock/redis.d.ts +0 -24
  70. package/lock/redis.js +0 -1
  71. package/lock.cjs +0 -8
  72. package/lock.d.ts +0 -552
  73. package/lock.js +0 -1
  74. package/logger.cjs +0 -8
  75. package/logger.d.ts +0 -287
  76. package/logger.js +0 -1
  77. package/postgres.cjs +0 -8
  78. package/postgres.d.ts +0 -2143
  79. package/postgres.js +0 -1
  80. package/queue/redis.cjs +0 -8
  81. package/queue/redis.d.ts +0 -29
  82. package/queue/redis.js +0 -1
  83. package/queue.cjs +0 -8
  84. package/queue.d.ts +0 -760
  85. package/queue.js +0 -1
  86. package/react/auth.cjs +0 -8
  87. package/react/auth.d.ts +0 -504
  88. package/react/auth.js +0 -1
  89. package/react/form.cjs +0 -8
  90. package/react/form.d.ts +0 -211
  91. package/react/form.js +0 -1
  92. package/react/head.cjs +0 -8
  93. package/react/head.d.ts +0 -120
  94. package/react/head.js +0 -1
  95. package/react/i18n.cjs +0 -8
  96. package/react/i18n.d.ts +0 -168
  97. package/react/i18n.js +0 -1
  98. package/react.cjs +0 -8
  99. package/react.d.ts +0 -1263
  100. package/react.js +0 -1
  101. package/redis.cjs +0 -8
  102. package/redis.d.ts +0 -82
  103. package/redis.js +0 -1
  104. package/retry.cjs +0 -8
  105. package/retry.d.ts +0 -162
  106. package/retry.js +0 -1
  107. package/router.cjs +0 -8
  108. package/router.d.ts +0 -45
  109. package/router.js +0 -1
  110. package/scheduler.cjs +0 -8
  111. package/scheduler.d.ts +0 -145
  112. package/scheduler.js +0 -1
  113. package/security.cjs +0 -8
  114. package/security.d.ts +0 -586
  115. package/security.js +0 -1
  116. package/server/cache.cjs +0 -8
  117. package/server/cache.d.ts +0 -163
  118. package/server/cache.js +0 -1
  119. package/server/compress.cjs +0 -8
  120. package/server/compress.d.ts +0 -38
  121. package/server/compress.js +0 -1
  122. package/server/cookies.cjs +0 -8
  123. package/server/cookies.d.ts +0 -144
  124. package/server/cookies.js +0 -1
  125. package/server/cors.cjs +0 -8
  126. package/server/cors.d.ts +0 -45
  127. package/server/cors.js +0 -1
  128. package/server/health.cjs +0 -8
  129. package/server/health.d.ts +0 -58
  130. package/server/health.js +0 -1
  131. package/server/helmet.cjs +0 -8
  132. package/server/helmet.d.ts +0 -98
  133. package/server/helmet.js +0 -1
  134. package/server/links.cjs +0 -8
  135. package/server/links.d.ts +0 -322
  136. package/server/links.js +0 -1
  137. package/server/metrics.cjs +0 -8
  138. package/server/metrics.d.ts +0 -35
  139. package/server/metrics.js +0 -1
  140. package/server/multipart.cjs +0 -8
  141. package/server/multipart.d.ts +0 -42
  142. package/server/multipart.js +0 -1
  143. package/server/proxy.cjs +0 -8
  144. package/server/proxy.d.ts +0 -234
  145. package/server/proxy.js +0 -1
  146. package/server/security.cjs +0 -8
  147. package/server/security.d.ts +0 -92
  148. package/server/security.js +0 -1
  149. package/server/static.cjs +0 -8
  150. package/server/static.d.ts +0 -119
  151. package/server/static.js +0 -1
  152. package/server/swagger.cjs +0 -8
  153. package/server/swagger.d.ts +0 -161
  154. package/server/swagger.js +0 -1
  155. package/server.cjs +0 -8
  156. package/server.d.ts +0 -849
  157. package/server.js +0 -1
  158. package/topic/redis.cjs +0 -8
  159. package/topic/redis.d.ts +0 -42
  160. package/topic/redis.js +0 -1
  161. package/topic.cjs +0 -8
  162. package/topic.d.ts +0 -819
  163. package/topic.js +0 -1
  164. package/vite.cjs +0 -8
  165. package/vite.d.ts +0 -186
  166. package/vite.js +0 -1
package/security.d.ts DELETED
@@ -1,586 +0,0 @@
1
- import * as _alepha_core1 from "alepha";
2
- import { Alepha, Descriptor, KIND, Static } from "alepha";
3
- import * as _alepha_logger0 from "alepha/logger";
4
- import { DateTimeProvider, Duration, DurationLike } from "alepha/datetime";
5
- import { CryptoKey, FlattenedJWSInput, JSONWebKeySet, JWSHeaderParameters, JWTHeaderParameters, JWTPayload, JWTVerifyResult, KeyObject } from "jose";
6
- import * as typebox0 from "typebox";
7
- import { JWTVerifyOptions } from "jose/jwt/verify";
8
-
9
- //#region src/schemas/userAccountInfoSchema.d.ts
10
- declare const userAccountInfoSchema: typebox0.TObject<{
11
- id: typebox0.TString;
12
- name: typebox0.TOptional<typebox0.TString>;
13
- email: typebox0.TOptional<typebox0.TString>;
14
- username: typebox0.TOptional<typebox0.TString>;
15
- picture: typebox0.TOptional<typebox0.TString>;
16
- sessionId: typebox0.TOptional<typebox0.TString>;
17
- organizations: typebox0.TOptional<typebox0.TArray<typebox0.TString>>;
18
- roles: typebox0.TOptional<typebox0.TArray<typebox0.TString>>;
19
- }>;
20
- type UserAccount = Static<typeof userAccountInfoSchema>;
21
- //#endregion
22
- //#region src/interfaces/UserAccountToken.d.ts
23
- /**
24
- * Add contextual metadata to a user account info.
25
- * E.g. UserAccountToken is a UserAccountInfo during a request.
26
- */
27
- interface UserAccountToken extends UserAccount {
28
- /**
29
- * Access token for the user.
30
- */
31
- token?: string;
32
- /**
33
- * Realm name of the user.
34
- */
35
- realm?: string;
36
- /**
37
- * Is user dedicated to his own resources for this scope ?
38
- * Mostly, Admin is false and Customer is true.
39
- */
40
- ownership?: string | boolean;
41
- }
42
- //#endregion
43
- //#region src/schemas/permissionSchema.d.ts
44
- declare const permissionSchema: typebox0.TObject<{
45
- name: typebox0.TString;
46
- group: typebox0.TOptional<typebox0.TString>;
47
- description: typebox0.TOptional<typebox0.TString>;
48
- method: typebox0.TOptional<typebox0.TString>;
49
- path: typebox0.TOptional<typebox0.TString>;
50
- }>;
51
- type Permission = Static<typeof permissionSchema>;
52
- //#endregion
53
- //#region src/schemas/roleSchema.d.ts
54
- declare const roleSchema: typebox0.TObject<{
55
- name: typebox0.TString;
56
- description: typebox0.TOptional<typebox0.TString>;
57
- default: typebox0.TOptional<typebox0.TBoolean>;
58
- permissions: typebox0.TArray<typebox0.TObject<{
59
- name: typebox0.TString;
60
- ownership: typebox0.TOptional<typebox0.TBoolean>;
61
- exclude: typebox0.TOptional<typebox0.TArray<typebox0.TString>>;
62
- }>>;
63
- }>;
64
- type Role = Static<typeof roleSchema>;
65
- //#endregion
66
- //#region src/providers/JwtProvider.d.ts
67
- /**
68
- * Provides utilities for working with JSON Web Tokens (JWT).
69
- */
70
- declare class JwtProvider {
71
- protected readonly log: _alepha_logger0.Logger;
72
- protected readonly keystore: KeyLoaderHolder[];
73
- protected readonly dateTimeProvider: DateTimeProvider;
74
- protected readonly encoder: TextEncoder;
75
- /**
76
- * Adds a key loader to the embedded keystore.
77
- *
78
- * @param name
79
- * @param secretKeyOrJwks
80
- */
81
- setKeyLoader(name: string, secretKeyOrJwks: string | JSONWebKeySet): void;
82
- /**
83
- * Retrieves the payload from a JSON Web Token (JWT).
84
- *
85
- * @param token - The JWT to extract the payload from.
86
- *
87
- * @return A Promise that resolves with the payload object from the token.
88
- */
89
- parse(token: string, keyName?: string, options?: JWTVerifyOptions): Promise<JwtParseResult>;
90
- /**
91
- * Creates a JWT token with the provided payload and secret key.
92
- *
93
- * @param payload - The payload to be encoded in the token.
94
- * It should include the `realm_access` property which contains an array of roles.
95
- * @param keyName - The name of the key to use when signing the token.
96
- *
97
- * @returns The signed JWT token.
98
- */
99
- create(payload: ExtendedJWTPayload, keyName?: string, signOptions?: JwtSignOptions): Promise<string>;
100
- /**
101
- * Determines if the provided key is a secret key.
102
- *
103
- * @param key
104
- * @protected
105
- */
106
- protected isSecretKey(key: string): boolean;
107
- }
108
- type KeyLoader = (protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput) => Promise<CryptoKey | KeyObject>;
109
- interface KeyLoaderHolder {
110
- name: string;
111
- keyLoader: KeyLoader;
112
- secretKey?: string;
113
- }
114
- interface JwtSignOptions {
115
- header?: Partial<JWTHeaderParameters>;
116
- }
117
- interface ExtendedJWTPayload extends JWTPayload {
118
- sid?: string;
119
- name?: string;
120
- roles?: string[];
121
- email?: string;
122
- organizations?: string[];
123
- realm_access?: {
124
- roles: string[];
125
- };
126
- }
127
- interface JwtParseResult {
128
- keyName: string;
129
- result: JWTVerifyResult<ExtendedJWTPayload>;
130
- }
131
- //#endregion
132
- //#region src/providers/SecurityProvider.d.ts
133
- declare const DEFAULT_APP_SECRET = "05759934015388327323179852515731";
134
- declare const envSchema: _alepha_core1.TObject<{
135
- APP_SECRET: _alepha_core1.TString;
136
- }>;
137
- declare module "alepha" {
138
- interface Env extends Partial<Static<typeof envSchema>> {}
139
- }
140
- declare class SecurityProvider {
141
- protected readonly UNKNOWN_USER_NAME = "Anonymous User";
142
- protected readonly PERMISSION_REGEXP: RegExp;
143
- protected readonly PERMISSION_REGEXP_WILDCARD: RegExp;
144
- protected readonly log: _alepha_logger0.Logger;
145
- protected readonly jwt: JwtProvider;
146
- protected readonly env: {
147
- APP_SECRET: string;
148
- };
149
- protected readonly alepha: Alepha;
150
- get secretKey(): string;
151
- /**
152
- * The permissions configured for the security provider.
153
- */
154
- protected readonly permissions: Permission[];
155
- /**
156
- * The realms configured for the security provider.
157
- */
158
- protected readonly realms: Realm[];
159
- protected start: _alepha_core1.HookDescriptor<"start">;
160
- /**
161
- * Adds a role to one or more realms.
162
- *
163
- * @param role
164
- * @param realms
165
- */
166
- createRole(role: Role, ...realms: string[]): Role;
167
- /**
168
- * Adds a permission to the security provider.
169
- *
170
- * @param raw - The permission to add.
171
- */
172
- createPermission(raw: Permission | string): Permission;
173
- createRealm(realm: Realm): void;
174
- /**
175
- * Updates the roles for a realm then synchronizes the user account provider if available.
176
- *
177
- * Only available when the app is started.
178
- *
179
- * @param realm - The realm to update the roles for.
180
- * @param roles - The roles to update.
181
- */
182
- updateRealm(realm: string, roles: Role[]): Promise<void>;
183
- /**
184
- * Creates a user account from the provided payload.
185
- *
186
- * @param payload - The payload to create the user account from.
187
- * @param [realmName] - The realm containing the roles. Default is all.
188
- *
189
- * @returns The user info created from the payload.
190
- */
191
- createUserFromPayload(payload: JWTPayload, realmName?: string): UserAccount;
192
- /**
193
- * Checks if the user has the specified permission.
194
- *
195
- * Bonus: we check also if the user has "ownership" flag.
196
- *
197
- * @param permissionLike - The permission to check for.
198
- * @param roleEntries - The roles to check for the permission.
199
- */
200
- checkPermission(permissionLike: string | Permission, ...roleEntries: string[]): SecurityCheckResult;
201
- /**
202
- * Creates a user account from the provided payload.
203
- */
204
- createUserFromToken(headerOrToken?: string, options?: {
205
- permission?: Permission | string;
206
- realm?: string;
207
- verify?: JWTVerifyOptions;
208
- }): Promise<UserAccountToken>;
209
- /**
210
- * Checks if a user has a specific role.
211
- *
212
- * @param roleName - The role to check for.
213
- * @param permission - The permission to check for.
214
- * @returns True if the user has the role, false otherwise.
215
- */
216
- can(roleName: string, permission: string | Permission): boolean;
217
- /**
218
- * Checks if a user has ownership of a specific permission.
219
- */
220
- ownership(roleName: string, permission: string | Permission): string | boolean | undefined;
221
- /**
222
- * Converts a permission object to a string.
223
- *
224
- * @param permission
225
- */
226
- permissionToString(permission: Permission | string): string;
227
- getRealms(): Realm[];
228
- /**
229
- * Retrieves the user account from the provided user ID.
230
- *
231
- * @param realm
232
- */
233
- getRoles(realm?: string): Role[];
234
- /**
235
- * Returns all permissions.
236
- *
237
- * @param user - Filter permissions by user.
238
- *
239
- * @return An array containing all permissions.
240
- */
241
- getPermissions(user?: {
242
- roles?: Array<Role | string>;
243
- realm?: string;
244
- }): Permission[];
245
- /**
246
- * Retrieves the user ID from the provided payload object.
247
- *
248
- * @param payload - The payload object from which to extract the user ID.
249
- * @return The user ID as a string.
250
- */
251
- getIdFromPayload(payload: Record<string, any>): string;
252
- getSessionIdFromPayload(payload: Record<string, any>): string | undefined;
253
- /**
254
- * Retrieves the roles from the provided payload object.
255
- * @param payload - The payload object from which to extract the roles.
256
- * @return An array of role strings.
257
- */
258
- getRolesFromPayload(payload: Record<string, any>): string[];
259
- getPictureFromPayload(payload: Record<string, any>): string | undefined;
260
- getUsernameFromPayload(payload: Record<string, any>): string | undefined;
261
- getEmailFromPayload(payload: Record<string, any>): string | undefined;
262
- /**
263
- * Returns the name from the given payload.
264
- *
265
- * @param payload - The payload object.
266
- * @returns The name extracted from the payload, or an empty string if the payload is falsy or no name is found.
267
- */
268
- getNameFromPayload(payload: Record<string, any>): string;
269
- getOrganizationsFromPayload(payload: Record<string, any>): string[] | undefined;
270
- }
271
- /**
272
- * A realm definition.
273
- */
274
- interface Realm {
275
- name: string;
276
- roles: Role[];
277
- /**
278
- * The secret key for the realm.
279
- *
280
- * Can be also a JWKS URL.
281
- */
282
- secret?: string | JSONWebKeySet | (() => string);
283
- /**
284
- * Create the user account info based on the raw JWT payload.
285
- * By default, SecurityProvider has his own implementation, but this method allow to override it.
286
- */
287
- profile?: (raw: Record<string, any>) => UserAccount;
288
- }
289
- interface SecurityCheckResult {
290
- isAuthorized: boolean;
291
- ownership: string | boolean | undefined;
292
- }
293
- //#endregion
294
- //#region src/descriptors/$permission.d.ts
295
- /**
296
- * Create a new permission.
297
- */
298
- declare const $permission: {
299
- (options?: PermissionDescriptorOptions): PermissionDescriptor;
300
- [KIND]: typeof PermissionDescriptor;
301
- };
302
- interface PermissionDescriptorOptions {
303
- /**
304
- * Name of the permission. Use Property name is not provided.
305
- */
306
- name?: string;
307
- /**
308
- * Group of the permission. Use Class name is not provided.
309
- */
310
- group?: string;
311
- /**
312
- * Describe the permission.
313
- */
314
- description?: string;
315
- }
316
- declare class PermissionDescriptor extends Descriptor<PermissionDescriptorOptions> {
317
- protected readonly securityProvider: SecurityProvider;
318
- get name(): string;
319
- get group(): string;
320
- toString(): string;
321
- protected onInit(): void;
322
- /**
323
- * Check if the user has the permission.
324
- */
325
- can(user: UserAccount): boolean;
326
- }
327
- //#endregion
328
- //#region src/descriptors/$realm.d.ts
329
- /**
330
- * Create a new realm.
331
- */
332
- declare const $realm: {
333
- (options: RealmDescriptorOptions): RealmDescriptor;
334
- [KIND]: typeof RealmDescriptor;
335
- };
336
- type RealmDescriptorOptions = {
337
- /**
338
- * Define the realm name.
339
- * If not provided, it will use the property key.
340
- */
341
- name?: string;
342
- /**
343
- * Short description about the realm.
344
- */
345
- description?: string;
346
- /**
347
- * All roles available in the realm. Role is a string (role name) or a Role object (embedded role).
348
- */
349
- roles?: Array<string | Role>;
350
- /**
351
- * Realm settings.
352
- */
353
- settings?: RealmSettings;
354
- /**
355
- * Parse the JWT payload to create a user account info.
356
- */
357
- profile?: (jwtPayload: Record<string, any>) => UserAccount;
358
- } & (RealmInternal | RealmExternal);
359
- interface RealmSettings {
360
- accessToken?: {
361
- /**
362
- * Lifetime of the access token.
363
- * @default 15 minutes
364
- */
365
- expiration?: DurationLike;
366
- };
367
- refreshToken?: {
368
- /**
369
- * Lifetime of the refresh token.
370
- * @default 30 days
371
- */
372
- expiration?: DurationLike;
373
- };
374
- onCreateSession?: (user: UserAccount, config: {
375
- expiresIn: number;
376
- }) => Promise<{
377
- refreshToken: string;
378
- sessionId?: string;
379
- }>;
380
- onRefreshSession?: (refreshToken: string) => Promise<{
381
- user: UserAccount;
382
- expiresIn: number;
383
- sessionId?: string;
384
- }>;
385
- onDeleteSession?: (refreshToken: string) => Promise<void>;
386
- }
387
- type RealmInternal = {
388
- /**
389
- * Internal secret to sign JWT tokens and verify them.
390
- */
391
- secret: string;
392
- };
393
- interface RealmExternal {
394
- /**
395
- * URL to the JWKS (JSON Web Key Set) to verify JWT tokens from external providers.
396
- */
397
- jwks: (() => string) | JSONWebKeySet;
398
- }
399
- declare class RealmDescriptor extends Descriptor<RealmDescriptorOptions> {
400
- protected readonly securityProvider: SecurityProvider;
401
- protected readonly dateTimeProvider: DateTimeProvider;
402
- protected readonly jwt: JwtProvider;
403
- protected readonly log: _alepha_logger0.Logger;
404
- get name(): string;
405
- get accessTokenExpiration(): Duration;
406
- get refreshTokenExpiration(): Duration;
407
- protected onInit(): void;
408
- /**
409
- * Get all roles in the realm.
410
- */
411
- getRoles(): Role[];
412
- /**
413
- * Set all roles in the realm.
414
- */
415
- setRoles(roles: Role[]): Promise<void>;
416
- /**
417
- * Get a role by name, throws an error if not found.
418
- */
419
- getRoleByName(name: string): Role;
420
- parseToken(token: string): Promise<JWTPayload>;
421
- /**
422
- * Create a token for the subject.
423
- */
424
- createToken(user: UserAccount, refreshToken?: {
425
- sid?: string;
426
- refresh_token?: string;
427
- refresh_token_expires_in?: number;
428
- }): Promise<AccessTokenResponse>;
429
- refreshToken(refreshToken: string, accessToken?: string): Promise<{
430
- tokens: AccessTokenResponse;
431
- user: UserAccount;
432
- }>;
433
- }
434
- interface CreateTokenOptions {
435
- sub: string;
436
- roles?: string[];
437
- email?: string;
438
- }
439
- interface AccessTokenResponse {
440
- access_token: string;
441
- token_type: string;
442
- expires_in?: number;
443
- issued_at: number;
444
- refresh_token?: string;
445
- refresh_token_expires_in?: number;
446
- scope?: string;
447
- }
448
- //#endregion
449
- //#region src/descriptors/$role.d.ts
450
- /**
451
- * Create a new role.
452
- */
453
- declare const $role: {
454
- (options?: RoleDescriptorOptions): RoleDescriptor;
455
- [KIND]: typeof RoleDescriptor;
456
- };
457
- interface RoleDescriptorOptions {
458
- /**
459
- * Name of the role.
460
- */
461
- name?: string;
462
- /**
463
- * Describe the role.
464
- */
465
- description?: string;
466
- realm?: string | RealmDescriptor;
467
- permissions?: Array<string | {
468
- name: string;
469
- ownership?: boolean;
470
- exclude?: string[];
471
- }>;
472
- }
473
- declare class RoleDescriptor extends Descriptor<RoleDescriptorOptions> {
474
- protected readonly securityProvider: SecurityProvider;
475
- get name(): string;
476
- protected onInit(): void;
477
- /**
478
- * Get the realm of the role.
479
- */
480
- get realm(): string | RealmDescriptor | undefined;
481
- can(permission: string | PermissionDescriptor): boolean;
482
- check(permission: string | PermissionDescriptor): SecurityCheckResult;
483
- }
484
- //#endregion
485
- //#region src/descriptors/$serviceAccount.d.ts
486
- /**
487
- * Allow to get an access token for a service account.
488
- *
489
- * You have some options to configure the service account:
490
- * - a OAUTH2 URL using client credentials grant type
491
- * - a JWT secret shared between the services
492
- *
493
- * @example
494
- * ```ts
495
- * import { $serviceAccount } from "alepha/security";
496
- *
497
- * class MyService {
498
- * serviceAccount = $serviceAccount({
499
- * oauth2: {
500
- * url: "https://example.com/oauth2/token",
501
- * clientId: "your-client-id",
502
- * clientSecret: "your-client-secret",
503
- * }
504
- * });
505
- *
506
- * async fetchData() {
507
- * const token = await this.serviceAccount.token();
508
- * // or
509
- * const response = await this.serviceAccount.fetch("https://api.example.com/data");
510
- * }
511
- * }
512
- * ```
513
- */
514
- declare const $serviceAccount: (options: ServiceAccountDescriptorOptions) => ServiceAccountDescriptor;
515
- type ServiceAccountDescriptorOptions = {
516
- gracePeriod?: number;
517
- } & ({
518
- oauth2: Oauth2ServiceAccountDescriptorOptions;
519
- } | {
520
- realm: RealmDescriptor;
521
- user: UserAccount;
522
- });
523
- interface Oauth2ServiceAccountDescriptorOptions {
524
- /**
525
- * Get Token URL.
526
- */
527
- url: string;
528
- /**
529
- * Client ID.
530
- */
531
- clientId: string;
532
- /**
533
- * Client Secret.
534
- */
535
- clientSecret: string;
536
- }
537
- interface ServiceAccountDescriptor {
538
- token: () => Promise<string>;
539
- }
540
- interface ServiceAccountStore {
541
- response?: AccessTokenResponse;
542
- }
543
- //#endregion
544
- //#region src/errors/InvalidPermissionError.d.ts
545
- declare class InvalidPermissionError extends Error {
546
- constructor(name: string);
547
- }
548
- //#endregion
549
- //#region src/errors/SecurityError.d.ts
550
- declare class SecurityError extends Error {
551
- name: string;
552
- readonly status = 403;
553
- }
554
- //#endregion
555
- //#region src/providers/CryptoProvider.d.ts
556
- declare class CryptoProvider {
557
- hashPassword(password: string): Promise<string>;
558
- verifyPassword(password: string, stored: string): Promise<boolean>;
559
- randomUUID(): string;
560
- }
561
- //#endregion
562
- //#region src/index.d.ts
563
- declare module "alepha" {
564
- interface Hooks {
565
- "security:user:created": {
566
- realm: string;
567
- user: UserAccount;
568
- };
569
- }
570
- }
571
- /**
572
- * Provides comprehensive authentication and authorization capabilities with JWT tokens, role-based access control, and user management.
573
- *
574
- * The security module enables building secure applications using descriptors like `$realm`, `$role`, and `$permission`
575
- * on class properties. It offers JWT-based authentication, fine-grained permissions, service accounts, and seamless
576
- * integration with various authentication providers and user management systems.
577
- *
578
- * @see {@link $realm}
579
- * @see {@link $role}
580
- * @see {@link $permission}
581
- * @module alepha.security
582
- */
583
- declare const AlephaSecurity: _alepha_core1.Service<_alepha_core1.Module>;
584
- //#endregion
585
- export { $permission, $realm, $role, $serviceAccount, AccessTokenResponse, AlephaSecurity, CreateTokenOptions, CryptoProvider, DEFAULT_APP_SECRET, ExtendedJWTPayload, InvalidPermissionError, JwtParseResult, JwtProvider, JwtSignOptions, KeyLoader, KeyLoaderHolder, Oauth2ServiceAccountDescriptorOptions, Permission, PermissionDescriptor, PermissionDescriptorOptions, Realm, RealmDescriptor, RealmDescriptorOptions, RealmExternal, RealmInternal, RealmSettings, Role, RoleDescriptor, RoleDescriptorOptions, SecurityCheckResult, SecurityError, SecurityProvider, ServiceAccountDescriptor, ServiceAccountDescriptorOptions, ServiceAccountStore, UserAccount, UserAccountToken, permissionSchema, roleSchema, userAccountInfoSchema };
586
- //# sourceMappingURL=index.d.ts.map
package/security.js DELETED
@@ -1 +0,0 @@
1
- export * from '@alepha/security'
package/server/cache.cjs DELETED
@@ -1,8 +0,0 @@
1
- 'use strict';
2
- var m = require('@alepha/server-cache');
3
- Object.keys(m).forEach(function (k) {
4
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
5
- enumerable: true,
6
- get: function () { return m[k]; }
7
- });
8
- });