@twin.org/api-auth-entity-storage-service 0.0.3-next.2 → 0.0.3-next.21
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/README.md +2 -2
- package/dist/es/entities/authenticationUser.js +9 -1
- package/dist/es/entities/authenticationUser.js.map +1 -1
- package/dist/es/index.js +1 -1
- package/dist/es/index.js.map +1 -1
- package/dist/es/processors/authHeaderProcessor.js +23 -9
- package/dist/es/processors/authHeaderProcessor.js.map +1 -1
- package/dist/es/restEntryPoints.js +7 -0
- package/dist/es/restEntryPoints.js.map +1 -1
- package/dist/es/routes/entityStorageAuthenticationAdminRoutes.js +362 -0
- package/dist/es/routes/entityStorageAuthenticationAdminRoutes.js.map +1 -0
- package/dist/es/routes/entityStorageAuthenticationRoutes.js +12 -12
- package/dist/es/routes/entityStorageAuthenticationRoutes.js.map +1 -1
- package/dist/es/services/entityStorageAuthenticationAdminService.js +110 -41
- package/dist/es/services/entityStorageAuthenticationAdminService.js.map +1 -1
- package/dist/es/services/entityStorageAuthenticationService.js +21 -10
- package/dist/es/services/entityStorageAuthenticationService.js.map +1 -1
- package/dist/es/utils/tokenHelper.js +25 -18
- package/dist/es/utils/tokenHelper.js.map +1 -1
- package/dist/types/entities/authenticationUser.d.ts +4 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/routes/entityStorageAuthenticationAdminRoutes.d.ts +61 -0
- package/dist/types/services/entityStorageAuthenticationAdminService.d.ts +21 -6
- package/dist/types/services/entityStorageAuthenticationService.d.ts +2 -3
- package/dist/types/utils/tokenHelper.d.ts +5 -2
- package/docs/changelog.md +338 -1
- package/docs/examples.md +88 -1
- package/docs/reference/classes/AuthenticationUser.md +8 -0
- package/docs/reference/classes/EntityStorageAuthenticationAdminService.md +73 -13
- package/docs/reference/classes/EntityStorageAuthenticationService.md +3 -9
- package/docs/reference/classes/TokenHelper.md +20 -2
- package/docs/reference/functions/authenticationAdminCreateUser.md +31 -0
- package/docs/reference/functions/authenticationAdminGetUser.md +31 -0
- package/docs/reference/functions/authenticationAdminGetUserByIdentity.md +31 -0
- package/docs/reference/functions/authenticationAdminRemoveUser.md +31 -0
- package/docs/reference/functions/authenticationAdminUpdateUser.md +31 -0
- package/docs/reference/functions/authenticationAdminUpdateUserPassword.md +31 -0
- package/docs/reference/functions/generateRestRoutesAuthenticationAdmin.md +25 -0
- package/docs/reference/index.md +8 -1
- package/docs/reference/interfaces/IAuthHeaderProcessorConfig.md +0 -12
- package/docs/reference/interfaces/IAuthHeaderProcessorConstructorOptions.md +0 -6
- package/docs/reference/interfaces/IEntityStorageAuthenticationAdminServiceConfig.md +0 -6
- package/docs/reference/interfaces/IEntityStorageAuthenticationAdminServiceConstructorOptions.md +0 -6
- package/docs/reference/interfaces/IEntityStorageAuthenticationServiceConfig.md +0 -12
- package/docs/reference/interfaces/IEntityStorageAuthenticationServiceConstructorOptions.md +0 -18
- package/docs/reference/variables/tagsAuthenticationAdmin.md +5 -0
- package/locales/en.json +7 -2
- package/package.json +5 -5
- package/dist/es/utils/passwordHelper.js +0 -29
- package/dist/es/utils/passwordHelper.js.map +0 -1
- package/dist/types/utils/passwordHelper.d.ts +0 -16
- package/docs/reference/classes/PasswordHelper.md +0 -49
package/locales/en.json
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
"entityStorageAuthenticationAdminService": {
|
|
9
9
|
"userExists": "The user with the specified e-mail already exists",
|
|
10
10
|
"createUserFailed": "Creating the user failed",
|
|
11
|
+
"getUserFailed": "Getting the user failed",
|
|
12
|
+
"updateUserFailed": "Updating the user failed",
|
|
11
13
|
"removeUserFailed": "Removing the user failed",
|
|
12
14
|
"updatePasswordFailed": "Updating the user's password failed",
|
|
13
|
-
"passwordTooShort": "The password is too short, it must be at least {minLength} characters long",
|
|
14
15
|
"userNotFound": "The user with the specified e-mail could not be found \"{notFoundId}\"",
|
|
15
16
|
"currentPasswordMismatch": "The current password is incorrect"
|
|
16
17
|
},
|
|
@@ -18,7 +19,11 @@
|
|
|
18
19
|
"missing": "The JSON Web token could not be found in the authorization header",
|
|
19
20
|
"payloadMissingSubject": "The JSON Web token payload does not contain a subject",
|
|
20
21
|
"payloadMissingOrganization": "The JSON Web token payload does not contain an organization",
|
|
21
|
-
"expired": "The JSON Web token has expired"
|
|
22
|
+
"expired": "The JSON Web token has expired",
|
|
23
|
+
"insufficientScopes": "The JSON Web token does not have the required scopes to access this resource"
|
|
24
|
+
},
|
|
25
|
+
"authHeaderProcessor": {
|
|
26
|
+
"tenantIdMismatch": "The tenant ID in the token does not match the tenant ID in the context"
|
|
22
27
|
}
|
|
23
28
|
}
|
|
24
29
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/api-auth-entity-storage-service",
|
|
3
|
-
"version": "0.0.3-next.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.3-next.21",
|
|
4
|
+
"description": "Authentication service implementation and REST routes backed by entity storage.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/twinfoundation/api.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.
|
|
18
|
-
"@twin.org/api-core": "0.0.3-next.
|
|
19
|
-
"@twin.org/api-models": "0.0.3-next.
|
|
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",
|
|
20
20
|
"@twin.org/context": "next",
|
|
21
21
|
"@twin.org/core": "next",
|
|
22
22
|
"@twin.org/crypto": "next",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 IOTA Stiftung.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
-
import { Converter, Guards } from "@twin.org/core";
|
|
4
|
-
import { Blake2b } from "@twin.org/crypto";
|
|
5
|
-
/**
|
|
6
|
-
* Helper class for password operations.
|
|
7
|
-
*/
|
|
8
|
-
export class PasswordHelper {
|
|
9
|
-
/**
|
|
10
|
-
* Runtime name for the class.
|
|
11
|
-
*/
|
|
12
|
-
static CLASS_NAME = "PasswordHelper";
|
|
13
|
-
/**
|
|
14
|
-
* Hash the password for the user.
|
|
15
|
-
* @param passwordBytes The password bytes.
|
|
16
|
-
* @param saltBytes The salt bytes.
|
|
17
|
-
* @returns The hashed password.
|
|
18
|
-
*/
|
|
19
|
-
static async hashPassword(passwordBytes, saltBytes) {
|
|
20
|
-
Guards.uint8Array(PasswordHelper.CLASS_NAME, "passwordBytes", passwordBytes);
|
|
21
|
-
Guards.uint8Array(PasswordHelper.CLASS_NAME, "saltBytes", saltBytes);
|
|
22
|
-
const combined = new Uint8Array(saltBytes.length + passwordBytes.length);
|
|
23
|
-
combined.set(saltBytes);
|
|
24
|
-
combined.set(passwordBytes, saltBytes.length);
|
|
25
|
-
const hashedPassword = Blake2b.sum256(combined);
|
|
26
|
-
return Converter.bytesToBase64(hashedPassword);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=passwordHelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"passwordHelper.js","sourceRoot":"","sources":["../../../src/utils/passwordHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG3C;;GAEG;AACH,MAAM,OAAO,cAAc;IAC1B;;OAEG;IACI,MAAM,CAAU,UAAU,oBAAoC;IAErE;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,YAAY,CAC/B,aAAyB,EACzB,SAAqB;QAErB,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,UAAU,mBAAyB,aAAa,CAAC,CAAC;QACnF,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,UAAU,eAAqB,SAAS,CAAC,CAAC;QAE3E,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QACzE,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxB,QAAQ,CAAC,GAAG,CAAC,aAAa,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QAE9C,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAEhD,OAAO,SAAS,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAChD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, Guards } from \"@twin.org/core\";\nimport { Blake2b } from \"@twin.org/crypto\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Helper class for password operations.\n */\nexport class PasswordHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<PasswordHelper>();\n\n\t/**\n\t * Hash the password for the user.\n\t * @param passwordBytes The password bytes.\n\t * @param saltBytes The salt bytes.\n\t * @returns The hashed password.\n\t */\n\tpublic static async hashPassword(\n\t\tpasswordBytes: Uint8Array,\n\t\tsaltBytes: Uint8Array\n\t): Promise<string> {\n\t\tGuards.uint8Array(PasswordHelper.CLASS_NAME, nameof(passwordBytes), passwordBytes);\n\t\tGuards.uint8Array(PasswordHelper.CLASS_NAME, nameof(saltBytes), saltBytes);\n\n\t\tconst combined = new Uint8Array(saltBytes.length + passwordBytes.length);\n\t\tcombined.set(saltBytes);\n\t\tcombined.set(passwordBytes, saltBytes.length);\n\n\t\tconst hashedPassword = Blake2b.sum256(combined);\n\n\t\treturn Converter.bytesToBase64(hashedPassword);\n\t}\n}\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper class for password operations.
|
|
3
|
-
*/
|
|
4
|
-
export declare class PasswordHelper {
|
|
5
|
-
/**
|
|
6
|
-
* Runtime name for the class.
|
|
7
|
-
*/
|
|
8
|
-
static readonly CLASS_NAME: string;
|
|
9
|
-
/**
|
|
10
|
-
* Hash the password for the user.
|
|
11
|
-
* @param passwordBytes The password bytes.
|
|
12
|
-
* @param saltBytes The salt bytes.
|
|
13
|
-
* @returns The hashed password.
|
|
14
|
-
*/
|
|
15
|
-
static hashPassword(passwordBytes: Uint8Array, saltBytes: Uint8Array): Promise<string>;
|
|
16
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# Class: PasswordHelper
|
|
2
|
-
|
|
3
|
-
Helper class for password operations.
|
|
4
|
-
|
|
5
|
-
## Constructors
|
|
6
|
-
|
|
7
|
-
### Constructor
|
|
8
|
-
|
|
9
|
-
> **new PasswordHelper**(): `PasswordHelper`
|
|
10
|
-
|
|
11
|
-
#### Returns
|
|
12
|
-
|
|
13
|
-
`PasswordHelper`
|
|
14
|
-
|
|
15
|
-
## Properties
|
|
16
|
-
|
|
17
|
-
### CLASS\_NAME
|
|
18
|
-
|
|
19
|
-
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
20
|
-
|
|
21
|
-
Runtime name for the class.
|
|
22
|
-
|
|
23
|
-
## Methods
|
|
24
|
-
|
|
25
|
-
### hashPassword()
|
|
26
|
-
|
|
27
|
-
> `static` **hashPassword**(`passwordBytes`, `saltBytes`): `Promise`\<`string`\>
|
|
28
|
-
|
|
29
|
-
Hash the password for the user.
|
|
30
|
-
|
|
31
|
-
#### Parameters
|
|
32
|
-
|
|
33
|
-
##### passwordBytes
|
|
34
|
-
|
|
35
|
-
`Uint8Array`
|
|
36
|
-
|
|
37
|
-
The password bytes.
|
|
38
|
-
|
|
39
|
-
##### saltBytes
|
|
40
|
-
|
|
41
|
-
`Uint8Array`
|
|
42
|
-
|
|
43
|
-
The salt bytes.
|
|
44
|
-
|
|
45
|
-
#### Returns
|
|
46
|
-
|
|
47
|
-
`Promise`\<`string`\>
|
|
48
|
-
|
|
49
|
-
The hashed password.
|