@twin.org/api-auth-entity-storage-service 0.0.2-next.9 → 0.0.3-next.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.
- package/dist/es/entities/authenticationUser.js +53 -0
- package/dist/es/entities/authenticationUser.js.map +1 -0
- package/dist/es/index.js +18 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IAuthHeaderProcessorConfig.js +4 -0
- package/dist/es/models/IAuthHeaderProcessorConfig.js.map +1 -0
- package/dist/es/models/IAuthHeaderProcessorConstructorOptions.js +2 -0
- package/dist/es/models/IAuthHeaderProcessorConstructorOptions.js.map +1 -0
- package/dist/es/models/IEntityStorageAuthenticationAdminServiceConfig.js +4 -0
- package/dist/es/models/IEntityStorageAuthenticationAdminServiceConfig.js.map +1 -0
- package/dist/es/models/IEntityStorageAuthenticationAdminServiceConstructorOptions.js +2 -0
- package/dist/es/models/IEntityStorageAuthenticationAdminServiceConstructorOptions.js.map +1 -0
- package/dist/es/models/IEntityStorageAuthenticationServiceConfig.js +4 -0
- package/dist/es/models/IEntityStorageAuthenticationServiceConfig.js.map +1 -0
- package/dist/es/models/IEntityStorageAuthenticationServiceConstructorOptions.js +2 -0
- package/dist/es/models/IEntityStorageAuthenticationServiceConstructorOptions.js.map +1 -0
- package/dist/es/processors/authHeaderProcessor.js +134 -0
- package/dist/es/processors/authHeaderProcessor.js.map +1 -0
- package/dist/es/restEntryPoints.js +10 -0
- package/dist/es/restEntryPoints.js.map +1 -0
- package/dist/es/routes/entityStorageAuthenticationRoutes.js +252 -0
- package/dist/es/routes/entityStorageAuthenticationRoutes.js.map +1 -0
- package/dist/es/schema.js +11 -0
- package/dist/es/schema.js.map +1 -0
- package/dist/es/services/entityStorageAuthenticationAdminService.js +146 -0
- package/dist/es/services/entityStorageAuthenticationAdminService.js.map +1 -0
- package/dist/es/services/entityStorageAuthenticationService.js +141 -0
- package/dist/es/services/entityStorageAuthenticationService.js.map +1 -0
- package/dist/es/utils/passwordHelper.js +29 -0
- package/dist/es/utils/passwordHelper.js.map +1 -0
- package/dist/es/utils/tokenHelper.js +94 -0
- package/dist/es/utils/tokenHelper.js.map +1 -0
- package/dist/types/entities/authenticationUser.d.ts +4 -0
- package/dist/types/index.d.ts +15 -15
- package/dist/types/models/IAuthHeaderProcessorConstructorOptions.d.ts +1 -1
- package/dist/types/models/IEntityStorageAuthenticationAdminServiceConstructorOptions.d.ts +1 -1
- package/dist/types/models/IEntityStorageAuthenticationServiceConstructorOptions.d.ts +1 -1
- package/dist/types/processors/authHeaderProcessor.d.ts +14 -9
- package/dist/types/services/entityStorageAuthenticationAdminService.d.ts +10 -4
- package/dist/types/services/entityStorageAuthenticationService.d.ts +9 -5
- package/dist/types/utils/passwordHelper.d.ts +4 -0
- package/dist/types/utils/tokenHelper.d.ts +8 -2
- package/docs/changelog.md +268 -0
- package/docs/reference/classes/AuthHeaderProcessor.md +28 -20
- package/docs/reference/classes/AuthenticationUser.md +8 -0
- package/docs/reference/classes/EntityStorageAuthenticationAdminService.md +25 -5
- package/docs/reference/classes/EntityStorageAuthenticationService.md +20 -12
- package/docs/reference/classes/PasswordHelper.md +8 -0
- package/docs/reference/classes/TokenHelper.md +27 -7
- package/locales/en.json +6 -6
- package/package.json +29 -11
- package/dist/cjs/index.cjs +0 -811
- package/dist/esm/index.mjs +0 -797
|
@@ -12,11 +12,19 @@ Helper class for token operations.
|
|
|
12
12
|
|
|
13
13
|
`TokenHelper`
|
|
14
14
|
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### CLASS\_NAME
|
|
18
|
+
|
|
19
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
20
|
+
|
|
21
|
+
Runtime name for the class.
|
|
22
|
+
|
|
15
23
|
## Methods
|
|
16
24
|
|
|
17
25
|
### createToken()
|
|
18
26
|
|
|
19
|
-
> `static` **createToken**(`vaultConnector`, `signingKeyName`, `
|
|
27
|
+
> `static` **createToken**(`vaultConnector`, `signingKeyName`, `userIdentity`, `organizationIdentity`, `tenantId`, `ttlMinutes`): `Promise`\<\{ `token`: `string`; `expiry`: `number`; \}\>
|
|
20
28
|
|
|
21
29
|
Create a new token.
|
|
22
30
|
|
|
@@ -34,12 +42,24 @@ The vault connector.
|
|
|
34
42
|
|
|
35
43
|
The signing key name.
|
|
36
44
|
|
|
37
|
-
#####
|
|
45
|
+
##### userIdentity
|
|
38
46
|
|
|
39
47
|
`string`
|
|
40
48
|
|
|
41
49
|
The subject for the token.
|
|
42
50
|
|
|
51
|
+
##### organizationIdentity
|
|
52
|
+
|
|
53
|
+
The organization for the token.
|
|
54
|
+
|
|
55
|
+
`string` | `undefined`
|
|
56
|
+
|
|
57
|
+
##### tenantId
|
|
58
|
+
|
|
59
|
+
The tenant id for the token.
|
|
60
|
+
|
|
61
|
+
`string` | `undefined`
|
|
62
|
+
|
|
43
63
|
##### ttlMinutes
|
|
44
64
|
|
|
45
65
|
`number`
|
|
@@ -56,7 +76,7 @@ The new token and its expiry date.
|
|
|
56
76
|
|
|
57
77
|
### verify()
|
|
58
78
|
|
|
59
|
-
> `static` **verify**(`vaultConnector`, `signingKeyName`, `token`): `Promise`\<\{ `header`: `
|
|
79
|
+
> `static` **verify**(`vaultConnector`, `signingKeyName`, `token`): `Promise`\<\{ `header`: `JWTHeaderParameters`; `payload`: `JWTPayload`; \}\>
|
|
60
80
|
|
|
61
81
|
Verify the token.
|
|
62
82
|
|
|
@@ -78,11 +98,11 @@ The signing key name.
|
|
|
78
98
|
|
|
79
99
|
The token to verify.
|
|
80
100
|
|
|
81
|
-
`
|
|
101
|
+
`string` | `undefined`
|
|
82
102
|
|
|
83
103
|
#### Returns
|
|
84
104
|
|
|
85
|
-
`Promise`\<\{ `header`: `
|
|
105
|
+
`Promise`\<\{ `header`: `JWTHeaderParameters`; `payload`: `JWTPayload`; \}\>
|
|
86
106
|
|
|
87
107
|
The verified details.
|
|
88
108
|
|
|
@@ -94,7 +114,7 @@ UnauthorizedError if the token is missing, invalid or expired.
|
|
|
94
114
|
|
|
95
115
|
### extractTokenFromHeaders()
|
|
96
116
|
|
|
97
|
-
> `static` **extractTokenFromHeaders**(`headers?`, `cookieName?`):
|
|
117
|
+
> `static` **extractTokenFromHeaders**(`headers?`, `cookieName?`): \{ `token`: `string`; `location`: `"authorization"` \| `"cookie"`; \} \| `undefined`
|
|
98
118
|
|
|
99
119
|
Extract the auth token from the headers, either from the authorization header or the cookie header.
|
|
100
120
|
|
|
@@ -114,6 +134,6 @@ The name of the cookie to extract the token from.
|
|
|
114
134
|
|
|
115
135
|
#### Returns
|
|
116
136
|
|
|
117
|
-
|
|
137
|
+
\{ `token`: `string`; `location`: `"authorization"` \| `"cookie"`; \} \| `undefined`
|
|
118
138
|
|
|
119
139
|
The token if found.
|
package/locales/en.json
CHANGED
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
"error": {
|
|
3
3
|
"entityStorageAuthenticationService": {
|
|
4
4
|
"loginFailed": "Login failed",
|
|
5
|
-
"refreshFailed": "Refresh failed",
|
|
6
5
|
"userNotFound": "The user with the specified e-mail could not be found",
|
|
7
6
|
"passwordMismatch": "The password does not match the user's password"
|
|
8
7
|
},
|
|
9
8
|
"entityStorageAuthenticationAdminService": {
|
|
10
9
|
"userExists": "The user with the specified e-mail already exists",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
10
|
+
"createUserFailed": "Creating the user failed",
|
|
11
|
+
"removeUserFailed": "Removing the user failed",
|
|
13
12
|
"updatePasswordFailed": "Updating the user's password failed",
|
|
14
13
|
"passwordTooShort": "The password is too short, it must be at least {minLength} characters long",
|
|
15
14
|
"userNotFound": "The user with the specified e-mail could not be found \"{notFoundId}\"",
|
|
16
15
|
"currentPasswordMismatch": "The current password is incorrect"
|
|
17
16
|
},
|
|
18
|
-
"entityStorageAuthenticationProcessor": {
|
|
19
|
-
"initializeFailed": "The JSON Web token authentication processor could not be initialized"
|
|
20
|
-
},
|
|
21
17
|
"tokenHelper": {
|
|
22
18
|
"missing": "The JSON Web token could not be found in the authorization header",
|
|
23
19
|
"payloadMissingSubject": "The JSON Web token payload does not contain a subject",
|
|
20
|
+
"payloadMissingOrganization": "The JSON Web token payload does not contain an organization",
|
|
24
21
|
"expired": "The JSON Web token has expired"
|
|
22
|
+
},
|
|
23
|
+
"authHeaderProcessor": {
|
|
24
|
+
"tenantIdMismatch": "The tenant ID in the token does not match the tenant ID in the context"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
}
|
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
|
+
"version": "0.0.3-next.10",
|
|
4
4
|
"description": "Auth Entity Storage contract implementation and REST endpoint definitions",
|
|
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.
|
|
18
|
-
"@twin.org/api-core": "0.0.
|
|
19
|
-
"@twin.org/api-models": "0.0.
|
|
17
|
+
"@twin.org/api-auth-entity-storage-models": "0.0.3-next.10",
|
|
18
|
+
"@twin.org/api-core": "0.0.3-next.10",
|
|
19
|
+
"@twin.org/api-models": "0.0.3-next.10",
|
|
20
|
+
"@twin.org/context": "next",
|
|
20
21
|
"@twin.org/core": "next",
|
|
21
22
|
"@twin.org/crypto": "next",
|
|
22
23
|
"@twin.org/entity": "next",
|
|
@@ -26,21 +27,38 @@
|
|
|
26
27
|
"@twin.org/vault-models": "next",
|
|
27
28
|
"@twin.org/web": "next"
|
|
28
29
|
},
|
|
29
|
-
"main": "./dist/
|
|
30
|
-
"module": "./dist/esm/index.mjs",
|
|
30
|
+
"main": "./dist/es/index.js",
|
|
31
31
|
"types": "./dist/types/index.d.ts",
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
34
34
|
"types": "./dist/types/index.d.ts",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
35
|
+
"import": "./dist/es/index.js",
|
|
36
|
+
"default": "./dist/es/index.js"
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"files": [
|
|
40
|
-
"dist/
|
|
41
|
-
"dist/esm",
|
|
40
|
+
"dist/es",
|
|
42
41
|
"dist/types",
|
|
43
42
|
"locales",
|
|
44
43
|
"docs"
|
|
45
|
-
]
|
|
44
|
+
],
|
|
45
|
+
"keywords": [
|
|
46
|
+
"twin",
|
|
47
|
+
"trade",
|
|
48
|
+
"iota",
|
|
49
|
+
"framework",
|
|
50
|
+
"blockchain",
|
|
51
|
+
"api",
|
|
52
|
+
"entity",
|
|
53
|
+
"storage",
|
|
54
|
+
"persistence",
|
|
55
|
+
"database",
|
|
56
|
+
"service",
|
|
57
|
+
"microservice",
|
|
58
|
+
"business-logic"
|
|
59
|
+
],
|
|
60
|
+
"bugs": {
|
|
61
|
+
"url": "git+https://github.com/twinfoundation/api/issues"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://twindev.org"
|
|
46
64
|
}
|