@pirxpilot/argon2 1.0.1 → 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.
Files changed (2) hide show
  1. package/argon2.d.ts +76 -0
  2. package/package.json +4 -2
package/argon2.d.ts ADDED
@@ -0,0 +1,76 @@
1
+ declare module 'argon2' {
2
+ /**
3
+ * Hashes a password with Argon2, producing a raw hash
4
+ *
5
+ * @overload
6
+ * @param {Buffer | string} password The plaintext password to be hashed
7
+ * @param {Options & { raw: true }} options The parameters for Argon2
8
+ * @returns {Promise<Buffer>} The raw hash generated from `password`
9
+ */
10
+ export function hash(
11
+ password: Buffer | string,
12
+ options: Options & {
13
+ raw: true;
14
+ }
15
+ ): Promise<Buffer>;
16
+ /**
17
+ * Hashes a password with Argon2, producing an encoded hash
18
+ *
19
+ * @overload
20
+ * @param {Buffer | string} password The plaintext password to be hashed
21
+ * @param {Options & { raw?: boolean }} [options] The parameters for Argon2
22
+ * @returns {Promise<string>} The encoded hash generated from `password`
23
+ */
24
+ export function hash(
25
+ password: Buffer | string,
26
+ options?: Options & {
27
+ raw?: boolean;
28
+ }
29
+ ): Promise<string>;
30
+ /**
31
+ * @param {string} digest The digest to be checked
32
+ * @param {Object} [options] The current parameters for Argon2
33
+ * @param {number} [options.timeCost=3]
34
+ * @param {number} [options.memoryCost=65536]
35
+ * @param {number} [options.parallelism=4]
36
+ * @param {number} [options.version=0x13]
37
+ * @returns {boolean} `true` if the digest parameters do not match the parameters in `options`, otherwise `false`
38
+ */
39
+ export function needsRehash(
40
+ digest: string,
41
+ options?: {
42
+ timeCost?: number;
43
+ memoryCost?: number;
44
+ parallelism?: number;
45
+ version?: number;
46
+ }
47
+ ): boolean;
48
+ /**
49
+ * @param {string} digest The digest to be checked
50
+ * @param {Buffer | string} password The plaintext password to be verified
51
+ * @param {Object} [options] The current parameters for Argon2
52
+ * @param {Buffer} [options.secret]
53
+ * @returns {Promise<boolean>} `true` if the digest parameters matches the hash generated from `password`, otherwise `false`
54
+ */
55
+ export function verify(
56
+ digest: string,
57
+ password: Buffer | string,
58
+ options?: {
59
+ secret?: Buffer;
60
+ }
61
+ ): Promise<boolean>;
62
+ export const argon2d: 0;
63
+ export const argon2i: 1;
64
+ export const argon2id: 2;
65
+ export type Options = {
66
+ hashLength?: number;
67
+ timeCost?: number;
68
+ memoryCost?: number;
69
+ parallelism?: number;
70
+ type?: 0 | 1 | 2;
71
+ version?: number;
72
+ salt?: Buffer;
73
+ associatedData?: Buffer;
74
+ secret?: Buffer;
75
+ };
76
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirxpilot/argon2",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "An Argon2 library for Node",
5
5
  "keywords": [
6
6
  "argon2",
@@ -17,8 +17,10 @@
17
17
  "author": "Ranieri Althoff <ranisalt+argon2@gmail.com>",
18
18
  "type": "module",
19
19
  "exports": "./argon2.js",
20
+ "types": "./argon2.d.ts",
20
21
  "files": [
21
- "argon2.js"
22
+ "argon2.js",
23
+ "argon2.d.ts"
22
24
  ],
23
25
  "scripts": {
24
26
  "test": "make check"