@twin.org/api-auth-entity-storage-service 0.0.3-next.26 → 0.0.3-next.28
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/routes/entityStorageAuthenticationRoutes.js +7 -7
- package/dist/es/routes/entityStorageAuthenticationRoutes.js.map +1 -1
- package/dist/es/services/entityStorageAuthenticationService.js +4 -2
- package/dist/es/services/entityStorageAuthenticationService.js.map +1 -1
- package/docs/changelog.md +140 -108
- package/package.json +4 -4
|
@@ -67,7 +67,7 @@ export function generateRestRoutesAuthentication(baseRouteName, componentName) {
|
|
|
67
67
|
operationId: "authenticationLogout",
|
|
68
68
|
summary: "Logout from the server",
|
|
69
69
|
tag: tagsAuthentication[0].name,
|
|
70
|
-
method: "
|
|
70
|
+
method: "POST",
|
|
71
71
|
path: `${baseRouteName}/logout`,
|
|
72
72
|
handler: async (httpRequestContext, request) => authenticationLogout(httpRequestContext, componentName, request),
|
|
73
73
|
requestType: {
|
|
@@ -77,7 +77,7 @@ export function generateRestRoutesAuthentication(baseRouteName, componentName) {
|
|
|
77
77
|
id: "logoutRequestExample",
|
|
78
78
|
description: "The request to logout from the server.",
|
|
79
79
|
request: {
|
|
80
|
-
|
|
80
|
+
body: {
|
|
81
81
|
token: "eyJhbGciOiJIU...sw5c"
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -95,7 +95,7 @@ export function generateRestRoutesAuthentication(baseRouteName, componentName) {
|
|
|
95
95
|
operationId: "authenticationRefreshToken",
|
|
96
96
|
summary: "Refresh an authentication token",
|
|
97
97
|
tag: tagsAuthentication[0].name,
|
|
98
|
-
method: "
|
|
98
|
+
method: "POST",
|
|
99
99
|
path: `${baseRouteName}/refresh`,
|
|
100
100
|
handler: async (httpRequestContext, request) => authenticationRefreshToken(httpRequestContext, componentName, request),
|
|
101
101
|
requestType: {
|
|
@@ -105,7 +105,7 @@ export function generateRestRoutesAuthentication(baseRouteName, componentName) {
|
|
|
105
105
|
id: "refreshTokenRequestExample",
|
|
106
106
|
description: "The request to refresh an auth token.",
|
|
107
107
|
request: {
|
|
108
|
-
|
|
108
|
+
body: {
|
|
109
109
|
token: "eyJhbGciOiJIU...sw5c"
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -197,7 +197,7 @@ export async function authenticationLogin(httpRequestContext, componentName, req
|
|
|
197
197
|
export async function authenticationLogout(httpRequestContext, componentName, request) {
|
|
198
198
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
199
199
|
const component = ComponentFactory.get(componentName);
|
|
200
|
-
await component.logout(request.
|
|
200
|
+
await component.logout(request.body?.token);
|
|
201
201
|
// Need to give a hint to any auth processors about the operation
|
|
202
202
|
// in case they need to manipulate the response
|
|
203
203
|
httpRequestContext.processorState.authOperation = "logout";
|
|
@@ -215,9 +215,9 @@ export async function authenticationLogout(httpRequestContext, componentName, re
|
|
|
215
215
|
export async function authenticationRefreshToken(httpRequestContext, componentName, request) {
|
|
216
216
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
217
217
|
const component = ComponentFactory.get(componentName);
|
|
218
|
-
// If the token is not in the
|
|
218
|
+
// If the token is not in the body, then maybe an auth processor has extracted it
|
|
219
219
|
// and stored it in the processor state
|
|
220
|
-
const token = request.
|
|
220
|
+
const token = request.body?.token ?? httpRequestContext.processorState.authToken;
|
|
221
221
|
const result = await component.refresh(token);
|
|
222
222
|
// Need to give a hint to any auth processors about the operation
|
|
223
223
|
// in case they need to manipulate the response
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityStorageAuthenticationRoutes.js","sourceRoot":"","sources":["../../../src/routes/entityStorageAuthenticationRoutes.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;GAEG;AACH,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAE7C;;GAEG;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,CAAC,KAAK,CAAC;IAE3D,OAAO;QACN,IAAI,EAAE;YACL,MAAM,EAAE,MAAM,CAAC,MAAM;SACrB;KACD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CACjD,kBAAuC,EACvC,aAAqB,EACrB,OAA+B;IAE/B,MAAM,CAAC,MAAM,CAAyB,aAAa,aAAmB,OAAO,CAAC,CAAC;IAC/E,MAAM,CAAC,MAAM,CAAiC,aAAa,kBAAwB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjG,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAA2B,aAAa,CAAC,CAAC;IAEhF,MAAM,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAEvF,OAAO;QACN,UAAU,EAAE,cAAc,CAAC,SAAS;KACpC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIAuthenticationComponent,\n\tILoginRequest,\n\tILoginResponse,\n\tILogoutRequest,\n\tIRefreshTokenRequest,\n\tIRefreshTokenResponse,\n\tIUpdatePasswordRequest\n} from \"@twin.org/api-auth-entity-storage-models\";\nimport type {\n\tIHttpRequestContext,\n\tINoContentResponse,\n\tIRestRoute,\n\tIRestRouteResponseOptions,\n\tITag,\n\tIUnauthorizedResponse\n} from \"@twin.org/api-models\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HttpStatusCode } from \"@twin.org/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"authenticationRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsAuthentication: ITag[] = [\n\t{\n\t\tname: \"Authentication\",\n\t\tdescription: \"Authentication endpoints for the REST server.\"\n\t}\n];\n\n/**\n * The REST routes for authentication.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesAuthentication(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst loginRoute: IRestRoute<ILoginRequest, ILoginResponse> = {\n\t\toperationId: \"authenticationLogin\",\n\t\tsummary: \"Login to the server\",\n\t\ttag: tagsAuthentication[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/login`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationLogin(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<ILoginRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"loginRequestExample\",\n\t\t\t\t\tdescription: \"The request to login to the server.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\temail: \"user@example.com\",\n\t\t\t\t\t\t\tpassword: \"MyPassword123!\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ILoginResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"loginResponseExample\",\n\t\t\t\t\t\tdescription: \"The response for the login request.\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\texpiry: 1722514341067\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IUnauthorizedResponse>()\n\t\t\t}\n\t\t],\n\t\tskipAuth: true\n\t};\n\n\tconst logoutRoute: IRestRoute<ILogoutRequest, INoContentResponse> = {\n\t\toperationId: \"authenticationLogout\",\n\t\tsummary: \"Logout from the server\",\n\t\ttag: tagsAuthentication[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/logout`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationLogout(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<ILogoutRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"logoutRequestExample\",\n\t\t\t\t\tdescription: \"The request to logout from the server.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\ttoken: \"eyJhbGciOiJIU...sw5c\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t],\n\t\tskipAuth: true\n\t};\n\n\tconst refreshTokenRoute: IRestRoute<IRefreshTokenRequest, IRefreshTokenResponse> = {\n\t\toperationId: \"authenticationRefreshToken\",\n\t\tsummary: \"Refresh an authentication token\",\n\t\ttag: tagsAuthentication[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/refresh`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationRefreshToken(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IRefreshTokenRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"refreshTokenRequestExample\",\n\t\t\t\t\tdescription: \"The request to refresh an auth token.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\ttoken: \"eyJhbGciOiJIU...sw5c\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IRefreshTokenResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"refreshTokenResponseExample\",\n\t\t\t\t\t\tdescription: \"The response for the refresh token request.\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\texpiry: 1722514341067\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IUnauthorizedResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst updatePasswordRoute: IRestRoute<IUpdatePasswordRequest, INoContentResponse> = {\n\t\toperationId: \"authenticationUpdatePassword\",\n\t\tsummary: \"Update the current user's password\",\n\t\ttag: tagsAuthentication[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/password`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationUpdatePassword(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IUpdatePasswordRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"updatePasswordRequestExample\",\n\t\t\t\t\tdescription: \"The request to update the current user's password.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tcurrentPassword: \"MyNewPassword123!\",\n\t\t\t\t\t\t\tnewPassword: \"MyNewPassword123!\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IUnauthorizedResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [loginRoute, logoutRoute, refreshTokenRoute, updatePasswordRoute];\n}\n\n/**\n * Login to the server.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function authenticationLogin(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ILoginRequest\n): Promise<ILoginResponse & IRestRouteResponseOptions> {\n\tGuards.object<ILoginRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<ILoginRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst component = ComponentFactory.get<IAuthenticationComponent>(componentName);\n\tconst result = await component.login(request.body.email, request.body.password);\n\n\t// Need to give a hint to any auth processors about the operation\n\t// in case they need to manipulate the response\n\thttpRequestContext.processorState.authOperation = \"login\";\n\thttpRequestContext.processorState.authToken = result.token;\n\n\treturn {\n\t\tbody: {\n\t\t\texpiry: result.expiry\n\t\t}\n\t};\n}\n\n/**\n * Logout from the server.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function authenticationLogout(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ILogoutRequest\n): Promise<INoContentResponse & IRestRouteResponseOptions> {\n\tGuards.object<ILogoutRequest>(ROUTES_SOURCE, nameof(request), request);\n\n\tconst component = ComponentFactory.get<IAuthenticationComponent>(componentName);\n\tawait component.logout(request.query?.token);\n\n\t// Need to give a hint to any auth processors about the operation\n\t// in case they need to manipulate the response\n\thttpRequestContext.processorState.authOperation = \"logout\";\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Refresh the login token.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function authenticationRefreshToken(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IRefreshTokenRequest\n): Promise<IRefreshTokenResponse & IRestRouteResponseOptions> {\n\tGuards.object<IRefreshTokenRequest>(ROUTES_SOURCE, nameof(request), request);\n\n\tconst component = ComponentFactory.get<IAuthenticationComponent>(componentName);\n\n\t// If the token is not in the query, then maybe an auth processor has extracted it\n\t// and stored it in the processor state\n\tconst token = request.query?.token ?? (httpRequestContext.processorState.authToken as string);\n\tconst result = await component.refresh(token);\n\n\t// Need to give a hint to any auth processors about the operation\n\t// in case they need to manipulate the response\n\thttpRequestContext.processorState.authOperation = \"refresh\";\n\thttpRequestContext.processorState.authToken = result.token;\n\n\treturn {\n\t\tbody: {\n\t\t\texpiry: result.expiry\n\t\t}\n\t};\n}\n\n/**\n * Update the user's password.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function authenticationUpdatePassword(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IUpdatePasswordRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IUpdatePasswordRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IUpdatePasswordRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst component = ComponentFactory.get<IAuthenticationComponent>(componentName);\n\n\tawait component.updatePassword(request.body.currentPassword, request.body.newPassword);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"entityStorageAuthenticationRoutes.js","sourceRoot":"","sources":["../../../src/routes/entityStorageAuthenticationRoutes.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;GAEG;AACH,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAW;IACzC;QACC,IAAI,EAAE,gBAAgB;QACtB,WAAW,EAAE,+CAA+C;KAC5D;CACD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAC/C,aAAqB,EACrB,aAAqB;IAErB,MAAM,UAAU,GAA8C;QAC7D,WAAW,EAAE,qBAAqB;QAClC,OAAO,EAAE,qBAAqB;QAC9B,GAAG,EAAE,kBAA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AC,MAAM,CAAiC,aAAa,kBAAwB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjG,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAA2B,aAAa,CAAC,CAAC;IAEhF,MAAM,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAEvF,OAAO;QACN,UAAU,EAAE,cAAc,CAAC,SAAS;KACpC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIAuthenticationComponent,\n\tILoginRequest,\n\tILoginResponse,\n\tILogoutRequest,\n\tIRefreshTokenRequest,\n\tIRefreshTokenResponse,\n\tIUpdatePasswordRequest\n} from \"@twin.org/api-auth-entity-storage-models\";\nimport type {\n\tIHttpRequestContext,\n\tINoContentResponse,\n\tIRestRoute,\n\tIRestRouteResponseOptions,\n\tITag,\n\tIUnauthorizedResponse\n} from \"@twin.org/api-models\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HttpStatusCode } from \"@twin.org/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"authenticationRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsAuthentication: ITag[] = [\n\t{\n\t\tname: \"Authentication\",\n\t\tdescription: \"Authentication endpoints for the REST server.\"\n\t}\n];\n\n/**\n * The REST routes for authentication.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesAuthentication(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst loginRoute: IRestRoute<ILoginRequest, ILoginResponse> = {\n\t\toperationId: \"authenticationLogin\",\n\t\tsummary: \"Login to the server\",\n\t\ttag: tagsAuthentication[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/login`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationLogin(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<ILoginRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"loginRequestExample\",\n\t\t\t\t\tdescription: \"The request to login to the server.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\temail: \"user@example.com\",\n\t\t\t\t\t\t\tpassword: \"MyPassword123!\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ILoginResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"loginResponseExample\",\n\t\t\t\t\t\tdescription: \"The response for the login request.\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\texpiry: 1722514341067\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IUnauthorizedResponse>()\n\t\t\t}\n\t\t],\n\t\tskipAuth: true\n\t};\n\n\tconst logoutRoute: IRestRoute<ILogoutRequest, INoContentResponse> = {\n\t\toperationId: \"authenticationLogout\",\n\t\tsummary: \"Logout from the server\",\n\t\ttag: tagsAuthentication[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/logout`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationLogout(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<ILogoutRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"logoutRequestExample\",\n\t\t\t\t\tdescription: \"The request to logout from the server.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\ttoken: \"eyJhbGciOiJIU...sw5c\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t],\n\t\tskipAuth: true\n\t};\n\n\tconst refreshTokenRoute: IRestRoute<IRefreshTokenRequest, IRefreshTokenResponse> = {\n\t\toperationId: \"authenticationRefreshToken\",\n\t\tsummary: \"Refresh an authentication token\",\n\t\ttag: tagsAuthentication[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/refresh`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationRefreshToken(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IRefreshTokenRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"refreshTokenRequestExample\",\n\t\t\t\t\tdescription: \"The request to refresh an auth token.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\ttoken: \"eyJhbGciOiJIU...sw5c\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IRefreshTokenResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"refreshTokenResponseExample\",\n\t\t\t\t\t\tdescription: \"The response for the refresh token request.\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\texpiry: 1722514341067\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IUnauthorizedResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst updatePasswordRoute: IRestRoute<IUpdatePasswordRequest, INoContentResponse> = {\n\t\toperationId: \"authenticationUpdatePassword\",\n\t\tsummary: \"Update the current user's password\",\n\t\ttag: tagsAuthentication[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/password`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationUpdatePassword(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IUpdatePasswordRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"updatePasswordRequestExample\",\n\t\t\t\t\tdescription: \"The request to update the current user's password.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tcurrentPassword: \"MyNewPassword123!\",\n\t\t\t\t\t\t\tnewPassword: \"MyNewPassword123!\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IUnauthorizedResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [loginRoute, logoutRoute, refreshTokenRoute, updatePasswordRoute];\n}\n\n/**\n * Login to the server.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function authenticationLogin(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ILoginRequest\n): Promise<ILoginResponse & IRestRouteResponseOptions> {\n\tGuards.object<ILoginRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<ILoginRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst component = ComponentFactory.get<IAuthenticationComponent>(componentName);\n\tconst result = await component.login(request.body.email, request.body.password);\n\n\t// Need to give a hint to any auth processors about the operation\n\t// in case they need to manipulate the response\n\thttpRequestContext.processorState.authOperation = \"login\";\n\thttpRequestContext.processorState.authToken = result.token;\n\n\treturn {\n\t\tbody: {\n\t\t\texpiry: result.expiry\n\t\t}\n\t};\n}\n\n/**\n * Logout from the server.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function authenticationLogout(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ILogoutRequest\n): Promise<INoContentResponse & IRestRouteResponseOptions> {\n\tGuards.object<ILogoutRequest>(ROUTES_SOURCE, nameof(request), request);\n\n\tconst component = ComponentFactory.get<IAuthenticationComponent>(componentName);\n\tawait component.logout(request.body?.token);\n\n\t// Need to give a hint to any auth processors about the operation\n\t// in case they need to manipulate the response\n\thttpRequestContext.processorState.authOperation = \"logout\";\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Refresh the login token.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function authenticationRefreshToken(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IRefreshTokenRequest\n): Promise<IRefreshTokenResponse & IRestRouteResponseOptions> {\n\tGuards.object<IRefreshTokenRequest>(ROUTES_SOURCE, nameof(request), request);\n\n\tconst component = ComponentFactory.get<IAuthenticationComponent>(componentName);\n\n\t// If the token is not in the body, then maybe an auth processor has extracted it\n\t// and stored it in the processor state\n\tconst token = request.body?.token ?? (httpRequestContext.processorState.authToken as string);\n\tconst result = await component.refresh(token);\n\n\t// Need to give a hint to any auth processors about the operation\n\t// in case they need to manipulate the response\n\thttpRequestContext.processorState.authOperation = \"refresh\";\n\thttpRequestContext.processorState.authToken = result.token;\n\n\treturn {\n\t\tbody: {\n\t\t\texpiry: result.expiry\n\t\t}\n\t};\n}\n\n/**\n * Update the user's password.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function authenticationUpdatePassword(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IUpdatePasswordRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IUpdatePasswordRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IUpdatePasswordRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst component = ComponentFactory.get<IAuthenticationComponent>(componentName);\n\n\tawait component.updatePassword(request.body.currentPassword, request.body.newPassword);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n"]}
|
|
@@ -255,7 +255,7 @@ export class EntityStorageAuthenticationService {
|
|
|
255
255
|
});
|
|
256
256
|
const refreshSub = headerAndPayload.payload.sub ?? "";
|
|
257
257
|
await this._authenticationRateService.check("token-refresh", refreshSub);
|
|
258
|
-
const refreshTokenAndExpiry = await TokenHelper.createToken(this._vaultConnector, `${this._nodeId}/${this._signingKeyName}`, refreshSub, Is.stringValue(headerAndPayload.payload.org) ? headerAndPayload.payload.org : "", Is.
|
|
258
|
+
const refreshTokenAndExpiry = await TokenHelper.createToken(this._vaultConnector, `${this._nodeId}/${this._signingKeyName}`, refreshSub, Is.stringValue(headerAndPayload.payload.org) ? headerAndPayload.payload.org : "", Is.string(headerAndPayload.payload.tid) ? headerAndPayload.payload.tid : undefined, this._defaultTtlMinutes, Coerce.string(headerAndPayload.payload?.scope));
|
|
259
259
|
const refreshScope = Coerce.string(headerAndPayload.payload?.scope) ?? "";
|
|
260
260
|
await this._authenticationAuditService?.create({
|
|
261
261
|
actorId: refreshSub,
|
|
@@ -264,7 +264,9 @@ export class EntityStorageAuthenticationService {
|
|
|
264
264
|
organizationIdentity: Is.stringValue(headerAndPayload.payload.org)
|
|
265
265
|
? headerAndPayload.payload.org
|
|
266
266
|
: "",
|
|
267
|
-
tenantId: Is.
|
|
267
|
+
tenantId: Is.string(headerAndPayload.payload.tid)
|
|
268
|
+
? headerAndPayload.payload.tid
|
|
269
|
+
: undefined,
|
|
268
270
|
scope: refreshScope.split(",").filter(scope => scope.length > 0)
|
|
269
271
|
}
|
|
270
272
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityStorageAuthenticationService.js","sourceRoot":"","sources":["../../../src/services/entityStorageAuthenticationService.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EACN,MAAM,EACN,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,aAAa,EACb,iBAAiB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAwB,MAAM,wBAAwB,CAAC;AAGrF,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,kCAAkC;IAC9C;;OAEG;IACI,MAAM,CAAU,UAAU,wCAAwD;IAEzF;;;OAGG;IACK,MAAM,CAAU,oBAAoB,GAAW,EAAE,CAAC;IAE1D;;;OAGG;IACK,MAAM,CAAU,gCAAgC,GAAW,CAAC,CAAC;IAErE;;;OAGG;IACK,MAAM,CAAU,kCAAkC,GAAW,EAAE,CAAC;IAExE;;;OAGG;IACK,MAAM,CAAU,0CAA0C,GAAW,CAAC,CAAC;IAE/E;;;OAGG;IACK,MAAM,CAAU,4CAA4C,GAAW,EAAE,CAAC;IAElF;;;OAGG;IACK,MAAM,CAAU,wCAAwC,GAAW,EAAE,CAAC;IAE9E;;;OAGG;IACK,MAAM,CAAU,0CAA0C,GAAW,EA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,CAAC;aAChE;SACD,CAAC,CAAC;QAEH,OAAO,qBAAqB,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,cAAc,CAAC,eAAuB,EAAE,WAAmB;QACvE,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,aAAa,EAAE,CAAC;QACxD,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;QAEtD,MAAM,YAAY,GAAG,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;QAE7E,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACzE,IAAI,CAAC,EAAE,CAAC,MAAM,CAAqB,IAAI,CAAC,EAAE,CAAC;YAC1C,MAAM,IAAI,aAAa,CACtB,kCAAkC,CAAC,UAAU,EAC7C,cAAc,EACd,YAAY,CACZ,CAAC;QACH,CAAC;QAED,MAAM,cAAc,CAAC,cAAc,CAClC,IAAI,CAAC,kBAAkB,EACvB,IAAI,CAAC,2BAA2B,EAChC,IAAI,EACJ,WAAW,EACX,eAAe,EACf,IAAI,CAAC,kBAAkB,CACvB,CAAC;QAEF,MAAM,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;IAC9E,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIAuthenticationRateActionConfig,\n\tIAuthenticationRateComponent,\n\tIAuthenticationAuditComponent,\n\tIAuthenticationComponent\n} from \"@twin.org/api-auth-entity-storage-models\";\nimport { AuthAuditEvent } from \"@twin.org/api-auth-entity-storage-models\";\nimport { ContextIdHelper, ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport {\n\tCoerce,\n\tComponentFactory,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tNotFoundError,\n\tUnauthorizedError\n} from \"@twin.org/core\";\nimport { PasswordGenerator, PasswordValidator } from \"@twin.org/crypto\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { VaultConnectorFactory, type IVaultConnector } from \"@twin.org/vault-models\";\nimport type { AuthenticationUser } from \"../entities/authenticationUser.js\";\nimport type { IEntityStorageAuthenticationServiceConstructorOptions } from \"../models/IEntityStorageAuthenticationServiceConstructorOptions.js\";\nimport { PasswordHelper } from \"../utils/passwordHelper.js\";\nimport { TokenHelper } from \"../utils/tokenHelper.js\";\n\n/**\n * Implementation of the authentication component using entity storage.\n */\nexport class EntityStorageAuthenticationService implements IAuthenticationComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageAuthenticationService>();\n\n\t/**\n\t * Default TTL in minutes.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_TTL_MINUTES: number = 60;\n\n\t/**\n\t * Default maximum login attempts in a rate window.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_LOGIN_RATE_MAX_ATTEMPTS: number = 5;\n\n\t/**\n\t * Default login rate window in minutes.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_LOGIN_RATE_WINDOW_MINUTES: number = 15;\n\n\t/**\n\t * Default maximum password change attempts in a rate window.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_PASSWORD_CHANGE_RATE_MAX_ATTEMPTS: number = 5;\n\n\t/**\n\t * Default password change rate window in minutes.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_PASSWORD_CHANGE_RATE_WINDOW_MINUTES: number = 15;\n\n\t/**\n\t * Default maximum token refresh attempts in a rate window.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_TOKEN_REFRESH_RATE_MAX_ATTEMPTS: number = 30;\n\n\t/**\n\t * Default token refresh rate window in minutes.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_TOKEN_REFRESH_RATE_WINDOW_MINUTES: number = 60;\n\n\t/**\n\t * The audit service.\n\t * @internal\n\t */\n\tprivate readonly _authenticationAuditService?: IAuthenticationAuditComponent;\n\n\t/**\n\t * The rate service.\n\t * @internal\n\t */\n\tprivate readonly _authenticationRateService: IAuthenticationRateComponent;\n\n\t/**\n\t * The entity storage for users.\n\t * @internal\n\t */\n\tprivate readonly _userEntityStorage: IEntityStorageConnector<AuthenticationUser>;\n\n\t/**\n\t * The vault for the keys.\n\t * @internal\n\t */\n\tprivate readonly _vaultConnector: IVaultConnector;\n\n\t/**\n\t * The name of the key to retrieve from the vault for signing JWT.\n\t * @internal\n\t */\n\tprivate readonly _signingKeyName: string;\n\n\t/**\n\t * The default TTL for the token.\n\t * @internal\n\t */\n\tprivate readonly _defaultTtlMinutes: number;\n\n\t/**\n\t * The minimum password length for validation.\n\t * @internal\n\t */\n\tprivate readonly _minPasswordLength?: number;\n\n\t/**\n\t * Rate limit configuration for login failures.\n\t * @internal\n\t */\n\tprivate readonly _loginRateLimit: IAuthenticationRateActionConfig;\n\n\t/**\n\t * Rate limit configuration for password changes.\n\t * @internal\n\t */\n\tprivate readonly _passwordChangeRateLimit: IAuthenticationRateActionConfig;\n\n\t/**\n\t * Rate limit configuration for token refresh.\n\t * @internal\n\t */\n\tprivate readonly _tokenRefreshRateLimit: IAuthenticationRateActionConfig;\n\n\t/**\n\t * The node identity.\n\t * @internal\n\t */\n\tprivate _nodeId?: string;\n\n\t/**\n\t * Create a new instance of EntityStorageAuthentication.\n\t * @param options The dependencies for the identity connector.\n\t */\n\tconstructor(options?: IEntityStorageAuthenticationServiceConstructorOptions) {\n\t\tthis._userEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.userEntityStorageType ?? \"authentication-user\"\n\t\t);\n\n\t\tthis._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? \"vault\");\n\n\t\tthis._authenticationAuditService = ComponentFactory.getIfExists<IAuthenticationAuditComponent>(\n\t\t\toptions?.authenticationAuditServiceType ?? \"authentication-audit\"\n\t\t);\n\n\t\tthis._authenticationRateService = ComponentFactory.get<IAuthenticationRateComponent>(\n\t\t\toptions?.authenticationRateServiceType ?? \"authentication-rate\"\n\t\t);\n\n\t\tthis._signingKeyName = options?.config?.signingKeyName ?? \"auth-signing\";\n\t\tthis._defaultTtlMinutes =\n\t\t\toptions?.config?.defaultTtlMinutes ?? EntityStorageAuthenticationService._DEFAULT_TTL_MINUTES;\n\t\tthis._minPasswordLength = options?.config?.minPasswordLength;\n\t\tthis._loginRateLimit = {\n\t\t\tmaxAttempts:\n\t\t\t\toptions?.config?.loginRateLimit?.maxAttempts ??\n\t\t\t\tEntityStorageAuthenticationService._DEFAULT_LOGIN_RATE_MAX_ATTEMPTS,\n\t\t\twindowMinutes:\n\t\t\t\toptions?.config?.loginRateLimit?.windowMinutes ??\n\t\t\t\tEntityStorageAuthenticationService._DEFAULT_LOGIN_RATE_WINDOW_MINUTES\n\t\t};\n\t\tthis._passwordChangeRateLimit = {\n\t\t\tmaxAttempts:\n\t\t\t\toptions?.config?.passwordChangeRateLimit?.maxAttempts ??\n\t\t\t\tEntityStorageAuthenticationService._DEFAULT_PASSWORD_CHANGE_RATE_MAX_ATTEMPTS,\n\t\t\twindowMinutes:\n\t\t\t\toptions?.config?.passwordChangeRateLimit?.windowMinutes ??\n\t\t\t\tEntityStorageAuthenticationService._DEFAULT_PASSWORD_CHANGE_RATE_WINDOW_MINUTES\n\t\t};\n\t\tthis._tokenRefreshRateLimit = {\n\t\t\tmaxAttempts:\n\t\t\t\toptions?.config?.tokenRefreshRateLimit?.maxAttempts ??\n\t\t\t\tEntityStorageAuthenticationService._DEFAULT_TOKEN_REFRESH_RATE_MAX_ATTEMPTS,\n\t\t\twindowMinutes:\n\t\t\t\toptions?.config?.tokenRefreshRateLimit?.windowMinutes ??\n\t\t\t\tEntityStorageAuthenticationService._DEFAULT_TOKEN_REFRESH_RATE_WINDOW_MINUTES\n\t\t};\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageAuthenticationService.CLASS_NAME;\n\t}\n\n\t/**\n\t * The service needs to be started when the application is initialized.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns Nothing.\n\t */\n\tpublic async start(nodeLoggingComponentType?: string): Promise<void> {\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tContextIdHelper.guard(contextIds, ContextIdKeys.Node);\n\t\tthis._nodeId = contextIds[ContextIdKeys.Node];\n\n\t\tawait this._authenticationRateService.registerAction(\"login\", this._loginRateLimit);\n\t\tawait this._authenticationRateService.registerAction(\n\t\t\t\"password-change\",\n\t\t\tthis._passwordChangeRateLimit\n\t\t);\n\t\tawait this._authenticationRateService.registerAction(\n\t\t\t\"token-refresh\",\n\t\t\tthis._tokenRefreshRateLimit\n\t\t);\n\t}\n\n\t/**\n\t * The component needs to be stopped when the node is closed.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns Nothing.\n\t */\n\tpublic async stop(nodeLoggingComponentType?: string): Promise<void> {\n\t\tawait this._authenticationRateService.unregisterAction(\"login\");\n\t\tawait this._authenticationRateService.unregisterAction(\"password-change\");\n\t\tawait this._authenticationRateService.unregisterAction(\"token-refresh\");\n\t}\n\n\t/**\n\t * Perform a login for the user.\n\t * @param email The email address for the user.\n\t * @param password The password for the user.\n\t * @returns The authentication token for the user, if it uses a mechanism with public access.\n\t */\n\tpublic async login(\n\t\temail: string,\n\t\tpassword: string\n\t): Promise<{\n\t\ttoken?: string;\n\t\texpiry: number;\n\t}> {\n\t\tGuards.stringValue(EntityStorageAuthenticationService.CLASS_NAME, nameof(email), email);\n\t\tGuards.stringValue(EntityStorageAuthenticationService.CLASS_NAME, nameof(password), password);\n\n\t\tlet loginUser: AuthenticationUser | undefined;\n\t\tlet loginTenantId: string | undefined;\n\t\tlet tokenAndExpiry: { token?: string; expiry: number } | undefined;\n\n\t\ttry {\n\t\t\tawait this._authenticationRateService.check(\"login\", email);\n\n\t\t\tconst user = await this._userEntityStorage.get(email);\n\t\t\tif (!user) {\n\t\t\t\tthrow new GeneralError(EntityStorageAuthenticationService.CLASS_NAME, \"userNotFound\");\n\t\t\t}\n\n\t\t\tconst saltBytes = Converter.base64ToBytes(user.salt);\n\t\t\tconst passwordBytes = Converter.utf8ToBytes(password);\n\n\t\t\tconst hashedPassword = await PasswordGenerator.hashPassword(passwordBytes, saltBytes);\n\n\t\t\tif (!PasswordValidator.comparePasswordHashes(hashedPassword, user.password)) {\n\t\t\t\tthrow new GeneralError(EntityStorageAuthenticationService.CLASS_NAME, \"passwordMismatch\");\n\t\t\t}\n\n\t\t\t// This might be undefined if the login is performed in a single tenant context\n\t\t\t// if is verified during the token processing, tenant id will be matched against\n\t\t\t// the context\n\t\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\t\tloginTenantId = contextIds?.[ContextIdKeys.Tenant];\n\n\t\t\ttokenAndExpiry = await TokenHelper.createToken(\n\t\t\t\tthis._vaultConnector,\n\t\t\t\t`${this._nodeId}/${this._signingKeyName}`,\n\t\t\t\tuser.identity,\n\t\t\t\tuser.organization,\n\t\t\t\tloginTenantId,\n\t\t\t\tthis._defaultTtlMinutes,\n\t\t\t\tuser.scope\n\t\t\t);\n\t\t\tloginUser = user;\n\t\t} catch (error) {\n\t\t\tawait this._authenticationAuditService?.create({\n\t\t\t\tactorId: email,\n\t\t\t\tevent: AuthAuditEvent.LoginFailure\n\t\t\t});\n\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tEntityStorageAuthenticationService.CLASS_NAME,\n\t\t\t\t\"loginFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\n\t\tawait this._authenticationRateService.clear(\"login\", email);\n\n\t\tawait this._authenticationAuditService?.create({\n\t\t\tactorId: email,\n\t\t\tevent: AuthAuditEvent.LoginSuccess,\n\t\t\tdata: {\n\t\t\t\tuserIdentity: loginUser.identity,\n\t\t\t\torganizationIdentity: loginUser.organization,\n\t\t\t\ttenantId: loginTenantId,\n\t\t\t\tscope: loginUser.scope.split(\",\")\n\t\t\t}\n\t\t});\n\n\t\treturn tokenAndExpiry;\n\t}\n\n\t/**\n\t * Logout the current user.\n\t * @param token The token to logout, if it uses a mechanism with public access.\n\t * @returns Nothing.\n\t */\n\tpublic async logout(token?: string): Promise<void> {\n\t\t// Nothing to do here, as we are stateless.\n\t\t// The cookie will be revoked by the REST route handling\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst identifier = contextIds?.[ContextIdKeys.User];\n\t\tif (Is.stringValue(identifier)) {\n\t\t\tawait this._authenticationAuditService?.create({\n\t\t\t\tactorId: identifier,\n\t\t\t\tevent: AuthAuditEvent.Logout\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Refresh the token.\n\t * @param token The token to refresh, if it uses a mechanism with public access.\n\t * @returns The refreshed token, if it uses a mechanism with public access.\n\t */\n\tpublic async refresh(token?: string): Promise<{\n\t\ttoken?: string;\n\t\texpiry: number;\n\t}> {\n\t\t// If the verify fails on the current token then it will throw an exception.\n\t\tconst headerAndPayload = await TokenHelper.verify(\n\t\t\tthis._vaultConnector,\n\t\t\t`${this._nodeId}/${this._signingKeyName}`,\n\t\t\ttoken,\n\t\t\tundefined,\n\t\t\tasync (userIdentity, organizationIdentity) => {\n\t\t\t\tconst validParts = [];\n\t\t\t\tconst user = await this._userEntityStorage.get(userIdentity, \"identity\");\n\t\t\t\tif (user?.identity === userIdentity) {\n\t\t\t\t\tvalidParts.push(\"user\");\n\t\t\t\t}\n\t\t\t\tif (user?.organization === organizationIdentity) {\n\t\t\t\t\tvalidParts.push(\"organization\");\n\t\t\t\t}\n\t\t\t\treturn validParts;\n\t\t\t}\n\t\t);\n\n\t\tconst refreshSub = headerAndPayload.payload.sub ?? \"\";\n\t\tawait this._authenticationRateService.check(\"token-refresh\", refreshSub);\n\n\t\tconst refreshTokenAndExpiry = await TokenHelper.createToken(\n\t\t\tthis._vaultConnector,\n\t\t\t`${this._nodeId}/${this._signingKeyName}`,\n\t\t\trefreshSub,\n\t\t\tIs.stringValue(headerAndPayload.payload.org) ? headerAndPayload.payload.org : \"\",\n\t\t\tIs.stringValue(headerAndPayload.payload.tid) ? headerAndPayload.payload.tid : \"\",\n\t\t\tthis._defaultTtlMinutes,\n\t\t\tCoerce.string(headerAndPayload.payload?.scope)\n\t\t);\n\t\tconst refreshScope = Coerce.string(headerAndPayload.payload?.scope) ?? \"\";\n\n\t\tawait this._authenticationAuditService?.create({\n\t\t\tactorId: refreshSub,\n\t\t\tevent: AuthAuditEvent.TokenRefreshed,\n\t\t\tdata: {\n\t\t\t\torganizationIdentity: Is.stringValue(headerAndPayload.payload.org)\n\t\t\t\t\t? headerAndPayload.payload.org\n\t\t\t\t\t: \"\",\n\t\t\t\ttenantId: Is.stringValue(headerAndPayload.payload.tid) ? headerAndPayload.payload.tid : \"\",\n\t\t\t\tscope: refreshScope.split(\",\").filter(scope => scope.length > 0)\n\t\t\t}\n\t\t});\n\n\t\treturn refreshTokenAndExpiry;\n\t}\n\n\t/**\n\t * Update the user's password.\n\t * @param currentPassword The current password for the user.\n\t * @param newPassword The new password for the user.\n\t * @returns Nothing.\n\t */\n\tpublic async updatePassword(currentPassword: string, newPassword: string): Promise<void> {\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tContextIdHelper.guard(contextIds, ContextIdKeys.User);\n\n\t\tconst userIdentity = contextIds[ContextIdKeys.User];\n\t\tawait this._authenticationRateService.check(\"password-change\", userIdentity);\n\n\t\tconst user = await this._userEntityStorage.get(userIdentity, \"identity\");\n\t\tif (!Is.object<AuthenticationUser>(user)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tEntityStorageAuthenticationService.CLASS_NAME,\n\t\t\t\t\"userNotFound\",\n\t\t\t\tuserIdentity\n\t\t\t);\n\t\t}\n\n\t\tawait PasswordHelper.updatePassword(\n\t\t\tthis._userEntityStorage,\n\t\t\tthis._authenticationAuditService,\n\t\t\tuser,\n\t\t\tnewPassword,\n\t\t\tcurrentPassword,\n\t\t\tthis._minPasswordLength\n\t\t);\n\n\t\tawait this._authenticationRateService.clear(\"password-change\", userIdentity);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"entityStorageAuthenticationService.js","sourceRoot":"","sources":["../../../src/services/entityStorageAuthenticationService.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EACN,MAAM,EACN,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,aAAa,EACb,iBAAiB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAwB,MAAM,wBAAwB,CAAC;AAGrF,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,kCAAkC;IAC9C;;OAEG;IACI,MAAM,CAAU,UAAU,wCAAwD;IAEzF;;;OAGG;IACK,MAAM,CAAU,oBAAoB,GAAW,EAAE,CAAC;IAE1D;;;OAGG;IACK,MAAM,CAAU,gCAAgC,GAAW,CAAC,CAAC;IAErE;;;OAGG;IACK,MAAM,CAAU,kCAAkC,GAAW,EAAE,CAAC;IAExE;;;OAGG;IACK,MAAM,CAAU,0CAA0C,GAAW,CAAC,CAAC;IAE/E;;;OAGG;IACK,MAAM,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AC,CAAC,SAAS;gBACZ,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;aAChE;SACD,CAAC,CAAC;QAEH,OAAO,qBAAqB,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,cAAc,CAAC,eAAuB,EAAE,WAAmB;QACvE,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,aAAa,EAAE,CAAC;QACxD,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;QAEtD,MAAM,YAAY,GAAG,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;QAE7E,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACzE,IAAI,CAAC,EAAE,CAAC,MAAM,CAAqB,IAAI,CAAC,EAAE,CAAC;YAC1C,MAAM,IAAI,aAAa,CACtB,kCAAkC,CAAC,UAAU,EAC7C,cAAc,EACd,YAAY,CACZ,CAAC;QACH,CAAC;QAED,MAAM,cAAc,CAAC,cAAc,CAClC,IAAI,CAAC,kBAAkB,EACvB,IAAI,CAAC,2BAA2B,EAChC,IAAI,EACJ,WAAW,EACX,eAAe,EACf,IAAI,CAAC,kBAAkB,CACvB,CAAC;QAEF,MAAM,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;IAC9E,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIAuthenticationRateActionConfig,\n\tIAuthenticationRateComponent,\n\tIAuthenticationAuditComponent,\n\tIAuthenticationComponent\n} from \"@twin.org/api-auth-entity-storage-models\";\nimport { AuthAuditEvent } from \"@twin.org/api-auth-entity-storage-models\";\nimport { ContextIdHelper, ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport {\n\tCoerce,\n\tComponentFactory,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tNotFoundError,\n\tUnauthorizedError\n} from \"@twin.org/core\";\nimport { PasswordGenerator, PasswordValidator } from \"@twin.org/crypto\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { VaultConnectorFactory, type IVaultConnector } from \"@twin.org/vault-models\";\nimport type { AuthenticationUser } from \"../entities/authenticationUser.js\";\nimport type { IEntityStorageAuthenticationServiceConstructorOptions } from \"../models/IEntityStorageAuthenticationServiceConstructorOptions.js\";\nimport { PasswordHelper } from \"../utils/passwordHelper.js\";\nimport { TokenHelper } from \"../utils/tokenHelper.js\";\n\n/**\n * Implementation of the authentication component using entity storage.\n */\nexport class EntityStorageAuthenticationService implements IAuthenticationComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageAuthenticationService>();\n\n\t/**\n\t * Default TTL in minutes.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_TTL_MINUTES: number = 60;\n\n\t/**\n\t * Default maximum login attempts in a rate window.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_LOGIN_RATE_MAX_ATTEMPTS: number = 5;\n\n\t/**\n\t * Default login rate window in minutes.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_LOGIN_RATE_WINDOW_MINUTES: number = 15;\n\n\t/**\n\t * Default maximum password change attempts in a rate window.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_PASSWORD_CHANGE_RATE_MAX_ATTEMPTS: number = 5;\n\n\t/**\n\t * Default password change rate window in minutes.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_PASSWORD_CHANGE_RATE_WINDOW_MINUTES: number = 15;\n\n\t/**\n\t * Default maximum token refresh attempts in a rate window.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_TOKEN_REFRESH_RATE_MAX_ATTEMPTS: number = 30;\n\n\t/**\n\t * Default token refresh rate window in minutes.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_TOKEN_REFRESH_RATE_WINDOW_MINUTES: number = 60;\n\n\t/**\n\t * The audit service.\n\t * @internal\n\t */\n\tprivate readonly _authenticationAuditService?: IAuthenticationAuditComponent;\n\n\t/**\n\t * The rate service.\n\t * @internal\n\t */\n\tprivate readonly _authenticationRateService: IAuthenticationRateComponent;\n\n\t/**\n\t * The entity storage for users.\n\t * @internal\n\t */\n\tprivate readonly _userEntityStorage: IEntityStorageConnector<AuthenticationUser>;\n\n\t/**\n\t * The vault for the keys.\n\t * @internal\n\t */\n\tprivate readonly _vaultConnector: IVaultConnector;\n\n\t/**\n\t * The name of the key to retrieve from the vault for signing JWT.\n\t * @internal\n\t */\n\tprivate readonly _signingKeyName: string;\n\n\t/**\n\t * The default TTL for the token.\n\t * @internal\n\t */\n\tprivate readonly _defaultTtlMinutes: number;\n\n\t/**\n\t * The minimum password length for validation.\n\t * @internal\n\t */\n\tprivate readonly _minPasswordLength?: number;\n\n\t/**\n\t * Rate limit configuration for login failures.\n\t * @internal\n\t */\n\tprivate readonly _loginRateLimit: IAuthenticationRateActionConfig;\n\n\t/**\n\t * Rate limit configuration for password changes.\n\t * @internal\n\t */\n\tprivate readonly _passwordChangeRateLimit: IAuthenticationRateActionConfig;\n\n\t/**\n\t * Rate limit configuration for token refresh.\n\t * @internal\n\t */\n\tprivate readonly _tokenRefreshRateLimit: IAuthenticationRateActionConfig;\n\n\t/**\n\t * The node identity.\n\t * @internal\n\t */\n\tprivate _nodeId?: string;\n\n\t/**\n\t * Create a new instance of EntityStorageAuthentication.\n\t * @param options The dependencies for the identity connector.\n\t */\n\tconstructor(options?: IEntityStorageAuthenticationServiceConstructorOptions) {\n\t\tthis._userEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.userEntityStorageType ?? \"authentication-user\"\n\t\t);\n\n\t\tthis._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? \"vault\");\n\n\t\tthis._authenticationAuditService = ComponentFactory.getIfExists<IAuthenticationAuditComponent>(\n\t\t\toptions?.authenticationAuditServiceType ?? \"authentication-audit\"\n\t\t);\n\n\t\tthis._authenticationRateService = ComponentFactory.get<IAuthenticationRateComponent>(\n\t\t\toptions?.authenticationRateServiceType ?? \"authentication-rate\"\n\t\t);\n\n\t\tthis._signingKeyName = options?.config?.signingKeyName ?? \"auth-signing\";\n\t\tthis._defaultTtlMinutes =\n\t\t\toptions?.config?.defaultTtlMinutes ?? EntityStorageAuthenticationService._DEFAULT_TTL_MINUTES;\n\t\tthis._minPasswordLength = options?.config?.minPasswordLength;\n\t\tthis._loginRateLimit = {\n\t\t\tmaxAttempts:\n\t\t\t\toptions?.config?.loginRateLimit?.maxAttempts ??\n\t\t\t\tEntityStorageAuthenticationService._DEFAULT_LOGIN_RATE_MAX_ATTEMPTS,\n\t\t\twindowMinutes:\n\t\t\t\toptions?.config?.loginRateLimit?.windowMinutes ??\n\t\t\t\tEntityStorageAuthenticationService._DEFAULT_LOGIN_RATE_WINDOW_MINUTES\n\t\t};\n\t\tthis._passwordChangeRateLimit = {\n\t\t\tmaxAttempts:\n\t\t\t\toptions?.config?.passwordChangeRateLimit?.maxAttempts ??\n\t\t\t\tEntityStorageAuthenticationService._DEFAULT_PASSWORD_CHANGE_RATE_MAX_ATTEMPTS,\n\t\t\twindowMinutes:\n\t\t\t\toptions?.config?.passwordChangeRateLimit?.windowMinutes ??\n\t\t\t\tEntityStorageAuthenticationService._DEFAULT_PASSWORD_CHANGE_RATE_WINDOW_MINUTES\n\t\t};\n\t\tthis._tokenRefreshRateLimit = {\n\t\t\tmaxAttempts:\n\t\t\t\toptions?.config?.tokenRefreshRateLimit?.maxAttempts ??\n\t\t\t\tEntityStorageAuthenticationService._DEFAULT_TOKEN_REFRESH_RATE_MAX_ATTEMPTS,\n\t\t\twindowMinutes:\n\t\t\t\toptions?.config?.tokenRefreshRateLimit?.windowMinutes ??\n\t\t\t\tEntityStorageAuthenticationService._DEFAULT_TOKEN_REFRESH_RATE_WINDOW_MINUTES\n\t\t};\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageAuthenticationService.CLASS_NAME;\n\t}\n\n\t/**\n\t * The service needs to be started when the application is initialized.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns Nothing.\n\t */\n\tpublic async start(nodeLoggingComponentType?: string): Promise<void> {\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tContextIdHelper.guard(contextIds, ContextIdKeys.Node);\n\t\tthis._nodeId = contextIds[ContextIdKeys.Node];\n\n\t\tawait this._authenticationRateService.registerAction(\"login\", this._loginRateLimit);\n\t\tawait this._authenticationRateService.registerAction(\n\t\t\t\"password-change\",\n\t\t\tthis._passwordChangeRateLimit\n\t\t);\n\t\tawait this._authenticationRateService.registerAction(\n\t\t\t\"token-refresh\",\n\t\t\tthis._tokenRefreshRateLimit\n\t\t);\n\t}\n\n\t/**\n\t * The component needs to be stopped when the node is closed.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns Nothing.\n\t */\n\tpublic async stop(nodeLoggingComponentType?: string): Promise<void> {\n\t\tawait this._authenticationRateService.unregisterAction(\"login\");\n\t\tawait this._authenticationRateService.unregisterAction(\"password-change\");\n\t\tawait this._authenticationRateService.unregisterAction(\"token-refresh\");\n\t}\n\n\t/**\n\t * Perform a login for the user.\n\t * @param email The email address for the user.\n\t * @param password The password for the user.\n\t * @returns The authentication token for the user, if it uses a mechanism with public access.\n\t */\n\tpublic async login(\n\t\temail: string,\n\t\tpassword: string\n\t): Promise<{\n\t\ttoken?: string;\n\t\texpiry: number;\n\t}> {\n\t\tGuards.stringValue(EntityStorageAuthenticationService.CLASS_NAME, nameof(email), email);\n\t\tGuards.stringValue(EntityStorageAuthenticationService.CLASS_NAME, nameof(password), password);\n\n\t\tlet loginUser: AuthenticationUser | undefined;\n\t\tlet loginTenantId: string | undefined;\n\t\tlet tokenAndExpiry: { token?: string; expiry: number } | undefined;\n\n\t\ttry {\n\t\t\tawait this._authenticationRateService.check(\"login\", email);\n\n\t\t\tconst user = await this._userEntityStorage.get(email);\n\t\t\tif (!user) {\n\t\t\t\tthrow new GeneralError(EntityStorageAuthenticationService.CLASS_NAME, \"userNotFound\");\n\t\t\t}\n\n\t\t\tconst saltBytes = Converter.base64ToBytes(user.salt);\n\t\t\tconst passwordBytes = Converter.utf8ToBytes(password);\n\n\t\t\tconst hashedPassword = await PasswordGenerator.hashPassword(passwordBytes, saltBytes);\n\n\t\t\tif (!PasswordValidator.comparePasswordHashes(hashedPassword, user.password)) {\n\t\t\t\tthrow new GeneralError(EntityStorageAuthenticationService.CLASS_NAME, \"passwordMismatch\");\n\t\t\t}\n\n\t\t\t// This might be undefined if the login is performed in a single tenant context\n\t\t\t// if is verified during the token processing, tenant id will be matched against\n\t\t\t// the context\n\t\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\t\tloginTenantId = contextIds?.[ContextIdKeys.Tenant];\n\n\t\t\ttokenAndExpiry = await TokenHelper.createToken(\n\t\t\t\tthis._vaultConnector,\n\t\t\t\t`${this._nodeId}/${this._signingKeyName}`,\n\t\t\t\tuser.identity,\n\t\t\t\tuser.organization,\n\t\t\t\tloginTenantId,\n\t\t\t\tthis._defaultTtlMinutes,\n\t\t\t\tuser.scope\n\t\t\t);\n\t\t\tloginUser = user;\n\t\t} catch (error) {\n\t\t\tawait this._authenticationAuditService?.create({\n\t\t\t\tactorId: email,\n\t\t\t\tevent: AuthAuditEvent.LoginFailure\n\t\t\t});\n\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tEntityStorageAuthenticationService.CLASS_NAME,\n\t\t\t\t\"loginFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\n\t\tawait this._authenticationRateService.clear(\"login\", email);\n\n\t\tawait this._authenticationAuditService?.create({\n\t\t\tactorId: email,\n\t\t\tevent: AuthAuditEvent.LoginSuccess,\n\t\t\tdata: {\n\t\t\t\tuserIdentity: loginUser.identity,\n\t\t\t\torganizationIdentity: loginUser.organization,\n\t\t\t\ttenantId: loginTenantId,\n\t\t\t\tscope: loginUser.scope.split(\",\")\n\t\t\t}\n\t\t});\n\n\t\treturn tokenAndExpiry;\n\t}\n\n\t/**\n\t * Logout the current user.\n\t * @param token The token to logout, if it uses a mechanism with public access.\n\t * @returns Nothing.\n\t */\n\tpublic async logout(token?: string): Promise<void> {\n\t\t// Nothing to do here, as we are stateless.\n\t\t// The cookie will be revoked by the REST route handling\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst identifier = contextIds?.[ContextIdKeys.User];\n\t\tif (Is.stringValue(identifier)) {\n\t\t\tawait this._authenticationAuditService?.create({\n\t\t\t\tactorId: identifier,\n\t\t\t\tevent: AuthAuditEvent.Logout\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Refresh the token.\n\t * @param token The token to refresh, if it uses a mechanism with public access.\n\t * @returns The refreshed token, if it uses a mechanism with public access.\n\t */\n\tpublic async refresh(token?: string): Promise<{\n\t\ttoken?: string;\n\t\texpiry: number;\n\t}> {\n\t\t// If the verify fails on the current token then it will throw an exception.\n\t\tconst headerAndPayload = await TokenHelper.verify(\n\t\t\tthis._vaultConnector,\n\t\t\t`${this._nodeId}/${this._signingKeyName}`,\n\t\t\ttoken,\n\t\t\tundefined,\n\t\t\tasync (userIdentity, organizationIdentity) => {\n\t\t\t\tconst validParts = [];\n\t\t\t\tconst user = await this._userEntityStorage.get(userIdentity, \"identity\");\n\t\t\t\tif (user?.identity === userIdentity) {\n\t\t\t\t\tvalidParts.push(\"user\");\n\t\t\t\t}\n\t\t\t\tif (user?.organization === organizationIdentity) {\n\t\t\t\t\tvalidParts.push(\"organization\");\n\t\t\t\t}\n\t\t\t\treturn validParts;\n\t\t\t}\n\t\t);\n\n\t\tconst refreshSub = headerAndPayload.payload.sub ?? \"\";\n\t\tawait this._authenticationRateService.check(\"token-refresh\", refreshSub);\n\n\t\tconst refreshTokenAndExpiry = await TokenHelper.createToken(\n\t\t\tthis._vaultConnector,\n\t\t\t`${this._nodeId}/${this._signingKeyName}`,\n\t\t\trefreshSub,\n\t\t\tIs.stringValue(headerAndPayload.payload.org) ? headerAndPayload.payload.org : \"\",\n\t\t\tIs.string(headerAndPayload.payload.tid) ? headerAndPayload.payload.tid : undefined,\n\t\t\tthis._defaultTtlMinutes,\n\t\t\tCoerce.string(headerAndPayload.payload?.scope)\n\t\t);\n\t\tconst refreshScope = Coerce.string(headerAndPayload.payload?.scope) ?? \"\";\n\n\t\tawait this._authenticationAuditService?.create({\n\t\t\tactorId: refreshSub,\n\t\t\tevent: AuthAuditEvent.TokenRefreshed,\n\t\t\tdata: {\n\t\t\t\torganizationIdentity: Is.stringValue(headerAndPayload.payload.org)\n\t\t\t\t\t? headerAndPayload.payload.org\n\t\t\t\t\t: \"\",\n\t\t\t\ttenantId: Is.string(headerAndPayload.payload.tid)\n\t\t\t\t\t? headerAndPayload.payload.tid\n\t\t\t\t\t: undefined,\n\t\t\t\tscope: refreshScope.split(\",\").filter(scope => scope.length > 0)\n\t\t\t}\n\t\t});\n\n\t\treturn refreshTokenAndExpiry;\n\t}\n\n\t/**\n\t * Update the user's password.\n\t * @param currentPassword The current password for the user.\n\t * @param newPassword The new password for the user.\n\t * @returns Nothing.\n\t */\n\tpublic async updatePassword(currentPassword: string, newPassword: string): Promise<void> {\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tContextIdHelper.guard(contextIds, ContextIdKeys.User);\n\n\t\tconst userIdentity = contextIds[ContextIdKeys.User];\n\t\tawait this._authenticationRateService.check(\"password-change\", userIdentity);\n\n\t\tconst user = await this._userEntityStorage.get(userIdentity, \"identity\");\n\t\tif (!Is.object<AuthenticationUser>(user)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tEntityStorageAuthenticationService.CLASS_NAME,\n\t\t\t\t\"userNotFound\",\n\t\t\t\tuserIdentity\n\t\t\t);\n\t\t}\n\n\t\tawait PasswordHelper.updatePassword(\n\t\t\tthis._userEntityStorage,\n\t\t\tthis._authenticationAuditService,\n\t\t\tuser,\n\t\t\tnewPassword,\n\t\t\tcurrentPassword,\n\t\t\tthis._minPasswordLength\n\t\t);\n\n\t\tawait this._authenticationRateService.clear(\"password-change\", userIdentity);\n\t}\n}\n"]}
|
package/docs/changelog.md
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.0.3-next.
|
|
3
|
+
## [0.0.3-next.28](https://github.com/twinfoundation/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.27...api-auth-entity-storage-service-v0.0.3-next.28) (2026-04-30)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* change logout and refresh routes from GET to POST ([#111](https://github.com/twinfoundation/twin-api/issues/111)) ([cb8b64b](https://github.com/twinfoundation/twin-api/commit/cb8b64b6507f9991baa78a663de2e84269695c82))
|
|
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.27 to 0.0.3-next.28
|
|
16
|
+
* @twin.org/api-core bumped from 0.0.3-next.27 to 0.0.3-next.28
|
|
17
|
+
* @twin.org/api-models bumped from 0.0.3-next.27 to 0.0.3-next.28
|
|
18
|
+
|
|
19
|
+
## [0.0.3-next.27](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.26...api-auth-entity-storage-service-v0.0.3-next.27) (2026-04-23)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* handling the tid as undefined at refresh when empty ([#104](https://github.com/iotaledger/twin-api/issues/104)) ([d874a4a](https://github.com/iotaledger/twin-api/commit/d874a4a542c5fd45bb1bd56650247f844d056643))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Dependencies
|
|
28
|
+
|
|
29
|
+
* The following workspace dependencies were updated
|
|
30
|
+
* dependencies
|
|
31
|
+
* @twin.org/api-auth-entity-storage-models bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
32
|
+
* @twin.org/api-core bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
33
|
+
* @twin.org/api-models bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
34
|
+
|
|
35
|
+
## [0.0.3-next.26](https://github.com/iotaledger/twin-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
36
|
|
|
5
37
|
|
|
6
38
|
### Miscellaneous Chores
|
|
@@ -16,12 +48,12 @@
|
|
|
16
48
|
* @twin.org/api-core bumped from 0.0.3-next.25 to 0.0.3-next.26
|
|
17
49
|
* @twin.org/api-models bumped from 0.0.3-next.25 to 0.0.3-next.26
|
|
18
50
|
|
|
19
|
-
## [0.0.3-next.25](https://github.com/
|
|
51
|
+
## [0.0.3-next.25](https://github.com/iotaledger/twin-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)
|
|
20
52
|
|
|
21
53
|
|
|
22
54
|
### Features
|
|
23
55
|
|
|
24
|
-
* auth header processor use user entity storage directly ([93084cf](https://github.com/
|
|
56
|
+
* auth header processor use user entity storage directly ([93084cf](https://github.com/iotaledger/twin-api/commit/93084cfed8f3ab16c80a1ab1bc90b1d9fc14bd25))
|
|
25
57
|
|
|
26
58
|
|
|
27
59
|
### Dependencies
|
|
@@ -32,12 +64,12 @@
|
|
|
32
64
|
* @twin.org/api-core bumped from 0.0.3-next.24 to 0.0.3-next.25
|
|
33
65
|
* @twin.org/api-models bumped from 0.0.3-next.24 to 0.0.3-next.25
|
|
34
66
|
|
|
35
|
-
## [0.0.3-next.24](https://github.com/
|
|
67
|
+
## [0.0.3-next.24](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.23...api-auth-entity-storage-service-v0.0.3-next.24) (2026-04-14)
|
|
36
68
|
|
|
37
69
|
|
|
38
70
|
### Features
|
|
39
71
|
|
|
40
|
-
* remove auth service dependency on admin service ([4aeb211](https://github.com/
|
|
72
|
+
* remove auth service dependency on admin service ([4aeb211](https://github.com/iotaledger/twin-api/commit/4aeb211a5ffcf2eaea89a6841faea3ac3069ef89))
|
|
41
73
|
|
|
42
74
|
|
|
43
75
|
### Dependencies
|
|
@@ -48,12 +80,12 @@
|
|
|
48
80
|
* @twin.org/api-core bumped from 0.0.3-next.23 to 0.0.3-next.24
|
|
49
81
|
* @twin.org/api-models bumped from 0.0.3-next.23 to 0.0.3-next.24
|
|
50
82
|
|
|
51
|
-
## [0.0.3-next.23](https://github.com/
|
|
83
|
+
## [0.0.3-next.23](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.22...api-auth-entity-storage-service-v0.0.3-next.23) (2026-04-14)
|
|
52
84
|
|
|
53
85
|
|
|
54
86
|
### Features
|
|
55
87
|
|
|
56
|
-
* auth enhancements ([#93](https://github.com/
|
|
88
|
+
* auth enhancements ([#93](https://github.com/iotaledger/twin-api/issues/93)) ([921a50c](https://github.com/iotaledger/twin-api/commit/921a50cd89d26e530a6be6174a5a803060fa0eb6))
|
|
57
89
|
|
|
58
90
|
|
|
59
91
|
### Dependencies
|
|
@@ -64,7 +96,7 @@
|
|
|
64
96
|
* @twin.org/api-core bumped from 0.0.3-next.22 to 0.0.3-next.23
|
|
65
97
|
* @twin.org/api-models bumped from 0.0.3-next.22 to 0.0.3-next.23
|
|
66
98
|
|
|
67
|
-
## [0.0.3-next.22](https://github.com/
|
|
99
|
+
## [0.0.3-next.22](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.21...api-auth-entity-storage-service-v0.0.3-next.22) (2026-03-27)
|
|
68
100
|
|
|
69
101
|
|
|
70
102
|
### Miscellaneous Chores
|
|
@@ -80,7 +112,7 @@
|
|
|
80
112
|
* @twin.org/api-core bumped from 0.0.3-next.21 to 0.0.3-next.22
|
|
81
113
|
* @twin.org/api-models bumped from 0.0.3-next.21 to 0.0.3-next.22
|
|
82
114
|
|
|
83
|
-
## [0.0.3-next.21](https://github.com/
|
|
115
|
+
## [0.0.3-next.21](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.20...api-auth-entity-storage-service-v0.0.3-next.21) (2026-03-11)
|
|
84
116
|
|
|
85
117
|
|
|
86
118
|
### Miscellaneous Chores
|
|
@@ -96,12 +128,12 @@
|
|
|
96
128
|
* @twin.org/api-core bumped from 0.0.3-next.20 to 0.0.3-next.21
|
|
97
129
|
* @twin.org/api-models bumped from 0.0.3-next.20 to 0.0.3-next.21
|
|
98
130
|
|
|
99
|
-
## [0.0.3-next.20](https://github.com/
|
|
131
|
+
## [0.0.3-next.20](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.19...api-auth-entity-storage-service-v0.0.3-next.20) (2026-02-09)
|
|
100
132
|
|
|
101
133
|
|
|
102
134
|
### Features
|
|
103
135
|
|
|
104
|
-
* location encoding ([#79](https://github.com/
|
|
136
|
+
* location encoding ([#79](https://github.com/iotaledger/twin-api/issues/79)) ([c684465](https://github.com/iotaledger/twin-api/commit/c684465f2a871376152472bdecb6aa230b1101a1))
|
|
105
137
|
|
|
106
138
|
|
|
107
139
|
### Dependencies
|
|
@@ -112,12 +144,12 @@
|
|
|
112
144
|
* @twin.org/api-core bumped from 0.0.3-next.19 to 0.0.3-next.20
|
|
113
145
|
* @twin.org/api-models bumped from 0.0.3-next.19 to 0.0.3-next.20
|
|
114
146
|
|
|
115
|
-
## [0.0.3-next.19](https://github.com/
|
|
147
|
+
## [0.0.3-next.19](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.18...api-auth-entity-storage-service-v0.0.3-next.19) (2026-02-06)
|
|
116
148
|
|
|
117
149
|
|
|
118
150
|
### Features
|
|
119
151
|
|
|
120
|
-
* user admin service ([#77](https://github.com/
|
|
152
|
+
* user admin service ([#77](https://github.com/iotaledger/twin-api/issues/77)) ([c8491df](https://github.com/iotaledger/twin-api/commit/c8491df7b07c1f45560c8a78c6adc806d0ececbb))
|
|
121
153
|
|
|
122
154
|
|
|
123
155
|
### Dependencies
|
|
@@ -128,12 +160,12 @@
|
|
|
128
160
|
* @twin.org/api-core bumped from 0.0.3-next.18 to 0.0.3-next.19
|
|
129
161
|
* @twin.org/api-models bumped from 0.0.3-next.18 to 0.0.3-next.19
|
|
130
162
|
|
|
131
|
-
## [0.0.3-next.18](https://github.com/
|
|
163
|
+
## [0.0.3-next.18](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.17...api-auth-entity-storage-service-v0.0.3-next.18) (2026-02-04)
|
|
132
164
|
|
|
133
165
|
|
|
134
166
|
### Features
|
|
135
167
|
|
|
136
|
-
* tenant api and scopes ([#75](https://github.com/
|
|
168
|
+
* tenant api and scopes ([#75](https://github.com/iotaledger/twin-api/issues/75)) ([c663141](https://github.com/iotaledger/twin-api/commit/c663141091e8974d769f8f9904ecdab009ebd083))
|
|
137
169
|
|
|
138
170
|
|
|
139
171
|
### Dependencies
|
|
@@ -144,7 +176,7 @@
|
|
|
144
176
|
* @twin.org/api-core bumped from 0.0.3-next.17 to 0.0.3-next.18
|
|
145
177
|
* @twin.org/api-models bumped from 0.0.3-next.17 to 0.0.3-next.18
|
|
146
178
|
|
|
147
|
-
## [0.0.3-next.17](https://github.com/
|
|
179
|
+
## [0.0.3-next.17](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.16...api-auth-entity-storage-service-v0.0.3-next.17) (2026-01-26)
|
|
148
180
|
|
|
149
181
|
|
|
150
182
|
### Miscellaneous Chores
|
|
@@ -160,7 +192,7 @@
|
|
|
160
192
|
* @twin.org/api-core bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
161
193
|
* @twin.org/api-models bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
162
194
|
|
|
163
|
-
## [0.0.3-next.16](https://github.com/
|
|
195
|
+
## [0.0.3-next.16](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.15...api-auth-entity-storage-service-v0.0.3-next.16) (2026-01-26)
|
|
164
196
|
|
|
165
197
|
|
|
166
198
|
### Miscellaneous Chores
|
|
@@ -176,7 +208,7 @@
|
|
|
176
208
|
* @twin.org/api-core bumped from 0.0.3-next.15 to 0.0.3-next.16
|
|
177
209
|
* @twin.org/api-models bumped from 0.0.3-next.15 to 0.0.3-next.16
|
|
178
210
|
|
|
179
|
-
## [0.0.3-next.15](https://github.com/
|
|
211
|
+
## [0.0.3-next.15](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.14...api-auth-entity-storage-service-v0.0.3-next.15) (2026-01-22)
|
|
180
212
|
|
|
181
213
|
|
|
182
214
|
### Miscellaneous Chores
|
|
@@ -192,7 +224,7 @@
|
|
|
192
224
|
* @twin.org/api-core bumped from 0.0.3-next.14 to 0.0.3-next.15
|
|
193
225
|
* @twin.org/api-models bumped from 0.0.3-next.14 to 0.0.3-next.15
|
|
194
226
|
|
|
195
|
-
## [0.0.3-next.14](https://github.com/
|
|
227
|
+
## [0.0.3-next.14](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.13...api-auth-entity-storage-service-v0.0.3-next.14) (2026-01-20)
|
|
196
228
|
|
|
197
229
|
|
|
198
230
|
### Miscellaneous Chores
|
|
@@ -208,7 +240,7 @@
|
|
|
208
240
|
* @twin.org/api-core bumped from 0.0.3-next.13 to 0.0.3-next.14
|
|
209
241
|
* @twin.org/api-models bumped from 0.0.3-next.13 to 0.0.3-next.14
|
|
210
242
|
|
|
211
|
-
## [0.0.3-next.13](https://github.com/
|
|
243
|
+
## [0.0.3-next.13](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.12...api-auth-entity-storage-service-v0.0.3-next.13) (2026-01-19)
|
|
212
244
|
|
|
213
245
|
|
|
214
246
|
### Miscellaneous Chores
|
|
@@ -224,7 +256,7 @@
|
|
|
224
256
|
* @twin.org/api-core bumped from 0.0.3-next.12 to 0.0.3-next.13
|
|
225
257
|
* @twin.org/api-models bumped from 0.0.3-next.12 to 0.0.3-next.13
|
|
226
258
|
|
|
227
|
-
## [0.0.3-next.12](https://github.com/
|
|
259
|
+
## [0.0.3-next.12](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.11...api-auth-entity-storage-service-v0.0.3-next.12) (2026-01-12)
|
|
228
260
|
|
|
229
261
|
|
|
230
262
|
### Miscellaneous Chores
|
|
@@ -240,7 +272,7 @@
|
|
|
240
272
|
* @twin.org/api-core bumped from 0.0.3-next.11 to 0.0.3-next.12
|
|
241
273
|
* @twin.org/api-models bumped from 0.0.3-next.11 to 0.0.3-next.12
|
|
242
274
|
|
|
243
|
-
## [0.0.3-next.11](https://github.com/
|
|
275
|
+
## [0.0.3-next.11](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.10...api-auth-entity-storage-service-v0.0.3-next.11) (2026-01-08)
|
|
244
276
|
|
|
245
277
|
|
|
246
278
|
### Miscellaneous Chores
|
|
@@ -256,12 +288,12 @@
|
|
|
256
288
|
* @twin.org/api-core bumped from 0.0.3-next.10 to 0.0.3-next.11
|
|
257
289
|
* @twin.org/api-models bumped from 0.0.3-next.10 to 0.0.3-next.11
|
|
258
290
|
|
|
259
|
-
## [0.0.3-next.10](https://github.com/
|
|
291
|
+
## [0.0.3-next.10](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.9...api-auth-entity-storage-service-v0.0.3-next.10) (2026-01-05)
|
|
260
292
|
|
|
261
293
|
|
|
262
294
|
### Bug Fixes
|
|
263
295
|
|
|
264
|
-
* remove token from return payload ([eaa4266](https://github.com/
|
|
296
|
+
* remove token from return payload ([eaa4266](https://github.com/iotaledger/twin-api/commit/eaa42661b8540881b0751f5d2513258b3413f3ef))
|
|
265
297
|
|
|
266
298
|
|
|
267
299
|
### Dependencies
|
|
@@ -272,30 +304,30 @@
|
|
|
272
304
|
* @twin.org/api-core bumped from 0.0.3-next.9 to 0.0.3-next.10
|
|
273
305
|
* @twin.org/api-models bumped from 0.0.3-next.9 to 0.0.3-next.10
|
|
274
306
|
|
|
275
|
-
## [0.0.3-next.9](https://github.com/
|
|
307
|
+
## [0.0.3-next.9](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.8...api-auth-entity-storage-service-v0.0.3-next.9) (2026-01-05)
|
|
276
308
|
|
|
277
309
|
|
|
278
310
|
### Features
|
|
279
311
|
|
|
280
|
-
* add context id features ([#42](https://github.com/
|
|
281
|
-
* add json-ld mime type processor and auth admin component ([8861791](https://github.com/
|
|
282
|
-
* add livez endpoint ([#57](https://github.com/
|
|
283
|
-
* add validate-locales ([cdba610](https://github.com/
|
|
284
|
-
* check tenant id in auth if set ([66f7337](https://github.com/
|
|
285
|
-
* eslint migration to flat config ([0dd5820](https://github.com/
|
|
286
|
-
* modify authHeaderProcessor to retain token in response body ([#53](https://github.com/
|
|
287
|
-
* remove unused namespace ([08478f2](https://github.com/
|
|
288
|
-
* update dependencies ([1171dc4](https://github.com/
|
|
289
|
-
* update framework core ([d8eebf2](https://github.com/
|
|
290
|
-
* update IComponent signatures ([915ce37](https://github.com/
|
|
291
|
-
* use new extractBearer method ([3e0cc54](https://github.com/
|
|
292
|
-
* use new extractBearerToken method ([df654e9](https://github.com/
|
|
293
|
-
* use shared store mechanism ([#19](https://github.com/
|
|
312
|
+
* add context id features ([#42](https://github.com/iotaledger/twin-api/issues/42)) ([0186055](https://github.com/iotaledger/twin-api/commit/0186055c48afde842a4254b4df9ac9249c40fe40))
|
|
313
|
+
* add json-ld mime type processor and auth admin component ([8861791](https://github.com/iotaledger/twin-api/commit/88617916e23bfbca023dbae1976fe421983a02ff))
|
|
314
|
+
* add livez endpoint ([#57](https://github.com/iotaledger/twin-api/issues/57)) ([ef007db](https://github.com/iotaledger/twin-api/commit/ef007db8201736dd3053211f849ffd03baaa485e))
|
|
315
|
+
* add validate-locales ([cdba610](https://github.com/iotaledger/twin-api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
|
|
316
|
+
* check tenant id in auth if set ([66f7337](https://github.com/iotaledger/twin-api/commit/66f73374d3cf4c1c85ea96ec74bb30712fb84dd7))
|
|
317
|
+
* eslint migration to flat config ([0dd5820](https://github.com/iotaledger/twin-api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
|
|
318
|
+
* modify authHeaderProcessor to retain token in response body ([#53](https://github.com/iotaledger/twin-api/issues/53)) ([5d9ae76](https://github.com/iotaledger/twin-api/commit/5d9ae76b5b52a8e10dac391b2d5784638a186583))
|
|
319
|
+
* remove unused namespace ([08478f2](https://github.com/iotaledger/twin-api/commit/08478f27efda9beb0271fdb22f6972e918361965))
|
|
320
|
+
* update dependencies ([1171dc4](https://github.com/iotaledger/twin-api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
|
|
321
|
+
* update framework core ([d8eebf2](https://github.com/iotaledger/twin-api/commit/d8eebf267fa2a0abaa84e58590496e9d20490cfa))
|
|
322
|
+
* update IComponent signatures ([915ce37](https://github.com/iotaledger/twin-api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
|
|
323
|
+
* use new extractBearer method ([3e0cc54](https://github.com/iotaledger/twin-api/commit/3e0cc5462c06f59a6b744386eeff8326e5abbc95))
|
|
324
|
+
* use new extractBearerToken method ([df654e9](https://github.com/iotaledger/twin-api/commit/df654e9caee5bd62f0be36f7be9902c8fab6ead6))
|
|
325
|
+
* use shared store mechanism ([#19](https://github.com/iotaledger/twin-api/issues/19)) ([32116df](https://github.com/iotaledger/twin-api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
|
|
294
326
|
|
|
295
327
|
|
|
296
328
|
### Bug Fixes
|
|
297
329
|
|
|
298
|
-
* include org in context ids from jwt ([a12cfdd](https://github.com/
|
|
330
|
+
* include org in context ids from jwt ([a12cfdd](https://github.com/iotaledger/twin-api/commit/a12cfdddb05e2ed0300b26f3d7c0cfc033e59bd3))
|
|
299
331
|
|
|
300
332
|
|
|
301
333
|
### Dependencies
|
|
@@ -306,7 +338,7 @@
|
|
|
306
338
|
* @twin.org/api-core bumped from 0.0.3-next.8 to 0.0.3-next.9
|
|
307
339
|
* @twin.org/api-models bumped from 0.0.3-next.8 to 0.0.3-next.9
|
|
308
340
|
|
|
309
|
-
## [0.0.3-next.8](https://github.com/
|
|
341
|
+
## [0.0.3-next.8](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.7...api-auth-entity-storage-service-v0.0.3-next.8) (2025-12-17)
|
|
310
342
|
|
|
311
343
|
|
|
312
344
|
### Miscellaneous Chores
|
|
@@ -322,7 +354,7 @@
|
|
|
322
354
|
* @twin.org/api-core bumped from 0.0.3-next.7 to 0.0.3-next.8
|
|
323
355
|
* @twin.org/api-models bumped from 0.0.3-next.7 to 0.0.3-next.8
|
|
324
356
|
|
|
325
|
-
## [0.0.3-next.7](https://github.com/
|
|
357
|
+
## [0.0.3-next.7](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.6...api-auth-entity-storage-service-v0.0.3-next.7) (2025-11-26)
|
|
326
358
|
|
|
327
359
|
|
|
328
360
|
### Miscellaneous Chores
|
|
@@ -338,12 +370,12 @@
|
|
|
338
370
|
* @twin.org/api-core bumped from 0.0.3-next.6 to 0.0.3-next.7
|
|
339
371
|
* @twin.org/api-models bumped from 0.0.3-next.6 to 0.0.3-next.7
|
|
340
372
|
|
|
341
|
-
## [0.0.3-next.6](https://github.com/
|
|
373
|
+
## [0.0.3-next.6](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.5...api-auth-entity-storage-service-v0.0.3-next.6) (2025-11-20)
|
|
342
374
|
|
|
343
375
|
|
|
344
376
|
### Features
|
|
345
377
|
|
|
346
|
-
* check tenant id in auth if set ([66f7337](https://github.com/
|
|
378
|
+
* check tenant id in auth if set ([66f7337](https://github.com/iotaledger/twin-api/commit/66f73374d3cf4c1c85ea96ec74bb30712fb84dd7))
|
|
347
379
|
|
|
348
380
|
|
|
349
381
|
### Dependencies
|
|
@@ -354,7 +386,7 @@
|
|
|
354
386
|
* @twin.org/api-core bumped from 0.0.3-next.5 to 0.0.3-next.6
|
|
355
387
|
* @twin.org/api-models bumped from 0.0.3-next.5 to 0.0.3-next.6
|
|
356
388
|
|
|
357
|
-
## [0.0.3-next.5](https://github.com/
|
|
389
|
+
## [0.0.3-next.5](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.4...api-auth-entity-storage-service-v0.0.3-next.5) (2025-11-14)
|
|
358
390
|
|
|
359
391
|
|
|
360
392
|
### Miscellaneous Chores
|
|
@@ -370,27 +402,27 @@
|
|
|
370
402
|
* @twin.org/api-core bumped from 0.0.3-next.4 to 0.0.3-next.5
|
|
371
403
|
* @twin.org/api-models bumped from 0.0.3-next.4 to 0.0.3-next.5
|
|
372
404
|
|
|
373
|
-
## [0.0.3-next.4](https://github.com/
|
|
405
|
+
## [0.0.3-next.4](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.3...api-auth-entity-storage-service-v0.0.3-next.4) (2025-11-14)
|
|
374
406
|
|
|
375
407
|
|
|
376
408
|
### Features
|
|
377
409
|
|
|
378
|
-
* add context id features ([#42](https://github.com/
|
|
379
|
-
* add json-ld mime type processor and auth admin component ([8861791](https://github.com/
|
|
380
|
-
* add validate-locales ([cdba610](https://github.com/
|
|
381
|
-
* eslint migration to flat config ([0dd5820](https://github.com/
|
|
382
|
-
* remove unused namespace ([08478f2](https://github.com/
|
|
383
|
-
* update dependencies ([1171dc4](https://github.com/
|
|
384
|
-
* update framework core ([d8eebf2](https://github.com/
|
|
385
|
-
* update IComponent signatures ([915ce37](https://github.com/
|
|
386
|
-
* use new extractBearer method ([3e0cc54](https://github.com/
|
|
387
|
-
* use new extractBearerToken method ([df654e9](https://github.com/
|
|
388
|
-
* use shared store mechanism ([#19](https://github.com/
|
|
410
|
+
* add context id features ([#42](https://github.com/iotaledger/twin-api/issues/42)) ([0186055](https://github.com/iotaledger/twin-api/commit/0186055c48afde842a4254b4df9ac9249c40fe40))
|
|
411
|
+
* add json-ld mime type processor and auth admin component ([8861791](https://github.com/iotaledger/twin-api/commit/88617916e23bfbca023dbae1976fe421983a02ff))
|
|
412
|
+
* add validate-locales ([cdba610](https://github.com/iotaledger/twin-api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
|
|
413
|
+
* eslint migration to flat config ([0dd5820](https://github.com/iotaledger/twin-api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
|
|
414
|
+
* remove unused namespace ([08478f2](https://github.com/iotaledger/twin-api/commit/08478f27efda9beb0271fdb22f6972e918361965))
|
|
415
|
+
* update dependencies ([1171dc4](https://github.com/iotaledger/twin-api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
|
|
416
|
+
* update framework core ([d8eebf2](https://github.com/iotaledger/twin-api/commit/d8eebf267fa2a0abaa84e58590496e9d20490cfa))
|
|
417
|
+
* update IComponent signatures ([915ce37](https://github.com/iotaledger/twin-api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
|
|
418
|
+
* use new extractBearer method ([3e0cc54](https://github.com/iotaledger/twin-api/commit/3e0cc5462c06f59a6b744386eeff8326e5abbc95))
|
|
419
|
+
* use new extractBearerToken method ([df654e9](https://github.com/iotaledger/twin-api/commit/df654e9caee5bd62f0be36f7be9902c8fab6ead6))
|
|
420
|
+
* use shared store mechanism ([#19](https://github.com/iotaledger/twin-api/issues/19)) ([32116df](https://github.com/iotaledger/twin-api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
|
|
389
421
|
|
|
390
422
|
|
|
391
423
|
### Bug Fixes
|
|
392
424
|
|
|
393
|
-
* include org in context ids from jwt ([a12cfdd](https://github.com/
|
|
425
|
+
* include org in context ids from jwt ([a12cfdd](https://github.com/iotaledger/twin-api/commit/a12cfdddb05e2ed0300b26f3d7c0cfc033e59bd3))
|
|
394
426
|
|
|
395
427
|
|
|
396
428
|
### Dependencies
|
|
@@ -401,12 +433,12 @@
|
|
|
401
433
|
* @twin.org/api-core bumped from 0.0.3-next.3 to 0.0.3-next.4
|
|
402
434
|
* @twin.org/api-models bumped from 0.0.3-next.3 to 0.0.3-next.4
|
|
403
435
|
|
|
404
|
-
## [0.0.3-next.3](https://github.com/
|
|
436
|
+
## [0.0.3-next.3](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.2...api-auth-entity-storage-service-v0.0.3-next.3) (2025-11-14)
|
|
405
437
|
|
|
406
438
|
|
|
407
439
|
### Bug Fixes
|
|
408
440
|
|
|
409
|
-
* include org in context ids from jwt ([a12cfdd](https://github.com/
|
|
441
|
+
* include org in context ids from jwt ([a12cfdd](https://github.com/iotaledger/twin-api/commit/a12cfdddb05e2ed0300b26f3d7c0cfc033e59bd3))
|
|
410
442
|
|
|
411
443
|
|
|
412
444
|
### Dependencies
|
|
@@ -417,7 +449,7 @@
|
|
|
417
449
|
* @twin.org/api-core bumped from 0.0.3-next.2 to 0.0.3-next.3
|
|
418
450
|
* @twin.org/api-models bumped from 0.0.3-next.2 to 0.0.3-next.3
|
|
419
451
|
|
|
420
|
-
## [0.0.3-next.2](https://github.com/
|
|
452
|
+
## [0.0.3-next.2](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.1...api-auth-entity-storage-service-v0.0.3-next.2) (2025-11-12)
|
|
421
453
|
|
|
422
454
|
|
|
423
455
|
### Miscellaneous Chores
|
|
@@ -433,22 +465,22 @@
|
|
|
433
465
|
* @twin.org/api-core bumped from 0.0.3-next.1 to 0.0.3-next.2
|
|
434
466
|
* @twin.org/api-models bumped from 0.0.3-next.1 to 0.0.3-next.2
|
|
435
467
|
|
|
436
|
-
## [0.0.3-next.1](https://github.com/
|
|
468
|
+
## [0.0.3-next.1](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.3-next.0...api-auth-entity-storage-service-v0.0.3-next.1) (2025-11-10)
|
|
437
469
|
|
|
438
470
|
|
|
439
471
|
### Features
|
|
440
472
|
|
|
441
|
-
* add context id features ([#42](https://github.com/
|
|
442
|
-
* add json-ld mime type processor and auth admin component ([8861791](https://github.com/
|
|
443
|
-
* add validate-locales ([cdba610](https://github.com/
|
|
444
|
-
* eslint migration to flat config ([0dd5820](https://github.com/
|
|
445
|
-
* remove unused namespace ([08478f2](https://github.com/
|
|
446
|
-
* update dependencies ([1171dc4](https://github.com/
|
|
447
|
-
* update framework core ([d8eebf2](https://github.com/
|
|
448
|
-
* update IComponent signatures ([915ce37](https://github.com/
|
|
449
|
-
* use new extractBearer method ([3e0cc54](https://github.com/
|
|
450
|
-
* use new extractBearerToken method ([df654e9](https://github.com/
|
|
451
|
-
* use shared store mechanism ([#19](https://github.com/
|
|
473
|
+
* add context id features ([#42](https://github.com/iotaledger/twin-api/issues/42)) ([0186055](https://github.com/iotaledger/twin-api/commit/0186055c48afde842a4254b4df9ac9249c40fe40))
|
|
474
|
+
* add json-ld mime type processor and auth admin component ([8861791](https://github.com/iotaledger/twin-api/commit/88617916e23bfbca023dbae1976fe421983a02ff))
|
|
475
|
+
* add validate-locales ([cdba610](https://github.com/iotaledger/twin-api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
|
|
476
|
+
* eslint migration to flat config ([0dd5820](https://github.com/iotaledger/twin-api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
|
|
477
|
+
* remove unused namespace ([08478f2](https://github.com/iotaledger/twin-api/commit/08478f27efda9beb0271fdb22f6972e918361965))
|
|
478
|
+
* update dependencies ([1171dc4](https://github.com/iotaledger/twin-api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
|
|
479
|
+
* update framework core ([d8eebf2](https://github.com/iotaledger/twin-api/commit/d8eebf267fa2a0abaa84e58590496e9d20490cfa))
|
|
480
|
+
* update IComponent signatures ([915ce37](https://github.com/iotaledger/twin-api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
|
|
481
|
+
* use new extractBearer method ([3e0cc54](https://github.com/iotaledger/twin-api/commit/3e0cc5462c06f59a6b744386eeff8326e5abbc95))
|
|
482
|
+
* use new extractBearerToken method ([df654e9](https://github.com/iotaledger/twin-api/commit/df654e9caee5bd62f0be36f7be9902c8fab6ead6))
|
|
483
|
+
* use shared store mechanism ([#19](https://github.com/iotaledger/twin-api/issues/19)) ([32116df](https://github.com/iotaledger/twin-api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
|
|
452
484
|
|
|
453
485
|
|
|
454
486
|
### Dependencies
|
|
@@ -459,7 +491,7 @@
|
|
|
459
491
|
* @twin.org/api-core bumped from 0.0.3-next.0 to 0.0.3-next.1
|
|
460
492
|
* @twin.org/api-models bumped from 0.0.3-next.0 to 0.0.3-next.1
|
|
461
493
|
|
|
462
|
-
## [0.0.2-next.13](https://github.com/
|
|
494
|
+
## [0.0.2-next.13](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.2-next.12...api-auth-entity-storage-service-v0.0.2-next.13) (2025-10-09)
|
|
463
495
|
|
|
464
496
|
|
|
465
497
|
### Miscellaneous Chores
|
|
@@ -475,12 +507,12 @@
|
|
|
475
507
|
* @twin.org/api-core bumped from 0.0.2-next.12 to 0.0.2-next.13
|
|
476
508
|
* @twin.org/api-models bumped from 0.0.2-next.12 to 0.0.2-next.13
|
|
477
509
|
|
|
478
|
-
## [0.0.2-next.12](https://github.com/
|
|
510
|
+
## [0.0.2-next.12](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.2-next.11...api-auth-entity-storage-service-v0.0.2-next.12) (2025-10-09)
|
|
479
511
|
|
|
480
512
|
|
|
481
513
|
### Features
|
|
482
514
|
|
|
483
|
-
* add validate-locales ([cdba610](https://github.com/
|
|
515
|
+
* add validate-locales ([cdba610](https://github.com/iotaledger/twin-api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
|
|
484
516
|
|
|
485
517
|
|
|
486
518
|
### Dependencies
|
|
@@ -491,12 +523,12 @@
|
|
|
491
523
|
* @twin.org/api-core bumped from 0.0.2-next.11 to 0.0.2-next.12
|
|
492
524
|
* @twin.org/api-models bumped from 0.0.2-next.11 to 0.0.2-next.12
|
|
493
525
|
|
|
494
|
-
## [0.0.2-next.11](https://github.com/
|
|
526
|
+
## [0.0.2-next.11](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.2-next.10...api-auth-entity-storage-service-v0.0.2-next.11) (2025-09-29)
|
|
495
527
|
|
|
496
528
|
|
|
497
529
|
### Features
|
|
498
530
|
|
|
499
|
-
* update IComponent signatures ([915ce37](https://github.com/
|
|
531
|
+
* update IComponent signatures ([915ce37](https://github.com/iotaledger/twin-api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
|
|
500
532
|
|
|
501
533
|
|
|
502
534
|
### Dependencies
|
|
@@ -507,13 +539,13 @@
|
|
|
507
539
|
* @twin.org/api-core bumped from 0.0.2-next.10 to 0.0.2-next.11
|
|
508
540
|
* @twin.org/api-models bumped from 0.0.2-next.10 to 0.0.2-next.11
|
|
509
541
|
|
|
510
|
-
## [0.0.2-next.10](https://github.com/
|
|
542
|
+
## [0.0.2-next.10](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.2-next.9...api-auth-entity-storage-service-v0.0.2-next.10) (2025-09-23)
|
|
511
543
|
|
|
512
544
|
|
|
513
545
|
### Features
|
|
514
546
|
|
|
515
|
-
* use new extractBearer method ([3e0cc54](https://github.com/
|
|
516
|
-
* use new extractBearerToken method ([df654e9](https://github.com/
|
|
547
|
+
* use new extractBearer method ([3e0cc54](https://github.com/iotaledger/twin-api/commit/3e0cc5462c06f59a6b744386eeff8326e5abbc95))
|
|
548
|
+
* use new extractBearerToken method ([df654e9](https://github.com/iotaledger/twin-api/commit/df654e9caee5bd62f0be36f7be9902c8fab6ead6))
|
|
517
549
|
|
|
518
550
|
|
|
519
551
|
### Dependencies
|
|
@@ -524,12 +556,12 @@
|
|
|
524
556
|
* @twin.org/api-core bumped from 0.0.2-next.9 to 0.0.2-next.10
|
|
525
557
|
* @twin.org/api-models bumped from 0.0.2-next.9 to 0.0.2-next.10
|
|
526
558
|
|
|
527
|
-
## [0.0.2-next.9](https://github.com/
|
|
559
|
+
## [0.0.2-next.9](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.2-next.8...api-auth-entity-storage-service-v0.0.2-next.9) (2025-08-29)
|
|
528
560
|
|
|
529
561
|
|
|
530
562
|
### Features
|
|
531
563
|
|
|
532
|
-
* eslint migration to flat config ([0dd5820](https://github.com/
|
|
564
|
+
* eslint migration to flat config ([0dd5820](https://github.com/iotaledger/twin-api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
|
|
533
565
|
|
|
534
566
|
|
|
535
567
|
### Dependencies
|
|
@@ -540,7 +572,7 @@
|
|
|
540
572
|
* @twin.org/api-core bumped from 0.0.2-next.8 to 0.0.2-next.9
|
|
541
573
|
* @twin.org/api-models bumped from 0.0.2-next.8 to 0.0.2-next.9
|
|
542
574
|
|
|
543
|
-
## [0.0.2-next.8](https://github.com/
|
|
575
|
+
## [0.0.2-next.8](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.2-next.7...api-auth-entity-storage-service-v0.0.2-next.8) (2025-08-21)
|
|
544
576
|
|
|
545
577
|
|
|
546
578
|
### Miscellaneous Chores
|
|
@@ -556,7 +588,7 @@
|
|
|
556
588
|
* @twin.org/api-core bumped from 0.0.2-next.7 to 0.0.2-next.8
|
|
557
589
|
* @twin.org/api-models bumped from 0.0.2-next.7 to 0.0.2-next.8
|
|
558
590
|
|
|
559
|
-
## [0.0.2-next.7](https://github.com/
|
|
591
|
+
## [0.0.2-next.7](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.2-next.6...api-auth-entity-storage-service-v0.0.2-next.7) (2025-08-20)
|
|
560
592
|
|
|
561
593
|
|
|
562
594
|
### Miscellaneous Chores
|
|
@@ -572,12 +604,12 @@
|
|
|
572
604
|
* @twin.org/api-core bumped from 0.0.2-next.6 to 0.0.2-next.7
|
|
573
605
|
* @twin.org/api-models bumped from 0.0.2-next.6 to 0.0.2-next.7
|
|
574
606
|
|
|
575
|
-
## [0.0.2-next.6](https://github.com/
|
|
607
|
+
## [0.0.2-next.6](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.2-next.5...api-auth-entity-storage-service-v0.0.2-next.6) (2025-08-19)
|
|
576
608
|
|
|
577
609
|
|
|
578
610
|
### Features
|
|
579
611
|
|
|
580
|
-
* update framework core ([d8eebf2](https://github.com/
|
|
612
|
+
* update framework core ([d8eebf2](https://github.com/iotaledger/twin-api/commit/d8eebf267fa2a0abaa84e58590496e9d20490cfa))
|
|
581
613
|
|
|
582
614
|
|
|
583
615
|
### Dependencies
|
|
@@ -588,15 +620,15 @@
|
|
|
588
620
|
* @twin.org/api-core bumped from 0.0.2-next.5 to 0.0.2-next.6
|
|
589
621
|
* @twin.org/api-models bumped from 0.0.2-next.5 to 0.0.2-next.6
|
|
590
622
|
|
|
591
|
-
## [0.0.2-next.5](https://github.com/
|
|
623
|
+
## [0.0.2-next.5](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.2-next.4...api-auth-entity-storage-service-v0.0.2-next.5) (2025-07-25)
|
|
592
624
|
|
|
593
625
|
|
|
594
626
|
### Features
|
|
595
627
|
|
|
596
|
-
* add json-ld mime type processor and auth admin component ([8861791](https://github.com/
|
|
597
|
-
* remove unused namespace ([08478f2](https://github.com/
|
|
598
|
-
* update dependencies ([1171dc4](https://github.com/
|
|
599
|
-
* use shared store mechanism ([#19](https://github.com/
|
|
628
|
+
* add json-ld mime type processor and auth admin component ([8861791](https://github.com/iotaledger/twin-api/commit/88617916e23bfbca023dbae1976fe421983a02ff))
|
|
629
|
+
* remove unused namespace ([08478f2](https://github.com/iotaledger/twin-api/commit/08478f27efda9beb0271fdb22f6972e918361965))
|
|
630
|
+
* update dependencies ([1171dc4](https://github.com/iotaledger/twin-api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
|
|
631
|
+
* use shared store mechanism ([#19](https://github.com/iotaledger/twin-api/issues/19)) ([32116df](https://github.com/iotaledger/twin-api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
|
|
600
632
|
|
|
601
633
|
|
|
602
634
|
### Dependencies
|
|
@@ -607,7 +639,7 @@
|
|
|
607
639
|
* @twin.org/api-core bumped from 0.0.2-next.4 to 0.0.2-next.5
|
|
608
640
|
* @twin.org/api-models bumped from 0.0.2-next.4 to 0.0.2-next.5
|
|
609
641
|
|
|
610
|
-
## [0.0.2-next.4](https://github.com/
|
|
642
|
+
## [0.0.2-next.4](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.2-next.3...api-auth-entity-storage-service-v0.0.2-next.4) (2025-07-25)
|
|
611
643
|
|
|
612
644
|
|
|
613
645
|
### Miscellaneous Chores
|
|
@@ -623,12 +655,12 @@
|
|
|
623
655
|
* @twin.org/api-core bumped from 0.0.2-next.3 to 0.0.2-next.4
|
|
624
656
|
* @twin.org/api-models bumped from 0.0.2-next.3 to 0.0.2-next.4
|
|
625
657
|
|
|
626
|
-
## [0.0.2-next.3](https://github.com/
|
|
658
|
+
## [0.0.2-next.3](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.2-next.2...api-auth-entity-storage-service-v0.0.2-next.3) (2025-07-24)
|
|
627
659
|
|
|
628
660
|
|
|
629
661
|
### Features
|
|
630
662
|
|
|
631
|
-
* remove unused namespace ([08478f2](https://github.com/
|
|
663
|
+
* remove unused namespace ([08478f2](https://github.com/iotaledger/twin-api/commit/08478f27efda9beb0271fdb22f6972e918361965))
|
|
632
664
|
|
|
633
665
|
|
|
634
666
|
### Dependencies
|
|
@@ -639,7 +671,7 @@
|
|
|
639
671
|
* @twin.org/api-core bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
640
672
|
* @twin.org/api-models bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
641
673
|
|
|
642
|
-
## [0.0.2-next.2](https://github.com/
|
|
674
|
+
## [0.0.2-next.2](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.2-next.1...api-auth-entity-storage-service-v0.0.2-next.2) (2025-07-17)
|
|
643
675
|
|
|
644
676
|
|
|
645
677
|
### Miscellaneous Chores
|
|
@@ -655,14 +687,14 @@
|
|
|
655
687
|
* @twin.org/api-core bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
656
688
|
* @twin.org/api-models bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
657
689
|
|
|
658
|
-
## [0.0.2-next.1](https://github.com/
|
|
690
|
+
## [0.0.2-next.1](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.2-next.0...api-auth-entity-storage-service-v0.0.2-next.1) (2025-07-08)
|
|
659
691
|
|
|
660
692
|
|
|
661
693
|
### Features
|
|
662
694
|
|
|
663
|
-
* add json-ld mime type processor and auth admin component ([8861791](https://github.com/
|
|
664
|
-
* update dependencies ([1171dc4](https://github.com/
|
|
665
|
-
* use shared store mechanism ([#19](https://github.com/
|
|
695
|
+
* add json-ld mime type processor and auth admin component ([8861791](https://github.com/iotaledger/twin-api/commit/88617916e23bfbca023dbae1976fe421983a02ff))
|
|
696
|
+
* update dependencies ([1171dc4](https://github.com/iotaledger/twin-api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
|
|
697
|
+
* use shared store mechanism ([#19](https://github.com/iotaledger/twin-api/issues/19)) ([32116df](https://github.com/iotaledger/twin-api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
|
|
666
698
|
|
|
667
699
|
|
|
668
700
|
### Dependencies
|
|
@@ -678,7 +710,7 @@
|
|
|
678
710
|
|
|
679
711
|
### Features
|
|
680
712
|
|
|
681
|
-
* release to production ([70ee2d5](https://github.com/
|
|
713
|
+
* release to production ([70ee2d5](https://github.com/iotaledger/twin-api/commit/70ee2d56a1dc9537d7c9c154d4cb78a235678a3a))
|
|
682
714
|
|
|
683
715
|
|
|
684
716
|
### Dependencies
|
|
@@ -689,7 +721,7 @@
|
|
|
689
721
|
* @twin.org/api-core bumped from ^0.0.0 to ^0.0.1
|
|
690
722
|
* @twin.org/api-models bumped from ^0.0.0 to ^0.0.1
|
|
691
723
|
|
|
692
|
-
## [0.0.1-next.36](https://github.com/
|
|
724
|
+
## [0.0.1-next.36](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.1-next.35...api-auth-entity-storage-service-v0.0.1-next.36) (2025-06-17)
|
|
693
725
|
|
|
694
726
|
|
|
695
727
|
### Miscellaneous Chores
|
|
@@ -705,12 +737,12 @@
|
|
|
705
737
|
* @twin.org/api-core bumped from 0.0.1-next.35 to 0.0.1-next.36
|
|
706
738
|
* @twin.org/api-models bumped from 0.0.1-next.35 to 0.0.1-next.36
|
|
707
739
|
|
|
708
|
-
## [0.0.1-next.35](https://github.com/
|
|
740
|
+
## [0.0.1-next.35](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.1-next.34...api-auth-entity-storage-service-v0.0.1-next.35) (2025-06-11)
|
|
709
741
|
|
|
710
742
|
|
|
711
743
|
### Features
|
|
712
744
|
|
|
713
|
-
* update dependencies ([1171dc4](https://github.com/
|
|
745
|
+
* update dependencies ([1171dc4](https://github.com/iotaledger/twin-api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
|
|
714
746
|
|
|
715
747
|
|
|
716
748
|
### Dependencies
|
|
@@ -721,7 +753,7 @@
|
|
|
721
753
|
* @twin.org/api-core bumped from 0.0.1-next.34 to 0.0.1-next.35
|
|
722
754
|
* @twin.org/api-models bumped from 0.0.1-next.34 to 0.0.1-next.35
|
|
723
755
|
|
|
724
|
-
## [0.0.1-next.34](https://github.com/
|
|
756
|
+
## [0.0.1-next.34](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.1-next.33...api-auth-entity-storage-service-v0.0.1-next.34) (2025-05-27)
|
|
725
757
|
|
|
726
758
|
|
|
727
759
|
### Miscellaneous Chores
|
|
@@ -737,12 +769,12 @@
|
|
|
737
769
|
* @twin.org/api-core bumped from 0.0.1-next.33 to 0.0.1-next.34
|
|
738
770
|
* @twin.org/api-models bumped from 0.0.1-next.33 to 0.0.1-next.34
|
|
739
771
|
|
|
740
|
-
## [0.0.1-next.33](https://github.com/
|
|
772
|
+
## [0.0.1-next.33](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.1-next.32...api-auth-entity-storage-service-v0.0.1-next.33) (2025-04-17)
|
|
741
773
|
|
|
742
774
|
|
|
743
775
|
### Features
|
|
744
776
|
|
|
745
|
-
* use shared store mechanism ([#19](https://github.com/
|
|
777
|
+
* use shared store mechanism ([#19](https://github.com/iotaledger/twin-api/issues/19)) ([32116df](https://github.com/iotaledger/twin-api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
|
|
746
778
|
|
|
747
779
|
|
|
748
780
|
### Dependencies
|
|
@@ -753,7 +785,7 @@
|
|
|
753
785
|
* @twin.org/api-core bumped from 0.0.1-next.32 to 0.0.1-next.33
|
|
754
786
|
* @twin.org/api-models bumped from 0.0.1-next.32 to 0.0.1-next.33
|
|
755
787
|
|
|
756
|
-
## [0.0.1-next.32](https://github.com/
|
|
788
|
+
## [0.0.1-next.32](https://github.com/iotaledger/twin-api/compare/api-auth-entity-storage-service-v0.0.1-next.31...api-auth-entity-storage-service-v0.0.1-next.32) (2025-03-28)
|
|
757
789
|
|
|
758
790
|
|
|
759
791
|
### Miscellaneous Chores
|
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.
|
|
3
|
+
"version": "0.0.3-next.28",
|
|
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.
|
|
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.28",
|
|
18
|
+
"@twin.org/api-core": "0.0.3-next.28",
|
|
19
|
+
"@twin.org/api-models": "0.0.3-next.28",
|
|
20
20
|
"@twin.org/background-task-models": "next",
|
|
21
21
|
"@twin.org/context": "next",
|
|
22
22
|
"@twin.org/core": "next",
|