@digitaldefiance/suite-core-lib 1.0.0 → 1.0.2

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
@@ -290,6 +290,16 @@ MIT © [Digital Defiance](https://github.com/digitaldefiance)
290
290
 
291
291
  ## ChangeLog
292
292
 
293
+ ## v1.0.2: Missing export (IConstants)
294
+
295
+ - Sun Oct 12 2025 14:13:00 GMT-0700 (Pacific Daylight Time)
296
+ - Added missing export for IConstants in src/interfaces/index.ts
297
+
298
+ ## v1.0.1: Add constants/function
299
+
300
+ - Sun Oct 12 2025 13:34:00 GMT-0700 (Pacific Daylight Time)
301
+ - Added more constants and changed to a function to create the constants object
302
+
293
303
  ## v1.0.0: Initial release of user system package
294
304
 
295
305
  - Sun Oct 12 2025 13:26:37 GMT-0700 (Pacific Daylight Time)
@@ -1,5 +1,6 @@
1
1
  import { IBackupCodeConstants } from './interfaces';
2
2
  import { IConstants } from './interfaces/constants';
3
3
  export declare const BACKUP_CODES: IBackupCodeConstants;
4
+ export declare const createConstants: (siteDomain: string, overrides?: Partial<IConstants>) => IConstants;
4
5
  export declare const Constants: IConstants;
5
6
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,eAAO,MAAM,YAAY,EAAE,oBAOjB,CAAC;AAEX,eAAO,MAAM,SAAS,EAAE,UAEvB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,eAAO,MAAM,YAAY,EAAE,oBAOhB,CAAC;AAEZ,eAAO,MAAM,eAAe,EAAE,CAC5B,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,KAC5B,UAqHJ,CAAC;AAEF,eAAO,MAAM,SAAS,YAA+B,CAAC"}
package/dist/constants.js CHANGED
@@ -1,15 +1,126 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Constants = exports.BACKUP_CODES = void 0;
4
- exports.BACKUP_CODES = {
3
+ exports.Constants = exports.createConstants = exports.BACKUP_CODES = void 0;
4
+ const role_1 = require("./enumerations/role");
5
+ exports.BACKUP_CODES = Object.freeze({
5
6
  /**
6
7
  * How many backup codes to generate for users
7
8
  */
8
9
  Count: 10,
9
10
  NormalizedHexRegex: /^[a-z0-9]{32}$/, // exactly 32 lowercase alphanumeric chars
10
11
  DisplayRegex: /^([a-z0-9]{4}-){7}[a-z0-9]{4}$/, // xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx
12
+ });
13
+ const createConstants = (siteDomain, overrides) => {
14
+ const result = {
15
+ /**
16
+ * Default duration in seconds for which a mnemonic is kept in memory
17
+ */
18
+ DefaultExpireMemoryMnemonicSeconds: 300, // 5 minutes
19
+ /**
20
+ * Default duration in seconds for which a wallet is kept in memory
21
+ */
22
+ DefaultExpireMemoryWalletSeconds: 300, // 5 minutes
23
+ /**
24
+ * Duration in milliseconds for which a login challenge is valid.
25
+ */
26
+ LoginChallengeExpiration: 60000, // 60 seconds
27
+ /**
28
+ * The expected length of a direct login challenge in bytes
29
+ */
30
+ DirectLoginChallengeLength: 104,
31
+ /**
32
+ * Backup code system configuration
33
+ */
34
+ BACKUP_CODES: exports.BACKUP_CODES,
35
+ /**
36
+ * Duration in milliseconds for which an email token is valid.
37
+ */
38
+ EmailTokenExpiration: 86400000, // 24 * 60 * 60 * 1000
39
+ /**
40
+ * Length in bytes of the email token generated (is represented as a hex string of twice as many)
41
+ */
42
+ EmailTokenLength: 32,
43
+ /**
44
+ * Number of rounds for bcrypt hashing. Higher values increase security but also consume more CPU resources.
45
+ */
46
+ BcryptRounds: 10,
47
+ /**
48
+ * The username of the administrator user.
49
+ */
50
+ AdministratorUser: 'admin',
51
+ /**
52
+ * The name of the administrator role.
53
+ */
54
+ AdministratorRole: role_1.Role.Admin,
55
+ /**
56
+ * The email of the administrator user/admin contact
57
+ */
58
+ AdministratorEmail: `admin@${siteDomain}`,
59
+ /**
60
+ * The name of the member role.
61
+ */
62
+ MemberRole: role_1.Role.Member,
63
+ /**
64
+ * The email of the test user.
65
+ */
66
+ MemberEmail: `test@${siteDomain}`,
67
+ /**
68
+ * The username of the test user.
69
+ */
70
+ MemberUser: 'test',
71
+ /**
72
+ * The name of the system role.
73
+ */
74
+ SystemRole: role_1.Role.System,
75
+ /**
76
+ * The username of the system user.
77
+ */
78
+ SystemUser: 'system',
79
+ /**
80
+ * The email of the system user.
81
+ */
82
+ SystemEmail: `system@${siteDomain}`,
83
+ /**
84
+ * Minimum username length
85
+ */
86
+ UsernameMinLength: 3,
87
+ /**
88
+ * Maximum username length
89
+ */
90
+ UsernameMaxLength: 30,
91
+ /**
92
+ * The regular expression for valid usernames.
93
+ */
94
+ UsernameRegex: /^[A-Za-z0-9]{3,30}$/,
95
+ /**
96
+ * Minimum password length
97
+ */
98
+ PasswordMinLength: 8,
99
+ /**
100
+ * The regular expression for valid passwords.
101
+ */
102
+ PasswordRegex: /^(?=.*[A-Za-z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?])[A-Za-z\d!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]{8,}$/,
103
+ /**
104
+ * The regular expression for valid mnemonic phrases.
105
+ * BIP39 - supports 12, 15, 18, 21, or 24 word mnemonics
106
+ */
107
+ MnemonicRegex: /^(?:\w+\s){11}\w+$|^(?:\w+\s){14}\w+$|^(?:\w+\s){17}\w+$|^(?:\w+\s){20}\w+$|^(?:\w+\s){23}\w+$/i,
108
+ /**
109
+ * Matches a 64-character hexadecimal string (SHA-256).
110
+ */
111
+ HmacRegex: /^[a-f0-9]{64}$/,
112
+ /**
113
+ * The amount of time in milliseconds after which an email token can be resent.
114
+ */
115
+ EmailTokenResendInterval: 300000, // 5 * 60 * 1000 = 5 minutes
116
+ /**
117
+ * The interval in minutes after which an email token can be resent.
118
+ */
119
+ EmailTokenResendIntervalMinutes: 5,
120
+ ...(overrides ?? {}),
121
+ };
122
+ return Object.freeze(result);
11
123
  };
12
- exports.Constants = {
13
- BACKUP_CODES: exports.BACKUP_CODES,
14
- };
124
+ exports.createConstants = createConstants;
125
+ exports.Constants = (0, exports.createConstants)('localhost');
15
126
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAGa,QAAA,YAAY,GAAyB;IAChD;;OAEG;IACH,KAAK,EAAE,EAAW;IAClB,kBAAkB,EAAE,gBAAgB,EAAE,0CAA0C;IAChF,YAAY,EAAE,gCAAgC,EAAE,0CAA0C;CAClF,CAAC;AAEE,QAAA,SAAS,GAAe;IACnC,YAAY,EAAZ,oBAAY;CACb,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,8CAA2C;AAI9B,QAAA,YAAY,GAAyB,MAAM,CAAC,MAAM,CAAC;IAC9D;;OAEG;IACH,KAAK,EAAE,EAAW;IAClB,kBAAkB,EAAE,gBAAgB,EAAE,0CAA0C;IAChF,YAAY,EAAE,gCAAgC,EAAE,0CAA0C;CAClF,CAAC,CAAC;AAEL,MAAM,eAAe,GAGV,CAAC,UAAkB,EAAE,SAA+B,EAAE,EAAE;IACxE,MAAM,MAAM,GAAG;QACb;;WAEG;QACH,kCAAkC,EAAE,GAAY,EAAE,YAAY;QAC9D;;WAEG;QACH,gCAAgC,EAAE,GAAY,EAAE,YAAY;QAE5D;;WAEG;QAC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C,CAAC"}
@@ -1,5 +1,109 @@
1
1
  import { IBackupCodeConstants } from './backup-code-consts';
2
2
  export interface IConstants {
3
+ /**
4
+ * Backup code related constants
5
+ */
3
6
  BACKUP_CODES: IBackupCodeConstants;
7
+ /**
8
+ * Duration in milliseconds for a login challenge
9
+ */
10
+ LoginChallengeExpiration: number;
11
+ /**
12
+ * Default duration in seconds for which mnemonics are kept in memory
13
+ */
14
+ DefaultExpireMemoryMnemonicSeconds: number;
15
+ /**
16
+ * Default duration in seconds for which wallets are kept in memory
17
+ */
18
+ DefaultExpireMemoryWalletSeconds: number;
19
+ /**
20
+ * The expected length of a direct login challenge in bytes
21
+ */
22
+ DirectLoginChallengeLength: number;
23
+ /**
24
+ * Duration in milliseconds for which an email token is valid.
25
+ */
26
+ EmailTokenExpiration: number;
27
+ /**
28
+ * Length in bytes of the email token generated (is represented as a hex string of twice as many)
29
+ */
30
+ EmailTokenLength: number;
31
+ /**
32
+ * Number of rounds for bcrypt hashing. Higher values increase security but also consume more CPU resources.
33
+ */
34
+ BcryptRounds: number;
35
+ /**
36
+ * The username of the administrator user.
37
+ */
38
+ AdministratorUser: string;
39
+ /**
40
+ * The name of the administrator role.
41
+ */
42
+ AdministratorRole: string;
43
+ /**
44
+ * The email of the administrator user/admin contact
45
+ */
46
+ AdministratorEmail: string;
47
+ /**
48
+ * The name of the member role.
49
+ */
50
+ MemberRole: string;
51
+ /**
52
+ * The email of the test user.
53
+ */
54
+ MemberEmail: string;
55
+ /**
56
+ * The username of the test user.
57
+ */
58
+ MemberUser: string;
59
+ /**
60
+ * The name of the system role.
61
+ */
62
+ SystemRole: string;
63
+ /**
64
+ * The username of the system user.
65
+ */
66
+ SystemUser: string;
67
+ /**
68
+ * The email of the system user.
69
+ */
70
+ SystemEmail: string;
71
+ /**
72
+ * Minimum username length
73
+ */
74
+ UsernameMinLength: number;
75
+ /**
76
+ * Maximum username length
77
+ */
78
+ UsernameMaxLength: number;
79
+ /**
80
+ * The regular expression for valid usernames.
81
+ */
82
+ UsernameRegex: RegExp;
83
+ /**
84
+ * Minimum password length
85
+ */
86
+ PasswordMinLength: number;
87
+ /**
88
+ * The regular expression for valid passwords.
89
+ */
90
+ PasswordRegex: RegExp;
91
+ /**
92
+ * The regular expression for valid mnemonic phrases.
93
+ * BIP39
94
+ */
95
+ MnemonicRegex: RegExp;
96
+ /**
97
+ * The regular expression for valid HMAC keys.
98
+ */
99
+ HmacRegex: RegExp;
100
+ /**
101
+ * The amount of time in milliseconds after which an email token can be resent.
102
+ */
103
+ EmailTokenResendInterval: number;
104
+ /**
105
+ * The interval in minutes after which an email token can be resent.
106
+ */
107
+ EmailTokenResendIntervalMinutes: number;
4
108
  }
5
109
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/interfaces/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,oBAAoB,CAAC;CACpC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/interfaces/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,YAAY,EAAE,oBAAoB,CAAC;IACnC;;OAEG;IACH,wBAAwB,EAAE,MAAM,CAAC;IACjC;;OAEG;IACH,kCAAkC,EAAE,MAAM,CAAC;IAC3C;;OAEG;IACH,gCAAgC,EAAE,MAAM,CAAC;IACzC;;OAEG;IACH,0BAA0B,EAAE,MAAM,CAAC;IACnC;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,wBAAwB,EAAE,MAAM,CAAC;IACjC;;OAEG;IACH,+BAA+B,EAAE,MAAM,CAAC;CACzC"}
@@ -1,6 +1,7 @@
1
1
  export * from './backup-code';
2
2
  export * from './backup-code-consts';
3
3
  export * from './bases';
4
+ export * from './constants';
4
5
  export * from './dto';
5
6
  export * from './has-creation';
6
7
  export * from './has-creator';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,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,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,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,UAAU,CAAC"}
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./backup-code"), exports);
18
18
  __exportStar(require("./backup-code-consts"), exports);
19
19
  __exportStar(require("./bases"), exports);
20
+ __exportStar(require("./constants"), exports);
20
21
  __exportStar(require("./dto"), exports);
21
22
  __exportStar(require("./has-creation"), exports);
22
23
  __exportStar(require("./has-creator"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,uDAAqC;AACrC,0CAAwB;AACxB,wCAAsB;AACtB,iDAA+B;AAC/B,gDAA8B;AAC9B,2CAAyB;AACzB,oDAAkC;AAClC,qDAAmC;AACnC,yDAAuC;AACvC,mDAAiC;AACjC,gDAA8B;AAC9B,gDAA8B;AAC9B,2CAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,uDAAqC;AACrC,0CAAwB;AACxB,8CAA4B;AAC5B,wCAAsB;AACtB,iDAA+B;AAC/B,gDAA8B;AAC9B,2CAAyB;AACzB,oDAAkC;AAClC,qDAAmC;AACnC,yDAAuC;AACvC,mDAAiC;AACjC,gDAA8B;AAC9B,gDAA8B;AAC9B,2CAAyB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/suite-core-lib",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Generic user system and document system common core for applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",