@selfhelp/shared 1.2.5 → 1.3.0

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/CHANGELOG.md CHANGED
@@ -9,6 +9,21 @@ All notable changes to `@selfhelp/shared` will be documented in this file.
9
9
 
10
10
  This project follows semantic versioning.
11
11
 
12
+ ## [1.3.0]
13
+
14
+ ### Added
15
+
16
+ - `ENDPOINTS.AUTH.FORGOT_PASSWORD` (`/cms-api/v1/auth/forgot-password`) and
17
+ `ENDPOINTS.AUTH.RESET_PASSWORD` (`/cms-api/v1/auth/reset-password`) so the
18
+ password-recovery flow is part of the shared API contract (issue #31). The
19
+ web frontend and the mobile app now build these requests from shared
20
+ constants instead of local/ad-hoc paths.
21
+ - Request DTOs `IForgotPasswordRequest` and `IResetPasswordRequest`, and
22
+ response types `IForgotPasswordResponse` / `IResetPasswordResponse`,
23
+ mirroring the backend `requests/auth/forgot_password.json` and
24
+ `reset_password.json` schemas. `scripts/check-schema-parity.mjs` now covers
25
+ these request schemas.
26
+
12
27
  ## [1.2.5]
13
28
 
14
29
  ### Changed
package/dist/index.d.mts CHANGED
@@ -244,6 +244,16 @@ interface ITwoFactorVerifyRequest {
244
244
  interface IRefreshRequest {
245
245
  refresh_token: string;
246
246
  }
247
+ /** POST /auth/forgot-password — request a recovery email. */
248
+ interface IForgotPasswordRequest {
249
+ email: string;
250
+ }
251
+ /** POST /auth/reset-password — set a new password from the one-time token. */
252
+ interface IResetPasswordRequest {
253
+ id_users: number;
254
+ token: string;
255
+ password: string;
256
+ }
247
257
  interface ILoginSuccessData {
248
258
  access_token: string;
249
259
  refresh_token: string;
@@ -268,6 +278,18 @@ type ILanguagePreferenceUpdateResponse = IBaseApiResponse<{
268
278
  access_token?: string;
269
279
  language_id: number;
270
280
  }>;
281
+ /**
282
+ * Generic success for the forgot-password request. The backend always returns
283
+ * `requested: true` regardless of whether the email matched an account, so the
284
+ * endpoint cannot be used to enumerate registered users.
285
+ */
286
+ type IForgotPasswordResponse = IBaseApiResponse<{
287
+ requested: boolean;
288
+ }>;
289
+ /** Success when the recovery token was valid and the password was changed. */
290
+ type IResetPasswordResponse = IBaseApiResponse<{
291
+ reset: boolean;
292
+ }>;
271
293
 
272
294
  interface IFormSubmitRequest {
273
295
  section_id: number;
@@ -358,6 +380,8 @@ declare const ENDPOINTS: {
358
380
  readonly TWO_FACTOR_VERIFY: "/cms-api/v1/auth/two-factor-verify";
359
381
  readonly LOGOUT: "/cms-api/v1/auth/logout";
360
382
  readonly REFRESH: "/cms-api/v1/auth/refresh-token";
383
+ readonly FORGOT_PASSWORD: "/cms-api/v1/auth/forgot-password";
384
+ readonly RESET_PASSWORD: "/cms-api/v1/auth/reset-password";
361
385
  readonly SET_LANGUAGE: "/cms-api/v1/auth/set-language";
362
386
  readonly USER_DATA: "/cms-api/v1/auth/user-data";
363
387
  readonly EVENTS: "/cms-api/v1/auth/events";
@@ -640,4 +664,4 @@ declare function transformPageData(apiPage: IRawPage): IPageItem;
640
664
  */
641
665
  declare function transformPagesData(pages: IRawPage[] | null | undefined): IPageItem[];
642
666
 
643
- export { API_VERSION_PREFIX, CLASS_PATTERNS, CLASS_REMAP, CLIENT_TYPE_MOBILE, CLIENT_TYPE_MOBILE_AND_WEB, CLIENT_TYPE_WEB, COLOR_NAMES, ENDPOINTS, HEADER_CLIENT_TYPE, type IApiError, type IApiMeta, type IAssetSource, type IBaseApiResponse, type IBasePageInfo, type IBasePageSection, type IClassPattern, type IClassRemap, type IConditionContext, IContentField, type IEvaluatedCondition, type IFormDeleteRequest, type IFormDeleteResponse, type IFormResultLegacyFields, type IFormSubmitData, type IFormSubmitRequest, type IFormSubmitResponse, type IFormUpdateData, type IFormUpdateRequest, type IFormUpdateResponse, type IGetPageResponse, type IGetPagesResponse, type IJwtPayload, type ILanguage, type ILanguageItem, type ILanguagePreference, type ILanguagePreferenceUpdateResponse, type ILanguagesResponse, type ILoginRequest, type ILoginSuccessData, type ILoginSuccessResponse, type ILogoutSuccessResponse, type IMeta, type IPageAccessTypeInfo, type IPageContent, type IPageField, type IPageFieldTranslation, type IPageFieldsData, type IPageItem, type IPageSectionWithFields, type IPageSectionsData, type IRefreshRequest, type IRefreshSuccessResponse, type ISpacingValue, type ITwoFactorRequiredData, type ITwoFactorRequiredResponse, type ITwoFactorVerifyRequest, type ITwoFactorVerifySuccessResponse, type IUserData, type IUserDataResponse, LITERAL_CLASSES, PERMISSIONS, SIZE_VALUES, SPACING_VALUES, type TCalcedValues, type TClassDecision, type TClientType, type TPermission, type TPlatform, TStyleName, buildConditionContext, classifyClass, classifyClassString, evaluateCondition, findRemap, parseSpacing, replaceCalcedValues, resolveAssetSources, resolveAssetUrl, spacingToClasses, transformPageData, transformPagesData };
667
+ export { API_VERSION_PREFIX, CLASS_PATTERNS, CLASS_REMAP, CLIENT_TYPE_MOBILE, CLIENT_TYPE_MOBILE_AND_WEB, CLIENT_TYPE_WEB, COLOR_NAMES, ENDPOINTS, HEADER_CLIENT_TYPE, type IApiError, type IApiMeta, type IAssetSource, type IBaseApiResponse, type IBasePageInfo, type IBasePageSection, type IClassPattern, type IClassRemap, type IConditionContext, IContentField, type IEvaluatedCondition, type IForgotPasswordRequest, type IForgotPasswordResponse, type IFormDeleteRequest, type IFormDeleteResponse, type IFormResultLegacyFields, type IFormSubmitData, type IFormSubmitRequest, type IFormSubmitResponse, type IFormUpdateData, type IFormUpdateRequest, type IFormUpdateResponse, type IGetPageResponse, type IGetPagesResponse, type IJwtPayload, type ILanguage, type ILanguageItem, type ILanguagePreference, type ILanguagePreferenceUpdateResponse, type ILanguagesResponse, type ILoginRequest, type ILoginSuccessData, type ILoginSuccessResponse, type ILogoutSuccessResponse, type IMeta, type IPageAccessTypeInfo, type IPageContent, type IPageField, type IPageFieldTranslation, type IPageFieldsData, type IPageItem, type IPageSectionWithFields, type IPageSectionsData, type IRefreshRequest, type IRefreshSuccessResponse, type IResetPasswordRequest, type IResetPasswordResponse, type ISpacingValue, type ITwoFactorRequiredData, type ITwoFactorRequiredResponse, type ITwoFactorVerifyRequest, type ITwoFactorVerifySuccessResponse, type IUserData, type IUserDataResponse, LITERAL_CLASSES, PERMISSIONS, SIZE_VALUES, SPACING_VALUES, type TCalcedValues, type TClassDecision, type TClientType, type TPermission, type TPlatform, TStyleName, buildConditionContext, classifyClass, classifyClassString, evaluateCondition, findRemap, parseSpacing, replaceCalcedValues, resolveAssetSources, resolveAssetUrl, spacingToClasses, transformPageData, transformPagesData };
package/dist/index.d.ts CHANGED
@@ -244,6 +244,16 @@ interface ITwoFactorVerifyRequest {
244
244
  interface IRefreshRequest {
245
245
  refresh_token: string;
246
246
  }
247
+ /** POST /auth/forgot-password — request a recovery email. */
248
+ interface IForgotPasswordRequest {
249
+ email: string;
250
+ }
251
+ /** POST /auth/reset-password — set a new password from the one-time token. */
252
+ interface IResetPasswordRequest {
253
+ id_users: number;
254
+ token: string;
255
+ password: string;
256
+ }
247
257
  interface ILoginSuccessData {
248
258
  access_token: string;
249
259
  refresh_token: string;
@@ -268,6 +278,18 @@ type ILanguagePreferenceUpdateResponse = IBaseApiResponse<{
268
278
  access_token?: string;
269
279
  language_id: number;
270
280
  }>;
281
+ /**
282
+ * Generic success for the forgot-password request. The backend always returns
283
+ * `requested: true` regardless of whether the email matched an account, so the
284
+ * endpoint cannot be used to enumerate registered users.
285
+ */
286
+ type IForgotPasswordResponse = IBaseApiResponse<{
287
+ requested: boolean;
288
+ }>;
289
+ /** Success when the recovery token was valid and the password was changed. */
290
+ type IResetPasswordResponse = IBaseApiResponse<{
291
+ reset: boolean;
292
+ }>;
271
293
 
272
294
  interface IFormSubmitRequest {
273
295
  section_id: number;
@@ -358,6 +380,8 @@ declare const ENDPOINTS: {
358
380
  readonly TWO_FACTOR_VERIFY: "/cms-api/v1/auth/two-factor-verify";
359
381
  readonly LOGOUT: "/cms-api/v1/auth/logout";
360
382
  readonly REFRESH: "/cms-api/v1/auth/refresh-token";
383
+ readonly FORGOT_PASSWORD: "/cms-api/v1/auth/forgot-password";
384
+ readonly RESET_PASSWORD: "/cms-api/v1/auth/reset-password";
361
385
  readonly SET_LANGUAGE: "/cms-api/v1/auth/set-language";
362
386
  readonly USER_DATA: "/cms-api/v1/auth/user-data";
363
387
  readonly EVENTS: "/cms-api/v1/auth/events";
@@ -640,4 +664,4 @@ declare function transformPageData(apiPage: IRawPage): IPageItem;
640
664
  */
641
665
  declare function transformPagesData(pages: IRawPage[] | null | undefined): IPageItem[];
642
666
 
643
- export { API_VERSION_PREFIX, CLASS_PATTERNS, CLASS_REMAP, CLIENT_TYPE_MOBILE, CLIENT_TYPE_MOBILE_AND_WEB, CLIENT_TYPE_WEB, COLOR_NAMES, ENDPOINTS, HEADER_CLIENT_TYPE, type IApiError, type IApiMeta, type IAssetSource, type IBaseApiResponse, type IBasePageInfo, type IBasePageSection, type IClassPattern, type IClassRemap, type IConditionContext, IContentField, type IEvaluatedCondition, type IFormDeleteRequest, type IFormDeleteResponse, type IFormResultLegacyFields, type IFormSubmitData, type IFormSubmitRequest, type IFormSubmitResponse, type IFormUpdateData, type IFormUpdateRequest, type IFormUpdateResponse, type IGetPageResponse, type IGetPagesResponse, type IJwtPayload, type ILanguage, type ILanguageItem, type ILanguagePreference, type ILanguagePreferenceUpdateResponse, type ILanguagesResponse, type ILoginRequest, type ILoginSuccessData, type ILoginSuccessResponse, type ILogoutSuccessResponse, type IMeta, type IPageAccessTypeInfo, type IPageContent, type IPageField, type IPageFieldTranslation, type IPageFieldsData, type IPageItem, type IPageSectionWithFields, type IPageSectionsData, type IRefreshRequest, type IRefreshSuccessResponse, type ISpacingValue, type ITwoFactorRequiredData, type ITwoFactorRequiredResponse, type ITwoFactorVerifyRequest, type ITwoFactorVerifySuccessResponse, type IUserData, type IUserDataResponse, LITERAL_CLASSES, PERMISSIONS, SIZE_VALUES, SPACING_VALUES, type TCalcedValues, type TClassDecision, type TClientType, type TPermission, type TPlatform, TStyleName, buildConditionContext, classifyClass, classifyClassString, evaluateCondition, findRemap, parseSpacing, replaceCalcedValues, resolveAssetSources, resolveAssetUrl, spacingToClasses, transformPageData, transformPagesData };
667
+ export { API_VERSION_PREFIX, CLASS_PATTERNS, CLASS_REMAP, CLIENT_TYPE_MOBILE, CLIENT_TYPE_MOBILE_AND_WEB, CLIENT_TYPE_WEB, COLOR_NAMES, ENDPOINTS, HEADER_CLIENT_TYPE, type IApiError, type IApiMeta, type IAssetSource, type IBaseApiResponse, type IBasePageInfo, type IBasePageSection, type IClassPattern, type IClassRemap, type IConditionContext, IContentField, type IEvaluatedCondition, type IForgotPasswordRequest, type IForgotPasswordResponse, type IFormDeleteRequest, type IFormDeleteResponse, type IFormResultLegacyFields, type IFormSubmitData, type IFormSubmitRequest, type IFormSubmitResponse, type IFormUpdateData, type IFormUpdateRequest, type IFormUpdateResponse, type IGetPageResponse, type IGetPagesResponse, type IJwtPayload, type ILanguage, type ILanguageItem, type ILanguagePreference, type ILanguagePreferenceUpdateResponse, type ILanguagesResponse, type ILoginRequest, type ILoginSuccessData, type ILoginSuccessResponse, type ILogoutSuccessResponse, type IMeta, type IPageAccessTypeInfo, type IPageContent, type IPageField, type IPageFieldTranslation, type IPageFieldsData, type IPageItem, type IPageSectionWithFields, type IPageSectionsData, type IRefreshRequest, type IRefreshSuccessResponse, type IResetPasswordRequest, type IResetPasswordResponse, type ISpacingValue, type ITwoFactorRequiredData, type ITwoFactorRequiredResponse, type ITwoFactorVerifyRequest, type ITwoFactorVerifySuccessResponse, type IUserData, type IUserDataResponse, LITERAL_CLASSES, PERMISSIONS, SIZE_VALUES, SPACING_VALUES, type TCalcedValues, type TClassDecision, type TClientType, type TPermission, type TPlatform, TStyleName, buildConditionContext, classifyClass, classifyClassString, evaluateCondition, findRemap, parseSpacing, replaceCalcedValues, resolveAssetSources, resolveAssetUrl, spacingToClasses, transformPageData, transformPagesData };
package/dist/index.js CHANGED
@@ -317,6 +317,8 @@ var ENDPOINTS = {
317
317
  TWO_FACTOR_VERIFY: `${API_VERSION_PREFIX}/auth/two-factor-verify`,
318
318
  LOGOUT: `${API_VERSION_PREFIX}/auth/logout`,
319
319
  REFRESH: `${API_VERSION_PREFIX}/auth/refresh-token`,
320
+ FORGOT_PASSWORD: `${API_VERSION_PREFIX}/auth/forgot-password`,
321
+ RESET_PASSWORD: `${API_VERSION_PREFIX}/auth/reset-password`,
320
322
  SET_LANGUAGE: `${API_VERSION_PREFIX}/auth/set-language`,
321
323
  USER_DATA: `${API_VERSION_PREFIX}/auth/user-data`,
322
324
  EVENTS: `${API_VERSION_PREFIX}/auth/events`
package/dist/index.mjs CHANGED
@@ -232,6 +232,8 @@ var ENDPOINTS = {
232
232
  TWO_FACTOR_VERIFY: `${API_VERSION_PREFIX}/auth/two-factor-verify`,
233
233
  LOGOUT: `${API_VERSION_PREFIX}/auth/logout`,
234
234
  REFRESH: `${API_VERSION_PREFIX}/auth/refresh-token`,
235
+ FORGOT_PASSWORD: `${API_VERSION_PREFIX}/auth/forgot-password`,
236
+ RESET_PASSWORD: `${API_VERSION_PREFIX}/auth/reset-password`,
235
237
  SET_LANGUAGE: `${API_VERSION_PREFIX}/auth/set-language`,
236
238
  USER_DATA: `${API_VERSION_PREFIX}/auth/user-data`,
237
239
  EVENTS: `${API_VERSION_PREFIX}/auth/events`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@selfhelp/shared",
3
- "version": "1.2.5",
3
+ "version": "1.3.0",
4
4
  "description": "Shared TypeScript package for SelfHelp web frontend and mobile app: style registry, types, API contracts, Mantine theme tokens, condition + interpolation engines, CMS class allow-list.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,45 @@
1
+ /*
2
+ * SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ import { describe, expect, it } from 'vitest';
7
+ import { API_VERSION_PREFIX, ENDPOINTS } from '../endpoints';
8
+ import type {
9
+ IForgotPasswordRequest,
10
+ IResetPasswordRequest,
11
+ } from '../../types/api/auth';
12
+
13
+ /**
14
+ * Contract coverage for the public auth endpoint catalog. The frontend and the
15
+ * mobile app both build their password-recovery requests from these constants,
16
+ * so a wrong/missing path silently breaks the cross-repo flow (issue #31). The
17
+ * backend serves these under `/cms-api/v1/auth/...`.
18
+ */
19
+ describe('ENDPOINTS.AUTH password recovery', () => {
20
+ it('exposes the forgot-password endpoint at the backend path', () => {
21
+ expect(ENDPOINTS.AUTH.FORGOT_PASSWORD).toBe(
22
+ `${API_VERSION_PREFIX}/auth/forgot-password`,
23
+ );
24
+ });
25
+
26
+ it('exposes the reset-password endpoint at the backend path', () => {
27
+ expect(ENDPOINTS.AUTH.RESET_PASSWORD).toBe(
28
+ `${API_VERSION_PREFIX}/auth/reset-password`,
29
+ );
30
+ });
31
+
32
+ it('models the request DTOs with the backend-required fields', () => {
33
+ const forgot: IForgotPasswordRequest = { email: 'qa.user@selfhelp.test' };
34
+ const reset: IResetPasswordRequest = {
35
+ id_users: 1,
36
+ token: 'qa-token',
37
+ password: 'qa-password-123',
38
+ };
39
+
40
+ expect(Object.keys(forgot)).toEqual(['email']);
41
+ expect(Object.keys(reset).sort()).toEqual(
42
+ ['id_users', 'password', 'token'],
43
+ );
44
+ });
45
+ });
@@ -15,6 +15,8 @@ export const ENDPOINTS = {
15
15
  TWO_FACTOR_VERIFY: `${API_VERSION_PREFIX}/auth/two-factor-verify`,
16
16
  LOGOUT: `${API_VERSION_PREFIX}/auth/logout`,
17
17
  REFRESH: `${API_VERSION_PREFIX}/auth/refresh-token`,
18
+ FORGOT_PASSWORD: `${API_VERSION_PREFIX}/auth/forgot-password`,
19
+ RESET_PASSWORD: `${API_VERSION_PREFIX}/auth/reset-password`,
18
20
  SET_LANGUAGE: `${API_VERSION_PREFIX}/auth/set-language`,
19
21
  USER_DATA: `${API_VERSION_PREFIX}/auth/user-data`,
20
22
  EVENTS: `${API_VERSION_PREFIX}/auth/events`,
@@ -20,6 +20,18 @@ export interface IRefreshRequest {
20
20
  refresh_token: string;
21
21
  }
22
22
 
23
+ /** POST /auth/forgot-password — request a recovery email. */
24
+ export interface IForgotPasswordRequest {
25
+ email: string;
26
+ }
27
+
28
+ /** POST /auth/reset-password — set a new password from the one-time token. */
29
+ export interface IResetPasswordRequest {
30
+ id_users: number;
31
+ token: string;
32
+ password: string;
33
+ }
34
+
23
35
  export interface ILoginSuccessData {
24
36
  access_token: string;
25
37
  refresh_token: string;
@@ -44,3 +56,13 @@ export type ILanguagePreferenceUpdateResponse = IBaseApiResponse<{
44
56
  access_token?: string;
45
57
  language_id: number;
46
58
  }>;
59
+
60
+ /**
61
+ * Generic success for the forgot-password request. The backend always returns
62
+ * `requested: true` regardless of whether the email matched an account, so the
63
+ * endpoint cannot be used to enumerate registered users.
64
+ */
65
+ export type IForgotPasswordResponse = IBaseApiResponse<{ requested: boolean }>;
66
+
67
+ /** Success when the recovery token was valid and the password was changed. */
68
+ export type IResetPasswordResponse = IBaseApiResponse<{ reset: boolean }>;