@twin.org/api-auth-entity-storage-service 0.0.3-next.21 → 0.0.3-next.23

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 (80) hide show
  1. package/dist/es/entities/authenticationAuditEntry.js +101 -0
  2. package/dist/es/entities/authenticationAuditEntry.js.map +1 -0
  3. package/dist/es/entities/authenticationRateEntry.js +37 -0
  4. package/dist/es/entities/authenticationRateEntry.js.map +1 -0
  5. package/dist/es/index.js +9 -0
  6. package/dist/es/index.js.map +1 -1
  7. package/dist/es/models/IAuthHeaderProcessorConstructorOptions.js.map +1 -1
  8. package/dist/es/models/IEntityStorageAuthenticationAdminServiceConstructorOptions.js.map +1 -1
  9. package/dist/es/models/IEntityStorageAuthenticationAuditServiceConfig.js +4 -0
  10. package/dist/es/models/IEntityStorageAuthenticationAuditServiceConfig.js.map +1 -0
  11. package/dist/es/models/IEntityStorageAuthenticationAuditServiceConstructorOptions.js +2 -0
  12. package/dist/es/models/IEntityStorageAuthenticationAuditServiceConstructorOptions.js.map +1 -0
  13. package/dist/es/models/IEntityStorageAuthenticationRateServiceConfig.js +2 -0
  14. package/dist/es/models/IEntityStorageAuthenticationRateServiceConfig.js.map +1 -0
  15. package/dist/es/models/IEntityStorageAuthenticationRateServiceConstructorOptions.js +2 -0
  16. package/dist/es/models/IEntityStorageAuthenticationRateServiceConstructorOptions.js.map +1 -0
  17. package/dist/es/models/IEntityStorageAuthenticationServiceConfig.js +0 -2
  18. package/dist/es/models/IEntityStorageAuthenticationServiceConfig.js.map +1 -1
  19. package/dist/es/models/IEntityStorageAuthenticationServiceConstructorOptions.js.map +1 -1
  20. package/dist/es/processors/authHeaderProcessor.js +18 -4
  21. package/dist/es/processors/authHeaderProcessor.js.map +1 -1
  22. package/dist/es/restEntryPoints.js +7 -0
  23. package/dist/es/restEntryPoints.js.map +1 -1
  24. package/dist/es/routes/entityStorageAuthenticationAuditRoutes.js +174 -0
  25. package/dist/es/routes/entityStorageAuthenticationAuditRoutes.js.map +1 -0
  26. package/dist/es/schema.js +4 -0
  27. package/dist/es/schema.js.map +1 -1
  28. package/dist/es/services/entityStorageAuthenticationAdminService.js +59 -4
  29. package/dist/es/services/entityStorageAuthenticationAdminService.js.map +1 -1
  30. package/dist/es/services/entityStorageAuthenticationAuditService.js +178 -0
  31. package/dist/es/services/entityStorageAuthenticationAuditService.js.map +1 -0
  32. package/dist/es/services/entityStorageAuthenticationRateService.js +202 -0
  33. package/dist/es/services/entityStorageAuthenticationRateService.js.map +1 -0
  34. package/dist/es/services/entityStorageAuthenticationService.js +152 -8
  35. package/dist/es/services/entityStorageAuthenticationService.js.map +1 -1
  36. package/dist/es/utils/tokenHelper.js +11 -1
  37. package/dist/es/utils/tokenHelper.js.map +1 -1
  38. package/dist/types/entities/authenticationAuditEntry.d.ts +49 -0
  39. package/dist/types/entities/authenticationRateEntry.d.ts +17 -0
  40. package/dist/types/index.d.ts +9 -0
  41. package/dist/types/models/IAuthHeaderProcessorConstructorOptions.d.ts +5 -0
  42. package/dist/types/models/IEntityStorageAuthenticationAdminServiceConstructorOptions.d.ts +5 -0
  43. package/dist/types/models/IEntityStorageAuthenticationAuditServiceConfig.d.ts +9 -0
  44. package/dist/types/models/IEntityStorageAuthenticationAuditServiceConstructorOptions.d.ts +15 -0
  45. package/dist/types/models/IEntityStorageAuthenticationRateServiceConfig.d.ts +10 -0
  46. package/dist/types/models/IEntityStorageAuthenticationRateServiceConstructorOptions.d.ts +20 -0
  47. package/dist/types/models/IEntityStorageAuthenticationServiceConfig.d.ts +17 -1
  48. package/dist/types/models/IEntityStorageAuthenticationServiceConstructorOptions.d.ts +10 -0
  49. package/dist/types/routes/entityStorageAuthenticationAuditRoutes.d.ts +29 -0
  50. package/dist/types/services/entityStorageAuthenticationAuditService.d.ts +59 -0
  51. package/dist/types/services/entityStorageAuthenticationRateService.d.ts +60 -0
  52. package/dist/types/services/entityStorageAuthenticationService.d.ts +6 -0
  53. package/dist/types/utils/tokenHelper.d.ts +2 -1
  54. package/docs/changelog.md +32 -0
  55. package/docs/reference/classes/AuthHeaderProcessor.md +9 -9
  56. package/docs/reference/classes/AuthenticationAuditEntry.md +101 -0
  57. package/docs/reference/classes/AuthenticationRateEntry.md +37 -0
  58. package/docs/reference/classes/AuthenticationUser.md +6 -6
  59. package/docs/reference/classes/EntityStorageAuthenticationAdminService.md +12 -12
  60. package/docs/reference/classes/EntityStorageAuthenticationAuditService.md +157 -0
  61. package/docs/reference/classes/EntityStorageAuthenticationRateService.md +227 -0
  62. package/docs/reference/classes/EntityStorageAuthenticationService.md +33 -7
  63. package/docs/reference/classes/TokenHelper.md +17 -11
  64. package/docs/reference/functions/authenticationAuditCreate.md +31 -0
  65. package/docs/reference/functions/authenticationAuditQuery.md +31 -0
  66. package/docs/reference/functions/generateRestRoutesAuthenticationAudit.md +25 -0
  67. package/docs/reference/index.md +12 -0
  68. package/docs/reference/interfaces/IAuthHeaderProcessorConfig.md +16 -4
  69. package/docs/reference/interfaces/IAuthHeaderProcessorConstructorOptions.md +24 -4
  70. package/docs/reference/interfaces/IEntityStorageAuthenticationAdminServiceConfig.md +8 -2
  71. package/docs/reference/interfaces/IEntityStorageAuthenticationAdminServiceConstructorOptions.md +24 -4
  72. package/docs/reference/interfaces/IEntityStorageAuthenticationAuditServiceConfig.md +11 -0
  73. package/docs/reference/interfaces/IEntityStorageAuthenticationAuditServiceConstructorOptions.md +25 -0
  74. package/docs/reference/interfaces/IEntityStorageAuthenticationRateServiceConfig.md +17 -0
  75. package/docs/reference/interfaces/IEntityStorageAuthenticationRateServiceConstructorOptions.md +39 -0
  76. package/docs/reference/interfaces/IEntityStorageAuthenticationServiceConfig.md +58 -4
  77. package/docs/reference/interfaces/IEntityStorageAuthenticationServiceConstructorOptions.md +54 -8
  78. package/docs/reference/variables/tagsAuthenticationAudit.md +5 -0
  79. package/locales/en.json +10 -1
  80. package/package.json +5 -4
@@ -4,16 +4,36 @@ Options for the AuthHeaderProcessor constructor.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### vaultConnectorType?
7
+ ### authenticationAdminServiceType? {#authenticationadminservicetype}
8
8
 
9
- > `optional` **vaultConnectorType**: `string`
9
+ > `optional` **authenticationAdminServiceType?**: `string`
10
+
11
+ The admin service.
12
+
13
+ #### Default
14
+
15
+ ```ts
16
+ authentication-admin
17
+ ```
18
+
19
+ ***
20
+
21
+ ### vaultConnectorType? {#vaultconnectortype}
22
+
23
+ > `optional` **vaultConnectorType?**: `string`
10
24
 
11
25
  The vault for the private keys.
12
26
 
27
+ #### Default
28
+
29
+ ```ts
30
+ vault
31
+ ```
32
+
13
33
  ***
14
34
 
15
- ### config?
35
+ ### config? {#config}
16
36
 
17
- > `optional` **config**: [`IAuthHeaderProcessorConfig`](IAuthHeaderProcessorConfig.md)
37
+ > `optional` **config?**: [`IAuthHeaderProcessorConfig`](IAuthHeaderProcessorConfig.md)
18
38
 
19
39
  The configuration for the processor.
@@ -4,8 +4,14 @@ Configuration for the entity storage authentication admin service.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### minPasswordLength?
7
+ ### minPasswordLength? {#minpasswordlength}
8
8
 
9
- > `optional` **minPasswordLength**: `number`
9
+ > `optional` **minPasswordLength?**: `number`
10
10
 
11
11
  The minimum password length.
12
+
13
+ #### Default
14
+
15
+ ```ts
16
+ 8
17
+ ```
@@ -4,16 +4,36 @@ Options for the EntityStorageAuthenticationAdminService constructor.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### userEntityStorageType?
7
+ ### userEntityStorageType? {#userentitystoragetype}
8
8
 
9
- > `optional` **userEntityStorageType**: `string`
9
+ > `optional` **userEntityStorageType?**: `string`
10
10
 
11
11
  The entity storage for the users.
12
12
 
13
+ #### Default
14
+
15
+ ```ts
16
+ authentication-user
17
+ ```
18
+
19
+ ***
20
+
21
+ ### authenticationAuditServiceType? {#authenticationauditservicetype}
22
+
23
+ > `optional` **authenticationAuditServiceType?**: `string`
24
+
25
+ The audit service.
26
+
27
+ #### Default
28
+
29
+ ```ts
30
+ authentication-audit
31
+ ```
32
+
13
33
  ***
14
34
 
15
- ### config?
35
+ ### config? {#config}
16
36
 
17
- > `optional` **config**: [`IEntityStorageAuthenticationAdminServiceConfig`](IEntityStorageAuthenticationAdminServiceConfig.md)
37
+ > `optional` **config?**: [`IEntityStorageAuthenticationAdminServiceConfig`](IEntityStorageAuthenticationAdminServiceConfig.md)
18
38
 
19
39
  The configuration for the authentication.
@@ -0,0 +1,11 @@
1
+ # Interface: IEntityStorageAuthenticationAuditServiceConfig
2
+
3
+ Config for the EntityStorageAuthenticationAuditService constructor.
4
+
5
+ ## Properties
6
+
7
+ ### ipHashSalt? {#iphashsalt}
8
+
9
+ > `optional` **ipHashSalt?**: `string`
10
+
11
+ The server-side salt for hashing IP addresses in audit logs, if configured.
@@ -0,0 +1,25 @@
1
+ # Interface: IEntityStorageAuthenticationAuditServiceConstructorOptions
2
+
3
+ Options for the EntityStorageAuthenticationAuditService constructor.
4
+
5
+ ## Properties
6
+
7
+ ### authenticationAuditEntryStorageType? {#authenticationauditentrystoragetype}
8
+
9
+ > `optional` **authenticationAuditEntryStorageType?**: `string`
10
+
11
+ The entity storage for the audit entries.
12
+
13
+ #### Default
14
+
15
+ ```ts
16
+ authentication-audit-entry
17
+ ```
18
+
19
+ ***
20
+
21
+ ### config? {#config}
22
+
23
+ > `optional` **config?**: [`IEntityStorageAuthenticationAuditServiceConfig`](IEntityStorageAuthenticationAuditServiceConfig.md)
24
+
25
+ The configuration for the authentication audit service.
@@ -0,0 +1,17 @@
1
+ # Interface: IEntityStorageAuthenticationRateServiceConfig
2
+
3
+ Configuration for the entity storage authentication rate service.
4
+
5
+ ## Properties
6
+
7
+ ### cleanupIntervalMinutes? {#cleanupintervalminutes}
8
+
9
+ > `optional` **cleanupIntervalMinutes?**: `number`
10
+
11
+ Interval between cleanup runs in minutes.
12
+
13
+ #### Default
14
+
15
+ ```ts
16
+ 5
17
+ ```
@@ -0,0 +1,39 @@
1
+ # Interface: IEntityStorageAuthenticationRateServiceConstructorOptions
2
+
3
+ Options for the EntityStorageAuthenticationRateService constructor.
4
+
5
+ ## Properties
6
+
7
+ ### authenticationRateEntryStorageType? {#authenticationrateentrystoragetype}
8
+
9
+ > `optional` **authenticationRateEntryStorageType?**: `string`
10
+
11
+ The entity storage for authentication rate entries.
12
+
13
+ #### Default
14
+
15
+ ```ts
16
+ authentication-rate-entry
17
+ ```
18
+
19
+ ***
20
+
21
+ ### taskSchedulerComponentType? {#taskschedulercomponenttype}
22
+
23
+ > `optional` **taskSchedulerComponentType?**: `string`
24
+
25
+ The task scheduler component type.
26
+
27
+ #### Default
28
+
29
+ ```ts
30
+ task-scheduler
31
+ ```
32
+
33
+ ***
34
+
35
+ ### config? {#config}
36
+
37
+ > `optional` **config?**: [`IEntityStorageAuthenticationRateServiceConfig`](IEntityStorageAuthenticationRateServiceConfig.md)
38
+
39
+ The configuration for the authentication rate service.
@@ -4,16 +4,70 @@ Configuration for the entity storage authentication service.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### signingKeyName?
7
+ ### signingKeyName? {#signingkeyname}
8
8
 
9
- > `optional` **signingKeyName**: `string`
9
+ > `optional` **signingKeyName?**: `string`
10
10
 
11
11
  The name of the key to retrieve from the vault for signing JWT.
12
12
 
13
+ #### Default
14
+
15
+ ```ts
16
+ auth-signing
17
+ ```
18
+
13
19
  ***
14
20
 
15
- ### defaultTtlMinutes?
21
+ ### defaultTtlMinutes? {#defaultttlminutes}
16
22
 
17
- > `optional` **defaultTtlMinutes**: `number`
23
+ > `optional` **defaultTtlMinutes?**: `number`
18
24
 
19
25
  The default time to live for the JWT.
26
+
27
+ #### Default
28
+
29
+ ```ts
30
+ 60
31
+ ```
32
+
33
+ ***
34
+
35
+ ### loginRateLimit? {#loginratelimit}
36
+
37
+ > `optional` **loginRateLimit?**: `IAuthenticationRateActionConfig`
38
+
39
+ Optional override for login failure rate limit.
40
+
41
+ #### Default
42
+
43
+ ```ts
44
+ { maxAttempts: 5, windowMinutes: 15 }
45
+ ```
46
+
47
+ ***
48
+
49
+ ### passwordChangeRateLimit? {#passwordchangeratelimit}
50
+
51
+ > `optional` **passwordChangeRateLimit?**: `IAuthenticationRateActionConfig`
52
+
53
+ Optional override for password change rate limit.
54
+
55
+ #### Default
56
+
57
+ ```ts
58
+ { maxAttempts: 5, windowMinutes: 15 }
59
+ ```
60
+
61
+ ***
62
+
63
+ ### tokenRefreshRateLimit? {#tokenrefreshratelimit}
64
+
65
+ > `optional` **tokenRefreshRateLimit?**: `IAuthenticationRateActionConfig`
66
+
67
+ Optional override for token refresh rate limit.
68
+
69
+ #### Default
70
+
71
+ ```ts
72
+ { maxAttempts: 30, windowMinutes: 60 }
73
+ ```
@@ -4,32 +4,78 @@ Options for the EntityStorageAuthenticationService constructor.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### userEntityStorageType?
7
+ ### userEntityStorageType? {#userentitystoragetype}
8
8
 
9
- > `optional` **userEntityStorageType**: `string`
9
+ > `optional` **userEntityStorageType?**: `string`
10
10
 
11
11
  The entity storage for the users.
12
12
 
13
+ #### Default
14
+
15
+ ```ts
16
+ authentication-user
17
+ ```
18
+
13
19
  ***
14
20
 
15
- ### vaultConnectorType?
21
+ ### vaultConnectorType? {#vaultconnectortype}
16
22
 
17
- > `optional` **vaultConnectorType**: `string`
23
+ > `optional` **vaultConnectorType?**: `string`
18
24
 
19
25
  The vault for the private keys.
20
26
 
27
+ #### Default
28
+
29
+ ```ts
30
+ vault
31
+ ```
32
+
21
33
  ***
22
34
 
23
- ### authenticationAdminServiceType?
35
+ ### authenticationAdminServiceType? {#authenticationadminservicetype}
24
36
 
25
- > `optional` **authenticationAdminServiceType**: `string`
37
+ > `optional` **authenticationAdminServiceType?**: `string`
26
38
 
27
39
  The admin service.
28
40
 
41
+ #### Default
42
+
43
+ ```ts
44
+ authentication-admin
45
+ ```
46
+
47
+ ***
48
+
49
+ ### authenticationAuditServiceType? {#authenticationauditservicetype}
50
+
51
+ > `optional` **authenticationAuditServiceType?**: `string`
52
+
53
+ The audit service.
54
+
55
+ #### Default
56
+
57
+ ```ts
58
+ authentication-audit
59
+ ```
60
+
61
+ ***
62
+
63
+ ### authenticationRateServiceType? {#authenticationrateservicetype}
64
+
65
+ > `optional` **authenticationRateServiceType?**: `string`
66
+
67
+ The rate service.
68
+
69
+ #### Default
70
+
71
+ ```ts
72
+ authentication-rate
73
+ ```
74
+
29
75
  ***
30
76
 
31
- ### config?
77
+ ### config? {#config}
32
78
 
33
- > `optional` **config**: [`IEntityStorageAuthenticationServiceConfig`](IEntityStorageAuthenticationServiceConfig.md)
79
+ > `optional` **config?**: [`IEntityStorageAuthenticationServiceConfig`](IEntityStorageAuthenticationServiceConfig.md)
34
80
 
35
81
  The configuration for the authentication.
@@ -0,0 +1,5 @@
1
+ # Variable: tagsAuthenticationAudit
2
+
3
+ > `const` **tagsAuthenticationAudit**: `ITag`[]
4
+
5
+ The tag to associate with the routes.
package/locales/en.json CHANGED
@@ -15,15 +15,24 @@
15
15
  "userNotFound": "The user with the specified e-mail could not be found \"{notFoundId}\"",
16
16
  "currentPasswordMismatch": "The current password is incorrect"
17
17
  },
18
+ "entityStorageAuthenticationRateService": {
19
+ "actionConfigMissing": "No rate-limit configuration exists for action \"{action}\".",
20
+ "rateLimitExceeded": "The rate limit for action \"{action}\" has been exceeded. Retry after {retryAfterSeconds} seconds."
21
+ },
18
22
  "tokenHelper": {
19
23
  "missing": "The JSON Web token could not be found in the authorization header",
20
24
  "payloadMissingSubject": "The JSON Web token payload does not contain a subject",
21
25
  "payloadMissingOrganization": "The JSON Web token payload does not contain an organization",
22
26
  "expired": "The JSON Web token has expired",
23
- "insufficientScopes": "The JSON Web token does not have the required scopes to access this resource"
27
+ "insufficientScopes": "The JSON Web token does not have the required scopes to access this resource",
28
+ "userNotVerified": "The user associated with the JSON Web token could not be verified",
29
+ "organizationNotVerified": "The organization associated with the JSON Web token could not be verified"
24
30
  },
25
31
  "authHeaderProcessor": {
26
32
  "tenantIdMismatch": "The tenant ID in the token does not match the tenant ID in the context"
33
+ },
34
+ "validation": {
35
+ "saltEntropyTooLow": "Salt must have at least 8 unique characters for sufficient entropy."
27
36
  }
28
37
  }
29
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/api-auth-entity-storage-service",
3
- "version": "0.0.3-next.21",
3
+ "version": "0.0.3-next.23",
4
4
  "description": "Authentication service implementation and REST routes backed by entity storage.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,9 +14,10 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/api-auth-entity-storage-models": "0.0.3-next.21",
18
- "@twin.org/api-core": "0.0.3-next.21",
19
- "@twin.org/api-models": "0.0.3-next.21",
17
+ "@twin.org/api-auth-entity-storage-models": "0.0.3-next.23",
18
+ "@twin.org/api-core": "0.0.3-next.23",
19
+ "@twin.org/api-models": "0.0.3-next.23",
20
+ "@twin.org/background-task-models": "next",
20
21
  "@twin.org/context": "next",
21
22
  "@twin.org/core": "next",
22
23
  "@twin.org/crypto": "next",