@twin.org/api-auth-entity-storage-service 0.0.3-next.25 → 0.0.3-next.26

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.
package/docs/changelog.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.26](https://github.com/twinfoundation/api/compare/api-auth-entity-storage-service-v0.0.3-next.25...api-auth-entity-storage-service-v0.0.3-next.26) (2026-04-22)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **api-auth-entity-storage-service:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/api-auth-entity-storage-models bumped from 0.0.3-next.25 to 0.0.3-next.26
16
+ * @twin.org/api-core bumped from 0.0.3-next.25 to 0.0.3-next.26
17
+ * @twin.org/api-models bumped from 0.0.3-next.25 to 0.0.3-next.26
18
+
3
19
  ## [0.0.3-next.25](https://github.com/twinfoundation/api/compare/api-auth-entity-storage-service-v0.0.3-next.24...api-auth-entity-storage-service-v0.0.3-next.25) (2026-04-14)
4
20
 
5
21
 
package/docs/examples.md CHANGED
@@ -60,6 +60,96 @@ await authService.logout(refreshResult.token);
60
60
  console.log(refreshResult.expiry > 0); // true
61
61
  ```
62
62
 
63
+ ## EntityStorageAuthenticationRateService
64
+
65
+ ```typescript
66
+ import { EntityStorageAuthenticationRateService } from '@twin.org/api-auth-entity-storage-service';
67
+ import { BaseError, GeneralError } from '@twin.org/core';
68
+ import { TooManyRequestsError } from '@twin.org/api-models';
69
+
70
+ const rateService = new EntityStorageAuthenticationRateService({
71
+ config: {
72
+ cleanupIntervalMinutes: 5
73
+ }
74
+ });
75
+
76
+ console.log(rateService.className()); // EntityStorageAuthenticationRateService
77
+
78
+ await rateService.registerAction('login', {
79
+ maxAttempts: 3,
80
+ windowMinutes: 15
81
+ });
82
+
83
+ await rateService.start('default');
84
+
85
+ await rateService.check('login', 'alice@example.org');
86
+ await rateService.check('login', 'alice@example.org');
87
+ await rateService.check('login', 'alice@example.org');
88
+
89
+ try {
90
+ await rateService.check('login', 'alice@example.org');
91
+ } catch (error) {
92
+ if (BaseError.isErrorName(error, TooManyRequestsError.CLASS_NAME)) {
93
+ const tooMany = error as TooManyRequestsError;
94
+ console.log(tooMany.properties?.retryAfterSeconds); // 900
95
+ console.log(tooMany.properties?.nextRequestTime); // 2026-04-13T10:15:00.000Z
96
+ }
97
+ }
98
+
99
+ await rateService.clear('login', 'alice@example.org');
100
+ await rateService.unregisterAction('login');
101
+
102
+ try {
103
+ await rateService.check('login', 'alice@example.org');
104
+ } catch (error) {
105
+ if (BaseError.isErrorName(error, GeneralError.CLASS_NAME)) {
106
+ console.log((error as GeneralError).name); // GeneralError
107
+ }
108
+ }
109
+
110
+ await rateService.stop('default');
111
+ ```
112
+
113
+ ## EntityStorageAuthenticationAuditService
114
+
115
+ ```typescript
116
+ import { EntityStorageAuthenticationAuditService } from '@twin.org/api-auth-entity-storage-service';
117
+
118
+ const auditService = new EntityStorageAuthenticationAuditService({
119
+ config: {
120
+ ipHashSalt: 'StrongServerSideSaltForAuditHashing123'
121
+ }
122
+ });
123
+
124
+ console.log(auditService.className()); // EntityStorageAuthenticationAuditService
125
+
126
+ const createdAuditId = await auditService.create({
127
+ event: 'login-failure',
128
+ actorId: 'did:example:user:alice',
129
+ nodeId: 'did:example:node:eu-west-1',
130
+ organizationId: 'did:example:org:core',
131
+ tenantId: 'did:example:tenant:alpha',
132
+ data: {
133
+ reason: 'invalid-password'
134
+ }
135
+ });
136
+
137
+ const auditPage = await auditService.query(
138
+ {
139
+ actorId: 'did:example:user:alice',
140
+ event: 'login-failure',
141
+ startDate: '2026-04-01T00:00:00.000Z',
142
+ endDate: '2026-04-30T23:59:59.999Z'
143
+ },
144
+ undefined,
145
+ 50
146
+ );
147
+
148
+ console.log(createdAuditId); // 018f2f67bb9d4a0caad8386f56df85ce
149
+ console.log(auditPage.entries.length); // 1
150
+ console.log(auditPage.cursor); // eyJpZCI6IjAxOGYyZjY3YmI5ZDRhMGNhYWQ4Mzg2ZjU2ZGY4NWNlIn0=
151
+ ```
152
+
63
153
  ## AuthHeaderProcessor
64
154
 
65
155
  ```typescript
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.25",
3
+ "version": "0.0.3-next.26",
4
4
  "description": "Authentication service implementation and REST routes backed by entity storage.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,9 +14,9 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/api-auth-entity-storage-models": "0.0.3-next.25",
18
- "@twin.org/api-core": "0.0.3-next.25",
19
- "@twin.org/api-models": "0.0.3-next.25",
17
+ "@twin.org/api-auth-entity-storage-models": "0.0.3-next.26",
18
+ "@twin.org/api-core": "0.0.3-next.26",
19
+ "@twin.org/api-models": "0.0.3-next.26",
20
20
  "@twin.org/background-task-models": "next",
21
21
  "@twin.org/context": "next",
22
22
  "@twin.org/core": "next",