@carecard/auth-util 3.39.0 → 3.41.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.
@@ -159,9 +159,11 @@ depend on those folders being present.
159
159
  key credential is verified.
160
160
  - Generate salts internally for every credential. Never accept caller-selected
161
161
  salts and never persist or log the pepper.
162
- - Normalize well-formed Unicode passwords to NFC before deriving the tag, but
163
- do not trim or impose password policy here. `@carecard/validate` owns policy,
164
- while login intentionally permits existing passwords of any length.
162
+ - Normalize password edge whitespace through `@carecard/validate`, then NFC,
163
+ before deriving the tag. Creation and verification use identical canonical
164
+ bytes; preserve internal spaces. `@carecard/validate` owns password policy.
165
+ Trim outer signed-token whitespace before verification or decomposition,
166
+ preserving the signed contents and canonical signature encoding checks.
165
167
  - Return an invalid verification result for unknown key IDs, malformed,
166
168
  non-canonical, differently parameterized, or legacy saved hashes. Throw for
167
169
  programmer/configuration errors such as an invalid keyring.
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- 24.20.0
1
+ 24.21.0
@@ -108,7 +108,7 @@ function verifyJwtSignature(jwt, verificationJwks) {
108
108
  if (typeof jwt !== 'string') {
109
109
  return false;
110
110
  }
111
- const parts = jwt.split('.');
111
+ const parts = jwt.trim().split('.');
112
112
  if (parts.length !== 3) {
113
113
  return false;
114
114
  }
@@ -129,10 +129,10 @@ function verifyJwtSignature(jwt, verificationJwks) {
129
129
 
130
130
  function getHeaderPayloadFromJwt(jwt) {
131
131
  try {
132
- if (typeof jwt !== 'string' || jwt.split('.').length !== 3) {
132
+ if (typeof jwt !== 'string' || jwt.trim().split('.').length !== 3) {
133
133
  return null;
134
134
  }
135
- const [headerPart, payloadPart] = jwt.split('.');
135
+ const [headerPart, payloadPart] = jwt.trim().split('.');
136
136
  const header = decodeJwtPart(headerPart);
137
137
  const payload = decodeJwtPart(payloadPart);
138
138
  return isDecodedJwtObject(header) && isDecodedJwtObject(payload) ? { header, payload } : null;
@@ -2,6 +2,7 @@
2
2
 
3
3
  const { argon2, randomBytes, timingSafeEqual } = require('node:crypto');
4
4
  const { promisify } = require('node:util');
5
+ const { normalizeInputWhitespace } = require('@carecard/validate');
5
6
 
6
7
  const deriveArgon2Tag = promisify(argon2);
7
8
  const ARGON2_ALGORITHM = 'argon2id';
@@ -17,12 +18,12 @@ const passwordKeyringSecrets = new WeakMap();
17
18
  const PASSWORD_HASH_PATTERN =
18
19
  /^\$argon2id\$v=19\$m=19456,t=2,p=1\$([A-Za-z0-9+/]{22})\$([A-Za-z0-9+/]{43})$/;
19
20
 
20
- // Pattern: Canonicalization - converts well-formed NFC password text to stable UTF-8 bytes.
21
+ // Pattern: Canonicalization - converts trimmed NFC password text to stable UTF-8 bytes.
21
22
  function createPasswordBuffer(password) {
22
23
  if (typeof password !== 'string' || !password.isWellFormed()) {
23
24
  throw new TypeError('Password must be a well-formed Unicode string.');
24
25
  }
25
- return Buffer.from(password.normalize('NFC'), 'utf8');
26
+ return Buffer.from(normalizeInputWhitespace(password).normalize('NFC'), 'utf8');
26
27
  }
27
28
 
28
29
  // Pattern: Serializer Helper - emits canonical unpadded PHC Base64 text.
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@carecard/auth-util",
3
- "version": "3.39.0",
3
+ "version": "3.41.0",
4
4
  "repository": "https://github.com/CareCard-ca/pkg-auth-util.git",
5
5
  "description": "Auth utility functions",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "engines": {
9
- "node": ">=24.20.0 <25"
9
+ "node": ">=24.21.0 <25"
10
10
  },
11
11
  "scripts": {
12
12
  "test": "node scripts/runPackageTask.mjs test",
@@ -31,35 +31,35 @@
31
31
  "author": "CareCard team",
32
32
  "license": "ISC",
33
33
  "devDependencies": {
34
- "@eslint/js": "9.39.5",
34
+ "@eslint/js": "10.0.1",
35
35
  "@istanbuljs/nyc-config-typescript": "1.0.2",
36
36
  "@types/mocha": "10.0.10",
37
- "@types/node": "25.9.9",
38
- "@typescript-eslint/parser": "8.71.0",
39
- "eslint": "9.39.5",
40
- "express": "5.2.1",
37
+ "@types/node": "24.19.2",
38
+ "@typescript-eslint/parser": "8.71.1",
39
+ "eslint": "10.12.0",
40
+ "express": "5.3.0",
41
41
  "globals": "17.13.0",
42
42
  "husky": "9.1.7",
43
43
  "lint-staged": "17.6.0",
44
- "mocha": "11.8.0",
44
+ "mocha": "12.0.3",
45
45
  "nyc": "18.0.0",
46
- "prettier": "3.9.9",
46
+ "prettier": "3.9.10",
47
47
  "source-map-support": "0.5.21",
48
48
  "supertest": "7.3.1",
49
49
  "ts-node": "10.9.2",
50
50
  "typescript": "6.0.3"
51
51
  },
52
52
  "dependencies": {
53
- "@carecard/common-util": "3.39.0",
54
- "@carecard/validate": "3.39.0",
53
+ "@carecard/common-util": "3.41.0",
54
+ "@carecard/validate": "3.41.0",
55
55
  "@types/express": "5.0.6"
56
56
  },
57
57
  "overrides": {
58
- "diff": "8.0.4",
58
+ "diff": "9.0.0",
59
59
  "glob": "13.0.6",
60
60
  "brace-expansion": "5.0.12",
61
61
  "minimatch": "10.2.6",
62
62
  "serialize-javascript": "7.1.2",
63
- "js-yaml": "4.3.2"
63
+ "js-yaml": "5.4.3"
64
64
  }
65
65
  }
package/readme.md CHANGED
@@ -122,8 +122,10 @@ if (result.isValid && result.needsRehash) {
122
122
 
123
123
  Keyring entries use `key-id:canonical-base64-32-byte-key`, separated by commas.
124
124
  Credential rows persist both the PHC hash and its `hashKeyId`; pepper keys stay
125
- outside persisted credentials and logs. Passwords retain spaces and normalize
126
- well-formed Unicode to NFC. `@carecard/validate` owns password policy.
125
+ outside persisted credentials and logs. Passwords trim edge whitespace and
126
+ normalize well-formed Unicode to NFC, preserving internal spaces.
127
+ `@carecard/validate` owns password policy. Signed token verification and
128
+ decomposition trim outer whitespace without rewriting signed token contents.
127
129
 
128
130
  JWT signing configuration is one strict private Ed25519 JWK. Verification
129
131
  configuration is an RFC 7517 JWKS containing one or more public Ed25519 JWKs.