node-opcua-role-set-common 2.174.0 → 2.175.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/README.md CHANGED
@@ -28,6 +28,9 @@ $ npm install node-opcua-role-set-common
28
28
  | `WellKnownRoleIds` | Pre-built `NodeId` objects for each well-known role. |
29
29
  | `saveToBinaryFile` / `loadFromBinaryFile` | Persist / restore a store to / from a binary file. |
30
30
  | `encodeIdentityStore` / `decodeIdentityStore` / `identityStoreBinaryStoreSize` | Lower-level binary (de)serialization helpers. |
31
+ | `InMemoryUserManagementStore` | Local user list + password lifecycle (OPC 10000-18 §5). |
32
+ | `serializeUser` / `credentialRecord` | Build a persisted user record offline (scrypt hash, or wrap an existing credential) — no clear text at rest. |
33
+ | `PasswordHasher` / `HasherRegistry` / `ScryptHasher` / `BcryptHasher` / `defaultHasherRegistry` | Pluggable password hashing (scrypt default; bcrypt coexists). |
31
34
 
32
35
  ## The identity mapping store
33
36
 
@@ -96,6 +99,51 @@ WellKnownRoleIds.ConfigureAdmin;
96
99
  WellKnownRoleIds.SecurityAdmin;
97
100
  ```
98
101
 
102
+ ## Users & password hashing
103
+
104
+ `InMemoryUserManagementStore` keeps the local user list and implements the
105
+ AddUser / ModifyUser / RemoveUser / ChangePassword behaviour (§5.2), the password
106
+ policy, and `authenticate`. **Passwords are never stored in clear**: each user
107
+ holds a single self-describing **PHC credential string**, so multiple hashing
108
+ schemes coexist and are told apart by prefix:
109
+
110
+ ```
111
+ scrypt: $scrypt$ln=14,r=8,p=1$<b64 salt>$<b64 hash> (default — Node core, no extra dependency)
112
+ bcrypt: $2b$10$<salt><hash> (verified for interop/migration)
113
+ ```
114
+
115
+ New and changed passwords are hashed with **scrypt**. A legacy **bcrypt**
116
+ credential still verifies and is transparently re-hashed to scrypt on the next
117
+ successful login (*upgrade-on-login*, driven by `HasherRegistry.needsRehash`).
118
+ Inject a custom `HasherRegistry` to add schemes (e.g. an external verifier).
119
+
120
+ > Credential operations (`authenticate` / `addUser` / `changePassword` /
121
+ > `modifyUser`) are **async** so an external verifier can be plugged in.
122
+
123
+ ### Seeding without clear text
124
+
125
+ Generate a persisted record **offline** and commit that instead of a password:
126
+
127
+ ```ts
128
+ import { InMemoryUserManagementStore, serializeUser, credentialRecord } from "node-opcua-role-set-common";
129
+ import { UserConfigurationMask } from "node-opcua-types";
130
+
131
+ // scrypt record from a clear password (run once at deploy time)
132
+ const rec = await serializeUser("admin", "admin-pw1", { userConfiguration: UserConfigurationMask.None });
133
+
134
+ // or wrap an already-hashed credential you hold (e.g. a legacy bcrypt hash)
135
+ const legacy = credentialRecord("legacy", "$2b$10$……");
136
+
137
+ const store = new InMemoryUserManagementStore();
138
+ store.importUsers([rec, legacy]); // no clear text involved
139
+ await store.authenticate("admin", "admin-pw1"); // -> Good
140
+ ```
141
+
142
+ `serializeUser` / `exportUsers` records are interchangeable and, together with
143
+ `importUsers`, back the consolidated archive (see below). Records written by an
144
+ older release (raw `{salt, hash}`, archive **v1**) are migrated to a `$scrypt$`
145
+ credential on read — **no forced password resets**.
146
+
99
147
  ## Persistence
100
148
 
101
149
  A store can be serialized to a compact binary file using OPC UA binary encoding:
package/dist/archive.d.ts CHANGED
@@ -1,7 +1,13 @@
1
1
  import type { IIdentityMappingStore } from "./identity_mapping_store.js";
2
2
  import type { SerializedRoleRestriction } from "./role_restriction_store.js";
3
- import type { SerializedUserRecord } from "./user_management_store.js";
4
- export declare const ROLE_SET_ARCHIVE_VERSION = 1;
3
+ import type { LegacySerializedUserRecord, SerializedUserRecord } from "./user_management_store.js";
4
+ /**
5
+ * v1: users stored as raw scrypt `{salt, hash}`.
6
+ * v2: users stored as a self-describing PHC `credential` string (scrypt/bcrypt/…).
7
+ * v1 archives are still read (records are migrated on import); v2 archives are
8
+ * rejected by a v1 reader via the version check.
9
+ */
10
+ export declare const ROLE_SET_ARCHIVE_VERSION = 2;
5
11
  /** Persisted definition of a custom Role (so its GUID NodeId survives a restart). */
6
12
  export interface PersistedCustomRole {
7
13
  nodeId: string;
@@ -15,8 +21,12 @@ export interface RoleSetArchive {
15
21
  identities?: string;
16
22
  roles?: PersistedCustomRole[];
17
23
  restrictions?: SerializedRoleRestriction[];
18
- /** UserManagement users with salted scrypt hashes (never clear passwords). */
19
- users?: SerializedUserRecord[];
24
+ /**
25
+ * UserManagement users, credentials only (never clear passwords). v2 writes
26
+ * PHC {@link SerializedUserRecord}s; v1 archives are read as
27
+ * {@link LegacySerializedUserRecord}s and migrated on import.
28
+ */
29
+ users?: (SerializedUserRecord | LegacySerializedUserRecord)[];
20
30
  }
21
31
  /** Encode the identity store as a base64 string (reuses the binary encoder). */
22
32
  export declare function identitiesToBase64(store: IIdentityMappingStore): string;
package/dist/archive.js CHANGED
@@ -30,7 +30,13 @@ const node_fs_1 = require("node:fs");
30
30
  const node_path_1 = require("node:path");
31
31
  const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");
32
32
  const binary_persistence_js_1 = require("./binary_persistence.js");
33
- exports.ROLE_SET_ARCHIVE_VERSION = 1;
33
+ /**
34
+ * v1: users stored as raw scrypt `{salt, hash}`.
35
+ * v2: users stored as a self-describing PHC `credential` string (scrypt/bcrypt/…).
36
+ * v1 archives are still read (records are migrated on import); v2 archives are
37
+ * rejected by a v1 reader via the version check.
38
+ */
39
+ exports.ROLE_SET_ARCHIVE_VERSION = 2;
34
40
  /** Encode the identity store as a base64 string (reuses the binary encoder). */
35
41
  function identitiesToBase64(store) {
36
42
  const size = (0, binary_persistence_js_1.identityStoreBinaryStoreSize)(store);
@@ -1 +1 @@
1
- {"version":3,"file":"archive.js","sourceRoot":"","sources":["../source/archive.ts"],"names":[],"mappings":";;;AAkDA,gDAKC;AAGD,oDAKC;AA2CD,oCAUC;AAGD,kCAyCC;AAhKD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,6CAAwF;AACxF,qCAAyC;AACzC,yCAAoC;AACpC,uEAAwD;AACxD,mEAAiH;AAKpG,QAAA,wBAAwB,GAAG,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KAAK;SAC3D,CAAC;QACF,MAAM,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QACrD,8DAA8D;QAC9D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;CACJ;AApDD,oCAoDC"}
package/dist/index.d.ts CHANGED
@@ -5,7 +5,8 @@ export { type ArchiveIO, ArchiveStore, identitiesFromBase64, identitiesToBase64,
5
5
  export { decodeIdentityStore, encodeIdentityStore, identityStoreBinaryStoreSize, loadFromBinaryFile, saveToBinaryFile } from "./binary_persistence.js";
6
6
  export type { AnyUserIdentityToken, IIdentityMappingStore } from "./identity_mapping_store.js";
7
7
  export { InMemoryIdentityMappingStore } from "./in_memory_store.js";
8
+ export { BcryptHasher, defaultHasherRegistry, HasherRegistry, type PasswordHasher, ScryptHasher, scryptPhc } from "./password_hasher.js";
8
9
  export { applicationComplies, deserializeRestrictions, type EndpointCriteria, endpointComplies, InMemoryRoleRestrictionStore, type IRoleRestrictionStore, loadRestrictionsFromFile, type ResolutionContext, type SerializedRoleRestriction, saveRestrictionsToFile, serializeRestrictions } from "./role_restriction_store.js";
9
- export { type AuthenticationResult, InMemoryUserManagementStore, type IUserManagementStore, type ModifyUserOptions, type PasswordPolicy, type SerializedUserRecord, type UserRecord } from "./user_management_store.js";
10
+ export { type AuthenticationResult, credentialRecord, InMemoryUserManagementStore, type IUserManagementStore, type LegacySerializedUserRecord, type ModifyUserOptions, type PasswordPolicy, type SerializedUserRecord, serializeUser, type UserRecord, validateUserConfiguration } from "./user_management_store.js";
10
11
  export { WellKnownRoleIds, WellKnownRoles } from "./well_known_role_ids.js";
11
12
  export { canonicalizeX509Subject, certificateSubjectPairs, matchX509Subject, parseX509SubjectCriteria, X509_SUBJECT_ORDER, type X509SubjectName } from "./x509_subject.js";
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * @module node-opcua-role-set-common
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.X509_SUBJECT_ORDER = exports.parseX509SubjectCriteria = exports.matchX509Subject = exports.certificateSubjectPairs = exports.canonicalizeX509Subject = exports.WellKnownRoles = exports.WellKnownRoleIds = exports.InMemoryUserManagementStore = exports.serializeRestrictions = exports.saveRestrictionsToFile = exports.loadRestrictionsFromFile = exports.InMemoryRoleRestrictionStore = exports.endpointComplies = exports.deserializeRestrictions = exports.applicationComplies = exports.InMemoryIdentityMappingStore = exports.saveToBinaryFile = exports.loadFromBinaryFile = exports.identityStoreBinaryStoreSize = exports.encodeIdentityStore = exports.decodeIdentityStore = exports.writeArchive = exports.readArchive = exports.ROLE_SET_ARCHIVE_VERSION = exports.identitiesToBase64 = exports.identitiesFromBase64 = exports.ArchiveStore = void 0;
6
+ exports.X509_SUBJECT_ORDER = exports.parseX509SubjectCriteria = exports.matchX509Subject = exports.certificateSubjectPairs = exports.canonicalizeX509Subject = exports.WellKnownRoles = exports.WellKnownRoleIds = exports.validateUserConfiguration = exports.serializeUser = exports.InMemoryUserManagementStore = exports.credentialRecord = exports.serializeRestrictions = exports.saveRestrictionsToFile = exports.loadRestrictionsFromFile = exports.InMemoryRoleRestrictionStore = exports.endpointComplies = exports.deserializeRestrictions = exports.applicationComplies = exports.scryptPhc = exports.ScryptHasher = exports.HasherRegistry = exports.defaultHasherRegistry = exports.BcryptHasher = exports.InMemoryIdentityMappingStore = exports.saveToBinaryFile = exports.loadFromBinaryFile = exports.identityStoreBinaryStoreSize = exports.encodeIdentityStore = exports.decodeIdentityStore = exports.writeArchive = exports.readArchive = exports.ROLE_SET_ARCHIVE_VERSION = exports.identitiesToBase64 = exports.identitiesFromBase64 = exports.ArchiveStore = void 0;
7
7
  var archive_js_1 = require("./archive.js");
8
8
  Object.defineProperty(exports, "ArchiveStore", { enumerable: true, get: function () { return archive_js_1.ArchiveStore; } });
9
9
  Object.defineProperty(exports, "identitiesFromBase64", { enumerable: true, get: function () { return archive_js_1.identitiesFromBase64; } });
@@ -19,6 +19,12 @@ Object.defineProperty(exports, "loadFromBinaryFile", { enumerable: true, get: fu
19
19
  Object.defineProperty(exports, "saveToBinaryFile", { enumerable: true, get: function () { return binary_persistence_js_1.saveToBinaryFile; } });
20
20
  var in_memory_store_js_1 = require("./in_memory_store.js");
21
21
  Object.defineProperty(exports, "InMemoryIdentityMappingStore", { enumerable: true, get: function () { return in_memory_store_js_1.InMemoryIdentityMappingStore; } });
22
+ var password_hasher_js_1 = require("./password_hasher.js");
23
+ Object.defineProperty(exports, "BcryptHasher", { enumerable: true, get: function () { return password_hasher_js_1.BcryptHasher; } });
24
+ Object.defineProperty(exports, "defaultHasherRegistry", { enumerable: true, get: function () { return password_hasher_js_1.defaultHasherRegistry; } });
25
+ Object.defineProperty(exports, "HasherRegistry", { enumerable: true, get: function () { return password_hasher_js_1.HasherRegistry; } });
26
+ Object.defineProperty(exports, "ScryptHasher", { enumerable: true, get: function () { return password_hasher_js_1.ScryptHasher; } });
27
+ Object.defineProperty(exports, "scryptPhc", { enumerable: true, get: function () { return password_hasher_js_1.scryptPhc; } });
22
28
  var role_restriction_store_js_1 = require("./role_restriction_store.js");
23
29
  Object.defineProperty(exports, "applicationComplies", { enumerable: true, get: function () { return role_restriction_store_js_1.applicationComplies; } });
24
30
  Object.defineProperty(exports, "deserializeRestrictions", { enumerable: true, get: function () { return role_restriction_store_js_1.deserializeRestrictions; } });
@@ -28,7 +34,10 @@ Object.defineProperty(exports, "loadRestrictionsFromFile", { enumerable: true, g
28
34
  Object.defineProperty(exports, "saveRestrictionsToFile", { enumerable: true, get: function () { return role_restriction_store_js_1.saveRestrictionsToFile; } });
29
35
  Object.defineProperty(exports, "serializeRestrictions", { enumerable: true, get: function () { return role_restriction_store_js_1.serializeRestrictions; } });
30
36
  var user_management_store_js_1 = require("./user_management_store.js");
37
+ Object.defineProperty(exports, "credentialRecord", { enumerable: true, get: function () { return user_management_store_js_1.credentialRecord; } });
31
38
  Object.defineProperty(exports, "InMemoryUserManagementStore", { enumerable: true, get: function () { return user_management_store_js_1.InMemoryUserManagementStore; } });
39
+ Object.defineProperty(exports, "serializeUser", { enumerable: true, get: function () { return user_management_store_js_1.serializeUser; } });
40
+ Object.defineProperty(exports, "validateUserConfiguration", { enumerable: true, get: function () { return user_management_store_js_1.validateUserConfiguration; } });
32
41
  var well_known_role_ids_js_1 = require("./well_known_role_ids.js");
33
42
  Object.defineProperty(exports, "WellKnownRoleIds", { enumerable: true, get: function () { return well_known_role_ids_js_1.WellKnownRoleIds; } });
34
43
  Object.defineProperty(exports, "WellKnownRoles", { enumerable: true, get: function () { return well_known_role_ids_js_1.WellKnownRoles; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,2CAUsB;AARlB,0GAAA,YAAY,OAAA;AACZ,kHAAA,oBAAoB,OAAA;AACpB,gHAAA,kBAAkB,OAAA;AAElB,sHAAA,wBAAwB,OAAA;AAExB,yGAAA,WAAW,OAAA;AACX,0GAAA,YAAY,OAAA;AAEhB,iEAMiC;AAL7B,4HAAA,mBAAmB,OAAA;AACnB,4HAAA,mBAAmB,OAAA;AACnB,qIAAA,4BAA4B,OAAA;AAC5B,2HAAA,kBAAkB,OAAA;AAClB,yHAAA,gBAAgB,OAAA;AAGpB,2DAAoE;AAA3D,kIAAA,4BAA4B,OAAA;AACrC,yEAYqC;AAXjC,gIAAA,mBAAmB,OAAA;AACnB,oIAAA,uBAAuB,OAAA;AAEvB,6HAAA,gBAAgB,OAAA;AAChB,yIAAA,4BAA4B,OAAA;AAE5B,qIAAA,wBAAwB,OAAA;AAGxB,mIAAA,sBAAsB,OAAA;AACtB,kIAAA,qBAAqB,OAAA;AAEzB,uEAQoC;AANhC,uIAAA,2BAA2B,OAAA;AAO/B,mEAA4E;AAAnE,0HAAA,gBAAgB,OAAA;AAAE,wHAAA,cAAc,OAAA;AACzC,qDAO2B;AANvB,0HAAA,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B,2HAAA,wBAAwB,OAAA;AACxB,qHAAA,kBAAkB,OAAA"}
@@ -0,0 +1,57 @@
1
+ /** A single password-hashing scheme. All operations are async (LDAP/argon2-ready). */
2
+ export interface PasswordHasher {
3
+ /** Canonical scheme id, e.g. `"scrypt"`, `"bcrypt"`. */
4
+ readonly id: string;
5
+ /** PHC prefixes this hasher verifies, e.g. `["$scrypt$"]` or `["$2a$", "$2b$", "$2y$"]`. */
6
+ readonly prefixes: readonly string[];
7
+ /** Hash a clear-text password into a full PHC string. */
8
+ hash(password: string): Promise<string>;
9
+ /** Verify a clear-text password against a PHC string produced by this scheme. */
10
+ verify(password: string, phc: string): Promise<boolean>;
11
+ /** True when a credential should be re-hashed after a successful login (e.g. cost drifted). */
12
+ needsRehash?(phc: string): boolean;
13
+ }
14
+ /** Build the canonical scrypt PHC string from a base64 salt + hash. */
15
+ export declare function scryptPhc(saltB64: string, hashB64: string, params?: {
16
+ ln?: number;
17
+ r?: number;
18
+ p?: number;
19
+ }): string;
20
+ export declare class ScryptHasher implements PasswordHasher {
21
+ readonly id = "scrypt";
22
+ readonly prefixes: readonly ["$scrypt$"];
23
+ hash(password: string): Promise<string>;
24
+ verify(password: string, phc: string): Promise<boolean>;
25
+ needsRehash(phc: string): boolean;
26
+ }
27
+ export declare class BcryptHasher implements PasswordHasher {
28
+ private readonly _cost;
29
+ readonly id = "bcrypt";
30
+ readonly prefixes: readonly ["$2a$", "$2b$", "$2y$"];
31
+ constructor(_cost?: number);
32
+ hash(password: string): Promise<string>;
33
+ verify(password: string, phc: string): Promise<boolean>;
34
+ needsRehash(): boolean;
35
+ }
36
+ export declare class HasherRegistry {
37
+ private readonly _default;
38
+ private readonly _all;
39
+ constructor(_default: PasswordHasher, others?: readonly PasswordHasher[]);
40
+ get defaultId(): string;
41
+ /** Hash a new/changed password with the configured default scheme. */
42
+ hash(password: string): Promise<string>;
43
+ /** Verify against whichever registered scheme owns the credential's prefix. */
44
+ verify(password: string, phc: string): Promise<boolean>;
45
+ /**
46
+ * True when the credential should be re-hashed with the default after a
47
+ * successful login: a different scheme than the default, or the same scheme
48
+ * reporting drifted parameters.
49
+ */
50
+ needsRehash(phc: string): boolean;
51
+ private _find;
52
+ }
53
+ /**
54
+ * Default registry: **scrypt** hashes and verifies (Node core), **bcrypt**
55
+ * verifies legacy credentials and is upgraded to scrypt on next login.
56
+ */
57
+ export declare function defaultHasherRegistry(): HasherRegistry;
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.HasherRegistry = exports.BcryptHasher = exports.ScryptHasher = void 0;
7
+ exports.scryptPhc = scryptPhc;
8
+ exports.defaultHasherRegistry = defaultHasherRegistry;
9
+ /**
10
+ * @module node-opcua-role-set-common
11
+ *
12
+ * Pluggable password hashing (OPC 10000-18 §5 credentials).
13
+ *
14
+ * Each stored credential is a single self-describing **PHC / modular-crypt
15
+ * string** so multiple schemes can coexist and be told apart by prefix:
16
+ *
17
+ * ```
18
+ * scrypt: $scrypt$ln=<log2N>,r=<r>,p=<p>$<b64 salt>$<b64 hash>
19
+ * bcrypt: $2b$<cost>$<22-char salt><31-char hash> (bcrypt's native format)
20
+ * ```
21
+ *
22
+ * A {@link HasherRegistry} verifies a credential by routing on its prefix and
23
+ * always *hashes* new credentials with the configured default (scrypt — Node
24
+ * core, zero extra dependency). Because non-default schemes report
25
+ * {@link PasswordHasher.needsRehash}=true, a store can transparently migrate a
26
+ * legacy credential to the default algorithm on the next successful login
27
+ * ("upgrade-on-login"). Additional schemes (bcrypt today, LDAP/argon2 later)
28
+ * are just more {@link PasswordHasher}s in the registry.
29
+ */
30
+ const node_crypto_1 = require("node:crypto");
31
+ const bcryptjs_1 = __importDefault(require("bcryptjs"));
32
+ // ---------------------------------------------------------------------------
33
+ // scrypt (default — Node core, no extra dependency)
34
+ // ---------------------------------------------------------------------------
35
+ const SCRYPT_N = 16384; // ln = 14
36
+ const SCRYPT_R = 8;
37
+ const SCRYPT_P = 1;
38
+ const SCRYPT_KEYLEN = 64;
39
+ const SCRYPT_SALT_BYTES = 16;
40
+ const SCRYPT_LN = Math.log2(SCRYPT_N);
41
+ // Upper bounds on the work factors accepted from a stored credential string.
42
+ // A tampered/poisoned credential (e.g. an edited archive) must not be able to
43
+ // set huge parameters and cause resource exhaustion during login, so anything
44
+ // out of range is rejected (parseScrypt returns null → verify() fails closed).
45
+ // The default (ln=14, r=8, p=1) sits comfortably below these limits.
46
+ const SCRYPT_LN_MAX = 20; // N = 2^20 (~1M) — beyond any legitimate configuration here
47
+ const SCRYPT_R_MAX = 32;
48
+ const SCRYPT_P_MAX = 16;
49
+ /** Build the canonical scrypt PHC string from a base64 salt + hash. */
50
+ function scryptPhc(saltB64, hashB64, params) {
51
+ const ln = params?.ln ?? SCRYPT_LN;
52
+ const r = params?.r ?? SCRYPT_R;
53
+ const p = params?.p ?? SCRYPT_P;
54
+ return `$scrypt$ln=${ln},r=${r},p=${p}$${saltB64}$${hashB64}`;
55
+ }
56
+ function parseScrypt(phc) {
57
+ // $scrypt$ln=14,r=8,p=1$<salt>$<hash>
58
+ const m = /^\$scrypt\$ln=(\d+),r=(\d+),p=(\d+)\$([^$]+)\$([^$]+)$/.exec(phc);
59
+ if (!m)
60
+ return null;
61
+ const ln = Number(m[1]);
62
+ const r = Number(m[2]);
63
+ const p = Number(m[3]);
64
+ // Reject out-of-range work factors so a tampered credential can't force an
65
+ // absurd scryptSync cost. Fails closed: verify() treats null as "no match".
66
+ if (ln < 1 || ln > SCRYPT_LN_MAX || r < 1 || r > SCRYPT_R_MAX || p < 1 || p > SCRYPT_P_MAX) {
67
+ return null;
68
+ }
69
+ return {
70
+ ln,
71
+ r,
72
+ p,
73
+ salt: Buffer.from(m[4], "base64"),
74
+ hash: Buffer.from(m[5], "base64")
75
+ };
76
+ }
77
+ class ScryptHasher {
78
+ id = "scrypt";
79
+ prefixes = ["$scrypt$"];
80
+ async hash(password) {
81
+ const salt = (0, node_crypto_1.randomBytes)(SCRYPT_SALT_BYTES);
82
+ const hash = (0, node_crypto_1.scryptSync)(password, salt, SCRYPT_KEYLEN, { N: SCRYPT_N, r: SCRYPT_R, p: SCRYPT_P });
83
+ return scryptPhc(salt.toString("base64"), hash.toString("base64"));
84
+ }
85
+ async verify(password, phc) {
86
+ const parsed = parseScrypt(phc);
87
+ if (!parsed)
88
+ return false;
89
+ const candidate = (0, node_crypto_1.scryptSync)(password, parsed.salt, parsed.hash.length, {
90
+ N: 2 ** parsed.ln,
91
+ r: parsed.r,
92
+ p: parsed.p
93
+ });
94
+ return candidate.length === parsed.hash.length && (0, node_crypto_1.timingSafeEqual)(candidate, parsed.hash);
95
+ }
96
+ needsRehash(phc) {
97
+ const parsed = parseScrypt(phc);
98
+ // Re-hash if unparsable or the work factors drifted below the current defaults.
99
+ return !parsed || parsed.ln !== SCRYPT_LN || parsed.r !== SCRYPT_R || parsed.p !== SCRYPT_P;
100
+ }
101
+ }
102
+ exports.ScryptHasher = ScryptHasher;
103
+ // ---------------------------------------------------------------------------
104
+ // bcrypt (verify-only default: migrated to scrypt on next login)
105
+ // ---------------------------------------------------------------------------
106
+ class BcryptHasher {
107
+ _cost;
108
+ id = "bcrypt";
109
+ prefixes = ["$2a$", "$2b$", "$2y$"];
110
+ constructor(_cost = 10) {
111
+ this._cost = _cost;
112
+ }
113
+ async hash(password) {
114
+ return bcryptjs_1.default.hash(password, this._cost);
115
+ }
116
+ async verify(password, phc) {
117
+ return bcryptjs_1.default.compare(password, phc);
118
+ }
119
+ // bcrypt is only kept for interop/migration — always upgrade to the default.
120
+ needsRehash() {
121
+ return true;
122
+ }
123
+ }
124
+ exports.BcryptHasher = BcryptHasher;
125
+ // ---------------------------------------------------------------------------
126
+ // Registry — hash with the default, verify by routing on the PHC prefix
127
+ // ---------------------------------------------------------------------------
128
+ class HasherRegistry {
129
+ _default;
130
+ _all;
131
+ constructor(_default, others = []) {
132
+ this._default = _default;
133
+ this._all = [_default, ...others];
134
+ }
135
+ get defaultId() {
136
+ return this._default.id;
137
+ }
138
+ /** Hash a new/changed password with the configured default scheme. */
139
+ hash(password) {
140
+ return this._default.hash(password);
141
+ }
142
+ /** Verify against whichever registered scheme owns the credential's prefix. */
143
+ async verify(password, phc) {
144
+ const hasher = this._find(phc);
145
+ return hasher ? hasher.verify(password, phc) : false;
146
+ }
147
+ /**
148
+ * True when the credential should be re-hashed with the default after a
149
+ * successful login: a different scheme than the default, or the same scheme
150
+ * reporting drifted parameters.
151
+ */
152
+ needsRehash(phc) {
153
+ const hasher = this._find(phc);
154
+ if (!hasher)
155
+ return false;
156
+ if (hasher !== this._default)
157
+ return true;
158
+ return hasher.needsRehash ? hasher.needsRehash(phc) : false;
159
+ }
160
+ _find(phc) {
161
+ return this._all.find((h) => h.prefixes.some((prefix) => phc.startsWith(prefix)));
162
+ }
163
+ }
164
+ exports.HasherRegistry = HasherRegistry;
165
+ /**
166
+ * Default registry: **scrypt** hashes and verifies (Node core), **bcrypt**
167
+ * verifies legacy credentials and is upgraded to scrypt on next login.
168
+ */
169
+ function defaultHasherRegistry() {
170
+ return new HasherRegistry(new ScryptHasher(), [new BcryptHasher()]);
171
+ }
172
+ //# sourceMappingURL=password_hasher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"password_hasher.js","sourceRoot":"","sources":["../source/password_hasher.ts"],"names":[],"mappings":";;;;;;AAmEA,8BAKC;AA6HD,sDAEC;AAvMD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,6CAAuE;AACvE,wDAA8B;AAgB9B,8EAA8E;AAC9E,oDAAoD;AACpD,8EAA8E;AAE9E,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,UAAU;AAClC,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,iBAAiB,G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provides the local user list and
5
+ * password lifecycle used by the `UserName` identity criteria.
6
+ *
7
+ * The store implements the behaviour of the AddUser / ModifyUser / RemoveUser
8
+ * / ChangePassword Methods and the password policy (PasswordLength range and
9
+ * the password-option requirements). Passwords are never stored in clear: each
10
+ * is kept as a self-describing PHC credential string (scrypt by default; other
11
+ * schemes such as bcrypt coexist and are migrated on login — see
12
+ * {@link HasherRegistry}). Credential operations are **async** so an external
13
+ * verifier (LDAP/argon2) can be plugged in without another interface change.
14
+ */
1
15
  import { type StatusCode } from "node-opcua-status-code";
2
16
  import { UserConfigurationMask } from "node-opcua-types";
17
+ import { type HasherRegistry } from "./password_hasher.js";
3
18
  /**
4
19
  * Password requirements (OPC 10000-18 §5.2.1-2: PasswordLength range and
5
20
  * PasswordOptionsMask). A length of 0 means "no limit".
@@ -19,10 +34,24 @@ export interface UserRecord {
19
34
  description: string;
20
35
  }
21
36
  /**
22
- * Persisted user record — includes the salted scrypt hash (base64), never the
23
- * clear password. Suitable for storing in the consolidated archive.
37
+ * Persisted user record (archive v2) — the credential is a self-describing PHC
38
+ * string (e.g. `$scrypt$…` / `$2b$…`), never a clear password. Suitable for
39
+ * storing in the consolidated archive.
24
40
  */
25
41
  export interface SerializedUserRecord {
42
+ userName: string;
43
+ /** PHC / modular-crypt credential string (scheme self-described by its prefix). */
44
+ credential: string;
45
+ userConfiguration: UserConfigurationMask;
46
+ description: string;
47
+ }
48
+ /**
49
+ * Legacy (archive v1) persisted record — raw scrypt `salt`+`hash` (base64).
50
+ * Accepted by {@link IUserManagementStore.importUsers} and read-migrated to a
51
+ * `$scrypt$…` {@link SerializedUserRecord} credential, so old archives keep
52
+ * working with **no forced password resets**.
53
+ */
54
+ export interface LegacySerializedUserRecord {
26
55
  userName: string;
27
56
  salt: string;
28
57
  hash: string;
@@ -45,18 +74,48 @@ export interface ModifyUserOptions {
45
74
  description?: string;
46
75
  }
47
76
  export interface IUserManagementStore {
48
- addUser(userName: string, password: string, userConfiguration: UserConfigurationMask, description: string): StatusCode;
49
- modifyUser(userName: string, options: ModifyUserOptions, callerUserName?: string): StatusCode;
77
+ addUser(userName: string, password: string, userConfiguration: UserConfigurationMask, description: string): Promise<StatusCode>;
78
+ modifyUser(userName: string, options: ModifyUserOptions, callerUserName?: string): Promise<StatusCode>;
50
79
  removeUser(userName: string, callerUserName?: string): StatusCode;
51
- changePassword(userName: string, oldPassword: string, newPassword: string): StatusCode;
52
- authenticate(userName: string, password: string): AuthenticationResult;
80
+ changePassword(userName: string, oldPassword: string, newPassword: string): Promise<StatusCode>;
81
+ authenticate(userName: string, password: string): Promise<AuthenticationResult>;
53
82
  getUsers(): UserRecord[];
54
83
  hasUser(userName: string): boolean;
55
- /** Export every user (with salted hash) for persistence. Optional: only stores that support persistence. */
84
+ /** Export every user (with its PHC credential) for persistence. Optional: only stores that support persistence. */
56
85
  exportUsers?(): SerializedUserRecord[];
57
- /** Load persisted users (with salted hash), replacing any existing entry of the same name. */
58
- importUsers?(records: SerializedUserRecord[]): void;
86
+ /** Load persisted users (v2 credential or legacy v1 salt+hash), replacing any existing entry of the same name. */
87
+ importUsers?(records: readonly (SerializedUserRecord | LegacySerializedUserRecord)[]): void;
88
+ /**
89
+ * Optional: register a callback fired when a credential is transparently
90
+ * re-hashed during {@link authenticate} (upgrade-on-login), so a persistence
91
+ * layer can flush the new hash.
92
+ */
93
+ setOnCredentialUpgraded?(fn: (userName: string) => void): void;
59
94
  }
95
+ /**
96
+ * Produce a {@link SerializedUserRecord} (scrypt PHC credential) from a
97
+ * clear-text password — **offline**, without a store.
98
+ *
99
+ * Use this to keep clear-text passwords out of version control / config: run it
100
+ * once at deploy time and commit only the returned record, then seed it through
101
+ * `importUsers` (or `createRoleBasedSecurity`'s `passwordHash`). The record is
102
+ * interchangeable with what {@link InMemoryUserManagementStore.exportUsers}
103
+ * produces, so `authenticate` accepts the original clear-text password.
104
+ */
105
+ export declare function serializeUser(userName: string, password: string, options?: {
106
+ userConfiguration?: UserConfigurationMask;
107
+ description?: string;
108
+ }): Promise<SerializedUserRecord>;
109
+ /**
110
+ * Wrap an **already-hashed** PHC credential string (e.g. a legacy `$2b$…`
111
+ * bcrypt hash) into a {@link SerializedUserRecord} — no clear text, no
112
+ * re-hashing. The credential is verified by whichever registered scheme owns
113
+ * its prefix, and (for non-default schemes) upgraded on next login.
114
+ */
115
+ export declare function credentialRecord(userName: string, credential: string, options?: {
116
+ userConfiguration?: UserConfigurationMask;
117
+ description?: string;
118
+ }): SerializedUserRecord;
60
119
  /**
61
120
  * In-memory implementation of {@link IUserManagementStore}.
62
121
  *
@@ -65,19 +124,29 @@ export interface IUserManagementStore {
65
124
  export declare class InMemoryUserManagementStore implements IUserManagementStore {
66
125
  private readonly _users;
67
126
  private readonly _policy;
68
- constructor(policy?: PasswordPolicy);
127
+ private readonly _registry;
128
+ private _onCredentialUpgraded?;
129
+ constructor(policy?: PasswordPolicy, options?: {
130
+ registry?: HasherRegistry;
131
+ });
69
132
  get policy(): PasswordPolicy;
133
+ setOnCredentialUpgraded(fn: (userName: string) => void): void;
70
134
  hasUser(userName: string): boolean;
71
135
  getUsers(): UserRecord[];
72
136
  exportUsers(): SerializedUserRecord[];
73
- importUsers(records: SerializedUserRecord[]): void;
74
- addUser(userName: string, password: string, userConfiguration: UserConfigurationMask, description: string): StatusCode;
75
- modifyUser(userName: string, options: ModifyUserOptions, callerUserName?: string): StatusCode;
137
+ importUsers(records: readonly (SerializedUserRecord | LegacySerializedUserRecord)[]): void;
138
+ addUser(userName: string, password: string, userConfiguration: UserConfigurationMask, description: string): Promise<StatusCode>;
139
+ modifyUser(userName: string, options: ModifyUserOptions, callerUserName?: string): Promise<StatusCode>;
76
140
  removeUser(userName: string, callerUserName?: string): StatusCode;
77
- changePassword(userName: string, oldPassword: string, newPassword: string): StatusCode;
78
- authenticate(userName: string, password: string): AuthenticationResult;
141
+ changePassword(userName: string, oldPassword: string, newPassword: string): Promise<StatusCode>;
142
+ authenticate(userName: string, password: string): Promise<AuthenticationResult>;
79
143
  /** Validate a candidate password against the configured policy. */
80
144
  isPasswordValid(password: string): boolean;
81
- private hashPassword;
82
- private verify;
83
145
  }
146
+ /**
147
+ * Validate a UserConfigurationMask combination (OPC 10000-18 §5.2.3):
148
+ * MustChangePassword is invalid when NoChangeByUser is also set.
149
+ *
150
+ * @returns a `Bad_ConfigurationError` StatusCode, or `null` if valid.
151
+ */
152
+ export declare function validateUserConfiguration(mask: UserConfigurationMask): StatusCode | null;