@digitaldefiance/suite-core-lib 3.10.30 → 3.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -60,27 +60,27 @@ import {
60
60
  safeGetSuiteCoreTranslation,
61
61
  SuiteCoreStringKey
62
62
  } from '@digitaldefiance/suite-core-lib';
63
+ import { LanguageCodes } from '@digitaldefiance/i18n-lib';
63
64
 
64
65
  // Direct translation using branded string keys (v3.10.0+)
65
66
  // Component ID is automatically resolved from the branded enum
66
- const message = getSuiteCoreTranslation(SuiteCoreStringKey.Common_Yes);
67
- // Output: "Yes" (or localized equivalent)
67
+ const message = getSuiteCoreTranslation(SuiteCoreStringKey.Auth_UserNotFound);
68
+ // Output: "User account not found" (or localized equivalent)
68
69
 
69
- // With variables
70
- const greeting = getSuiteCoreTranslation(
71
- SuiteCoreStringKey.Welcome_Template,
72
- { name: 'Alice' }
70
+ // With variables (if the string supports them)
71
+ const validation = getSuiteCoreTranslation(
72
+ SuiteCoreStringKey.Validation_InvalidUsername
73
73
  );
74
74
 
75
75
  // With specific language
76
76
  const french = getSuiteCoreTranslation(
77
- SuiteCoreStringKey.Common_Yes,
77
+ SuiteCoreStringKey.Auth_AccountLocked,
78
78
  {},
79
- CoreLanguage.French
79
+ LanguageCodes.FR // or use string directly: 'fr'
80
80
  );
81
81
 
82
82
  // Safe version returns placeholder on failure instead of throwing
83
- const safe = safeGetSuiteCoreTranslation(SuiteCoreStringKey.Common_Yes);
83
+ const safe = safeGetSuiteCoreTranslation(SuiteCoreStringKey.Auth_TokenExpired);
84
84
  ```
85
85
 
86
86
  ## 🏗️ Architecture Overview
@@ -149,13 +149,13 @@ import {
149
149
  } from '@digitaldefiance/suite-core-lib';
150
150
 
151
151
  // Throw errors with automatic localization support
152
- throw new UserNotFoundError(CoreLanguage.French);
152
+ throw new UserNotFoundError(LanguageCodes.French);
153
153
  // Output: "Compte utilisateur introuvable"
154
154
 
155
- throw new UsernameInUseError(CoreLanguage.Spanish);
155
+ throw new UsernameInUseError(LanguageCodes.Spanish);
156
156
  // Output: "El nombre de usuario ya está en uso"
157
157
 
158
- throw new AccountLockedError(CoreLanguage.German);
158
+ throw new AccountLockedError(LanguageCodes.German);
159
159
  // Output: "Konto ist von einem Administrator gesperrt"
160
160
  ```
161
161
 
@@ -384,7 +384,13 @@ import {
384
384
  isValidEmail,
385
385
  isValidPassword,
386
386
  createValidators,
387
- createConstants
387
+ createConstants,
388
+ formatBackupCode,
389
+ normalizeBackupCode,
390
+ isValidBackupCodeFormat,
391
+ hydrateUserSettings,
392
+ dehydrateUserSettings,
393
+ BCP47_TO_FLAG_CDN
388
394
  } from '@digitaldefiance/suite-core-lib';
389
395
 
390
396
  // Use default validators with built-in constants
@@ -403,6 +409,25 @@ const validators = createValidators(myConstants);
403
409
  if (!validators.isValidUsername('user_name')) {
404
410
  throw new Error('Invalid username');
405
411
  }
412
+
413
+ // Format backup codes
414
+ const formatted = formatBackupCode('1234567890ABCDEF'); // "1234-5678-90AB-CDEF"
415
+ const normalized = normalizeBackupCode('1234-5678-90AB-CDEF'); // "1234567890ABCDEF"
416
+ const isValid = isValidBackupCodeFormat('1234-5678-90AB-CDEF'); // true
417
+
418
+ // Hydrate/dehydrate user settings
419
+ const settings = hydrateUserSettings({
420
+ email: 'user@example.com',
421
+ timezone: 'America/New_York',
422
+ currency: 'USD',
423
+ siteLanguage: 'en-US',
424
+ darkMode: false,
425
+ directChallenge: true
426
+ });
427
+ const dto = dehydrateUserSettings(settings);
428
+
429
+ // Map language codes to flag codes for UI
430
+ const flagCode = BCP47_TO_FLAG_CDN['en-US']; // 'us'
406
431
  ```
407
432
 
408
433
  ### Improved Architecture
@@ -561,11 +586,11 @@ describe('Validators', () => {
561
586
  #### Testing Error Handling
562
587
 
563
588
  ```typescript
564
- import { UserNotFoundError, UsernameInUseError, CoreLanguage } from '@digitaldefiance/suite-core-lib';
589
+ import { UserNotFoundError, UsernameInUseError } from '@digitaldefiance/suite-core-lib';
565
590
 
566
591
  describe('Error Handling', () => {
567
592
  it('should throw localized errors', () => {
568
- const error = new UserNotFoundError(CoreLanguage.French);
593
+ const error = new UserNotFoundError(LanguageCodes.French);
569
594
  expect(error.message).toContain('utilisateur');
570
595
  });
571
596
  });
@@ -611,7 +636,7 @@ describe('User Management', () => {
611
636
  - Added `registerStringKeyEnum(SuiteCoreStringKey)` during engine initialization
612
637
  - Updated `getSuiteCoreTranslation()` to use `translateStringKey()` for automatic component ID resolution
613
638
  - Updated `safeGetSuiteCoreTranslation()` to use `safeTranslateStringKey()`
614
- - Changed `SuiteCoreComponentStrings` to use `BrandedMasterStringsCollection<typeof SuiteCoreStringKey, CoreLanguageCode>` for type-safe branded enum support
639
+ - Changed `SuiteCoreComponentStrings` to use `BrandedMasterStringsCollection<typeof SuiteCoreStringKey>` for type-safe branded enum support
615
640
  - Upgraded `@digitaldefiance/ecies-lib` from 4.15.6 to 4.16.20
616
641
  - Upgraded `@digitaldefiance/i18n-lib` from 4.0.5 to 4.2.20
617
642
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/suite-core-lib",
3
- "version": "3.10.30",
3
+ "version": "3.12.1",
4
4
  "homepage": "https://github.com/Digital-Defiance/suite-core-lib",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,8 +28,8 @@
28
28
  "publish:public": "npm publish --access public"
29
29
  },
30
30
  "dependencies": {
31
- "@digitaldefiance/ecies-lib": "4.16.30",
32
- "@digitaldefiance/i18n-lib": "4.3.0"
31
+ "@digitaldefiance/ecies-lib": "4.17.2",
32
+ "@digitaldefiance/i18n-lib": "4.3.2"
33
33
  },
34
34
  "files": [
35
35
  "src",
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @fileoverview Base API message response interface.
3
+ * Defines minimal structure for all API responses.
4
+ * @module interfaces/api-message-response
5
+ */
6
+ /**
7
+ * Base API response with message.
8
+ */
9
+ export interface IApiMessageResponse {
10
+ message: string;
11
+ }
12
+ //# sourceMappingURL=api-message-response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-message-response.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-suite-core-lib/src/interfaces/api-message-response.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Base API message response interface.
4
+ * Defines minimal structure for all API responses.
5
+ * @module interfaces/api-message-response
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ //# sourceMappingURL=api-message-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-message-response.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-suite-core-lib/src/interfaces/api-message-response.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Interface exports for the suite-core library.
3
3
  */
4
+ export type * from './api-message-response';
4
5
  export * from './backup-code';
5
6
  export * from './backup-code-consts';
6
7
  export * from './bases';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-suite-core-lib/src/interfaces/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,OAAO,CAAC;AACtB,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-suite-core-lib/src/interfaces/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,mBAAmB,wBAAwB,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,OAAO,CAAC;AACtB,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- /**
5
- * Interface exports for the suite-core library.
6
- */
7
4
  tslib_1.__exportStar(require("./backup-code"), exports);
8
5
  tslib_1.__exportStar(require("./backup-code-consts"), exports);
9
6
  tslib_1.__exportStar(require("./bases"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-suite-core-lib/src/interfaces/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,wDAA8B;AAC9B,+DAAqC;AACrC,kDAAwB;AACxB,qEAA2C;AAC3C,sDAA4B;AAC5B,wDAA8B;AAC9B,yDAA+B;AAC/B,gDAAsB;AACtB,4DAAkC;AAClC,6DAAmC;AACnC,yDAA+B;AAC/B,wDAA8B;AAC9B,mDAAyB;AACzB,4DAAkC;AAClC,6DAAmC;AACnC,iEAAuC;AACvC,2DAAiC;AACjC,wDAA8B;AAC9B,wDAA8B;AAC9B,4DAAkC;AAClC,uDAA6B;AAC7B,0DAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-suite-core-lib/src/interfaces/index.ts"],"names":[],"mappings":";;;AAIA,wDAA8B;AAC9B,+DAAqC;AACrC,kDAAwB;AACxB,qEAA2C;AAC3C,sDAA4B;AAC5B,wDAA8B;AAC9B,yDAA+B;AAC/B,gDAAsB;AACtB,4DAAkC;AAClC,6DAAmC;AACnC,yDAA+B;AAC/B,wDAA8B;AAC9B,mDAAyB;AACzB,4DAAkC;AAClC,6DAAmC;AACnC,iEAAuC;AACvC,2DAAiC;AACjC,wDAA8B;AAC9B,wDAA8B;AAC9B,4DAAkC;AAClC,uDAA6B;AAC7B,0DAAgC"}