@vlasky/shacrypt 0.4.0 → 0.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.1] - 2026-01-29
4
+
5
+ ### Added
6
+ - TypeScript type declarations (`index.d.ts`)
7
+
8
+ ## [0.5.0] - 2026-01-28
9
+
10
+ ### Changed
11
+ - **Breaking:** Minimum Node.js version is now 18.0.0
12
+ - Updated NAN to 2.25.0 for Node.js 25 compatibility
13
+ - Updated mocha to 11.3.0 and chai to 6.2.2
14
+ - Replaced `NODE_MODULE` with `NAN_MODULE_WORKER_ENABLED` for proper module registration
15
+ - Fixed null pointer subtraction warnings in sha256crypt.c and sha512crypt.c using `uintptr_t`
16
+
17
+ ### Added
18
+ - Support for Node.js 25
19
+
3
20
  ## [0.4.0] - 2025-06-27
4
21
 
5
22
  ### Added
package/README.md CHANGED
@@ -16,6 +16,8 @@ Asynchronous mode is especially useful in that computation is performed in Node.
16
16
  npm install @vlasky/shacrypt
17
17
  ```
18
18
 
19
+ TypeScript type declarations are included.
20
+
19
21
  NOTE: You will need to have C++ build tools installed on your system to successfully install the package. If you are running under Windows, you can download Microsoft's [Build Tools for Visual Studio 2017](https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017).
20
22
 
21
23
  ### Usage
package/index.d.ts ADDED
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Callback function for async hash operations.
3
+ */
4
+ type HashCallback = (error: Error | null, hash: string) => void;
5
+
6
+ /**
7
+ * Generate SHA256-CRYPT hash (synchronous).
8
+ *
9
+ * @param password - The password to hash
10
+ * @param salt - Optional salt string (auto-generated if not provided)
11
+ * @param rounds - Optional number of rounds (default: 5000, minimum: 1000)
12
+ * @returns The hashed password string
13
+ */
14
+ export function sha256crypt(password: string, salt?: string, rounds?: number): string;
15
+
16
+ /**
17
+ * Generate SHA256-CRYPT hash (callback-based async).
18
+ *
19
+ * @param password - The password to hash
20
+ * @param salt - Optional salt string (auto-generated if not provided)
21
+ * @param rounds - Optional number of rounds (default: 5000, minimum: 1000)
22
+ * @param callback - Callback function receiving (error, hash)
23
+ */
24
+ export function sha256crypt(password: string, salt: string | undefined, rounds: number | undefined, callback: HashCallback): void;
25
+
26
+ /**
27
+ * Generate SHA512-CRYPT hash (synchronous).
28
+ *
29
+ * @param password - The password to hash
30
+ * @param salt - Optional salt string (auto-generated if not provided)
31
+ * @param rounds - Optional number of rounds (default: 5000, minimum: 1000)
32
+ * @returns The hashed password string
33
+ */
34
+ export function sha512crypt(password: string, salt?: string, rounds?: number): string;
35
+
36
+ /**
37
+ * Generate SHA512-CRYPT hash (callback-based async).
38
+ *
39
+ * @param password - The password to hash
40
+ * @param salt - Optional salt string (auto-generated if not provided)
41
+ * @param rounds - Optional number of rounds (default: 5000, minimum: 1000)
42
+ * @param callback - Callback function receiving (error, hash)
43
+ */
44
+ export function sha512crypt(password: string, salt: string | undefined, rounds: number | undefined, callback: HashCallback): void;
45
+
46
+ /**
47
+ * Generate SHA256-CRYPT hash (async/await compatible).
48
+ *
49
+ * @param password - The password to hash
50
+ * @param salt - Optional salt string (auto-generated if not provided)
51
+ * @param rounds - Optional number of rounds (default: 5000, minimum: 1000)
52
+ * @returns Promise resolving to the hashed password string
53
+ */
54
+ export function sha256cryptAsync(password: string, salt?: string, rounds?: number): Promise<string>;
55
+
56
+ /**
57
+ * Generate SHA512-CRYPT hash (async/await compatible).
58
+ *
59
+ * @param password - The password to hash
60
+ * @param salt - Optional salt string (auto-generated if not provided)
61
+ * @param rounds - Optional number of rounds (default: 5000, minimum: 1000)
62
+ * @returns Promise resolving to the hashed password string
63
+ */
64
+ export function sha512cryptAsync(password: string, salt?: string, rounds?: number): Promise<string>;
package/package.json CHANGED
@@ -1,33 +1,34 @@
1
1
  {
2
2
  "name": "@vlasky/shacrypt",
3
3
  "description": "Node.js wrapper over sha256-crypt and sha512-crypt functions originally created by Ulrich Drepper https://www.akkadia.org/drepper/SHA-crypt.txt",
4
- "version": "0.4.0",
4
+ "version": "0.5.1",
5
5
  "homepage": "https://github.com/vlasky/shacrypt",
6
6
  "author": "Vlad Lasky <github@vladlasky.com> (https://github.com/vlasky/)",
7
7
  "contributors": [
8
8
  "Oleksiy Krivoshey <oleksiyk@gmail.com> (https://github.com/oleksiyk/)"
9
9
  ],
10
10
  "main": "shacrypt",
11
+ "types": "index.d.ts",
11
12
  "scripts": {
12
13
  "install": "node-gyp rebuild",
13
14
  "test": "make test"
14
15
  },
15
16
  "dependencies": {
16
- "nan": "^2.22.2"
17
+ "nan": "^2.25.0"
17
18
  },
18
19
  "devDependencies": {
19
- "mocha": "^10.8.2",
20
- "chai": "^4.5.0"
20
+ "chai": "^6.2.2",
21
+ "mocha": "^11.3.0"
21
22
  },
22
23
  "engines": {
23
- "node": ">= 16.0.0"
24
+ "node": ">= 18.0.0"
24
25
  },
25
26
  "bugs": {
26
27
  "url": "https://github.com/vlasky/shacrypt/issues"
27
28
  },
28
29
  "repository": {
29
- "type": "git",
30
- "url": "git://github.com/vlasky/shacrypt.git"
30
+ "type": "git",
31
+ "url": "git://github.com/vlasky/shacrypt.git"
31
32
  },
32
33
  "gypfile": true,
33
34
  "readmeFilename": "README.md",
package/src/sha256crypt.c CHANGED
@@ -364,21 +364,21 @@ sha256_crypt_r (const char *key, const char *salt, char *buffer, int buflen)
364
364
  salt_len = MIN (strcspn (salt, "$"), SALT_LEN_MAX);
365
365
  key_len = strlen (key);
366
366
 
367
- if ((key - (char *) 0) % __alignof__ (uint32_t) != 0)
367
+ if ((uintptr_t)key % __alignof__ (uint32_t) != 0)
368
368
  {
369
369
  char *tmp = (char *) alloca (key_len + __alignof__ (uint32_t));
370
370
  key = copied_key = (char *)
371
371
  memcpy (tmp + __alignof__ (uint32_t)
372
- - (tmp - (char *) 0) % __alignof__ (uint32_t),
372
+ - (uintptr_t)tmp % __alignof__ (uint32_t),
373
373
  key, key_len);
374
374
  }
375
375
 
376
- if ((salt - (char *) 0) % __alignof__ (uint32_t) != 0)
376
+ if ((uintptr_t)salt % __alignof__ (uint32_t) != 0)
377
377
  {
378
378
  char *tmp = (char *) alloca (salt_len + __alignof__ (uint32_t));
379
379
  salt = copied_salt = (char *)
380
380
  memcpy (tmp + __alignof__ (uint32_t)
381
- - (tmp - (char *) 0) % __alignof__ (uint32_t),
381
+ - (uintptr_t)tmp % __alignof__ (uint32_t),
382
382
  salt, salt_len);
383
383
  }
384
384
 
package/src/sha512crypt.c CHANGED
@@ -394,21 +394,21 @@ sha512_crypt_r (const char *key, const char *salt, char *buffer, int buflen)
394
394
  salt_len = MIN (strcspn (salt, "$"), SALT_LEN_MAX);
395
395
  key_len = strlen (key);
396
396
 
397
- if ((key - (char *) 0) % __alignof__ (uint64_t) != 0)
397
+ if ((uintptr_t)key % __alignof__ (uint64_t) != 0)
398
398
  {
399
399
  char *tmp = (char *) alloca (key_len + __alignof__ (uint64_t));
400
400
  key = copied_key = (char *)
401
401
  memcpy (tmp + __alignof__ (uint64_t)
402
- - (tmp - (char *) 0) % __alignof__ (uint64_t),
402
+ - (uintptr_t)tmp % __alignof__ (uint64_t),
403
403
  key, key_len);
404
404
  }
405
405
 
406
- if ((salt - (char *) 0) % __alignof__ (uint64_t) != 0)
406
+ if ((uintptr_t)salt % __alignof__ (uint64_t) != 0)
407
407
  {
408
408
  char *tmp = (char *) alloca (salt_len + __alignof__ (uint64_t));
409
409
  salt = copied_salt = (char *)
410
410
  memcpy (tmp + __alignof__ (uint64_t)
411
- - (tmp - (char *) 0) % __alignof__ (uint64_t),
411
+ - (uintptr_t)tmp % __alignof__ (uint64_t),
412
412
  salt, salt_len);
413
413
  }
414
414
 
package/src/shacrypt.cc CHANGED
@@ -177,5 +177,5 @@ NAN_MODULE_INIT(init) {
177
177
  }
178
178
 
179
179
 
180
- NODE_MODULE(shacrypt, init);
180
+ NAN_MODULE_WORKER_ENABLED(shacrypt, init)
181
181