@orieljs/hashing 0.1.0-alpha.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/LICENSE +202 -0
- package/NOTICE +9 -0
- package/dist/index.d.ts +101 -0
- package/dist/index.js +217 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Oriel
|
|
2
|
+
Copyright 2026 meeeet-dev and Oriel contributors
|
|
3
|
+
|
|
4
|
+
This product includes software developed by the Oriel project
|
|
5
|
+
(https://orieljs.vercel.app, https://github.com/orieljs).
|
|
6
|
+
|
|
7
|
+
Oriel is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
8
|
+
The Oriel name and logo are not covered by that license; see TRADEMARKS.md
|
|
9
|
+
(https://github.com/orieljs/framework/blob/main/TRADEMARKS.md).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { OrielError, Hasher } from '@orieljs/contracts';
|
|
2
|
+
import * as _orieljs_support from '@orieljs/support';
|
|
3
|
+
import { ServiceProvider } from '@orieljs/support';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Thrown by check() when `verify` is on and the hash uses another algorithm (Laravel's RuntimeException).
|
|
7
|
+
* A reported 500 ('Server' kind); the message is shown only with app.debug.
|
|
8
|
+
*/
|
|
9
|
+
declare class HashAlgorithmError extends Error implements OrielError {
|
|
10
|
+
readonly name = "HashAlgorithmError";
|
|
11
|
+
readonly kind: "Server";
|
|
12
|
+
readonly status = 500;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface HashInfo {
|
|
16
|
+
algorithm: string;
|
|
17
|
+
options: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
/** PHP's password_get_info(): the algorithm name ('bcrypt', 'argon2i', 'argon2id' or 'unknown') and its options. */
|
|
20
|
+
declare function hashInfo(hashed: string): HashInfo;
|
|
21
|
+
/** PHP's password_verify(): checks a value against a bcrypt or argon2 hash, whatever the configured driver. */
|
|
22
|
+
declare function passwordVerify(value: string, hashed: string): Promise<boolean>;
|
|
23
|
+
|
|
24
|
+
interface BcryptOptions {
|
|
25
|
+
rounds?: number;
|
|
26
|
+
verify?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** Laravel's BcryptHasher: `$2y$` hashes (what PHP's password_hash produces), cost `rounds` (default 12). */
|
|
29
|
+
declare class BcryptHasher implements Hasher {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(options?: BcryptOptions);
|
|
32
|
+
make(value: string, options?: {
|
|
33
|
+
rounds?: number;
|
|
34
|
+
}): Promise<string>;
|
|
35
|
+
check(value: string, hashed: string): Promise<boolean>;
|
|
36
|
+
needsRehash(hashed: string, options?: {
|
|
37
|
+
rounds?: number;
|
|
38
|
+
}): boolean;
|
|
39
|
+
info(hashed: string): HashInfo;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface ArgonOptions {
|
|
43
|
+
/** Memory cost in KiB (default 65536). */
|
|
44
|
+
memory?: number;
|
|
45
|
+
/** Time cost / passes (default 4). */
|
|
46
|
+
time?: number;
|
|
47
|
+
/** Parallelism (default 1). */
|
|
48
|
+
threads?: number;
|
|
49
|
+
verify?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** Laravel's ArgonHasher (`argon`, argon2i) and Argon2IdHasher (`argon2id`). */
|
|
52
|
+
declare class ArgonHasher implements Hasher {
|
|
53
|
+
#private;
|
|
54
|
+
readonly algorithm: 'argon2i' | 'argon2id';
|
|
55
|
+
constructor(options?: ArgonOptions, algorithm?: 'argon2i' | 'argon2id');
|
|
56
|
+
make(value: string, options?: Omit<ArgonOptions, 'verify'>): Promise<string>;
|
|
57
|
+
check(value: string, hashed: string): Promise<boolean>;
|
|
58
|
+
needsRehash(hashed: string, options?: Omit<ArgonOptions, 'verify'>): boolean;
|
|
59
|
+
info(hashed: string): HashInfo;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface HashingConfig {
|
|
63
|
+
driver?: string;
|
|
64
|
+
bcrypt?: BcryptOptions;
|
|
65
|
+
argon?: ArgonOptions;
|
|
66
|
+
rehash_on_login?: boolean;
|
|
67
|
+
}
|
|
68
|
+
type HasherFactory = (config: HashingConfig) => Hasher;
|
|
69
|
+
/** Laravel's HashManager: the `Hasher` binding. Delegates to the default driver (config('hashing.driver')). */
|
|
70
|
+
declare class HashManager implements Hasher {
|
|
71
|
+
#private;
|
|
72
|
+
private readonly config;
|
|
73
|
+
/** `config` is read lazily, each time a driver is first created. */
|
|
74
|
+
constructor(config: () => HashingConfig);
|
|
75
|
+
driver(name?: string): Hasher;
|
|
76
|
+
/** Register a custom driver: Hash.extend('sha', (config) => new ShaHasher()). */
|
|
77
|
+
extend(driver: string, factory: HasherFactory): this;
|
|
78
|
+
getDefaultDriver(): string;
|
|
79
|
+
make(value: string): Promise<string>;
|
|
80
|
+
check(value: string, hashed: string): Promise<boolean>;
|
|
81
|
+
needsRehash(hashed: string): boolean;
|
|
82
|
+
info(hashed: string): HashInfo;
|
|
83
|
+
/** Whether the value is already a bcrypt or argon2 hash (Laravel's Hash::isHashed). */
|
|
84
|
+
isHashed(value: string): boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The Hash facade. `Hash.driver('argon2id')` and `Hash.isHashed()` need the HashManager binding. */
|
|
88
|
+
declare const Hash: _orieljs_support.Facade<Hasher, {
|
|
89
|
+
driver: (name?: string) => Hasher;
|
|
90
|
+
isHashed: (value: string) => boolean;
|
|
91
|
+
}>;
|
|
92
|
+
/** bcrypt() helper: hashes with the bcrypt driver whatever the default driver is (Laravel's bcrypt()). */
|
|
93
|
+
declare function bcrypt(value: string, options?: {
|
|
94
|
+
rounds?: number;
|
|
95
|
+
}): Promise<string>;
|
|
96
|
+
|
|
97
|
+
declare class HashingServiceProvider extends ServiceProvider {
|
|
98
|
+
register(): void;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { ArgonHasher, type ArgonOptions, BcryptHasher, type BcryptOptions, Hash, HashAlgorithmError, type HashInfo, HashManager, type HasherFactory, type HashingConfig, HashingServiceProvider, bcrypt, hashInfo, passwordVerify };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// errors.ts
|
|
2
|
+
var HashAlgorithmError = class extends Error {
|
|
3
|
+
name = "HashAlgorithmError";
|
|
4
|
+
kind = "Server";
|
|
5
|
+
status = 500;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// info.ts
|
|
9
|
+
import bcrypt from "bcryptjs";
|
|
10
|
+
import { verify as argonVerify } from "@node-rs/argon2";
|
|
11
|
+
var BCRYPT = /^\$2[abxy]\$(\d{2})\$[./A-Za-z0-9]{53}$/;
|
|
12
|
+
var ARGON = /^\$(argon2id|argon2i)\$v=\d+\$m=(\d+),t=(\d+),p=(\d+)\$/;
|
|
13
|
+
function hashInfo(hashed) {
|
|
14
|
+
const bcryptMatch = BCRYPT.exec(hashed);
|
|
15
|
+
if (bcryptMatch) return { algorithm: "bcrypt", options: { cost: Number(bcryptMatch[1]) } };
|
|
16
|
+
const argonMatch = ARGON.exec(hashed);
|
|
17
|
+
if (argonMatch) {
|
|
18
|
+
return {
|
|
19
|
+
algorithm: argonMatch[1],
|
|
20
|
+
options: { memory_cost: Number(argonMatch[2]), time_cost: Number(argonMatch[3]), threads: Number(argonMatch[4]) }
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return { algorithm: "unknown", options: {} };
|
|
24
|
+
}
|
|
25
|
+
async function passwordVerify(value, hashed) {
|
|
26
|
+
const { algorithm } = hashInfo(hashed);
|
|
27
|
+
try {
|
|
28
|
+
if (algorithm === "bcrypt") return await bcrypt.compare(value, hashed);
|
|
29
|
+
if (algorithm === "argon2i" || algorithm === "argon2id") return await argonVerify(hashed, value);
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// BcryptHasher.ts
|
|
37
|
+
import bcrypt2 from "bcryptjs";
|
|
38
|
+
|
|
39
|
+
// coerce.ts
|
|
40
|
+
function coerceOption(name, value, fallback) {
|
|
41
|
+
if (value === void 0 || value === null) return fallback;
|
|
42
|
+
const coerced = Number(value);
|
|
43
|
+
if (!Number.isFinite(coerced)) {
|
|
44
|
+
throw new Error(`Invalid hashing configuration: [${name}] must be a number, got ${JSON.stringify(value)}.`);
|
|
45
|
+
}
|
|
46
|
+
return coerced;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// BcryptHasher.ts
|
|
50
|
+
var BcryptHasher = class {
|
|
51
|
+
#rounds;
|
|
52
|
+
#verify;
|
|
53
|
+
constructor(options = {}) {
|
|
54
|
+
this.#rounds = coerceOption("hashing.bcrypt.rounds", options.rounds, 12);
|
|
55
|
+
this.#verify = options.verify ?? true;
|
|
56
|
+
}
|
|
57
|
+
async make(value, options = {}) {
|
|
58
|
+
const rounds = coerceOption("hashing.bcrypt.rounds", options.rounds, this.#rounds);
|
|
59
|
+
const hashed = await bcrypt2.hash(value, rounds);
|
|
60
|
+
return hashed.replace(/^\$2b\$/, "$2y$");
|
|
61
|
+
}
|
|
62
|
+
async check(value, hashed) {
|
|
63
|
+
if (typeof hashed !== "string" || hashed === "") return false;
|
|
64
|
+
if (this.#verify && hashInfo(hashed).algorithm !== "bcrypt") {
|
|
65
|
+
throw new HashAlgorithmError("This password does not use the Bcrypt algorithm.");
|
|
66
|
+
}
|
|
67
|
+
return passwordVerify(value, hashed);
|
|
68
|
+
}
|
|
69
|
+
needsRehash(hashed, options = {}) {
|
|
70
|
+
const info = hashInfo(hashed);
|
|
71
|
+
const rounds = coerceOption("hashing.bcrypt.rounds", options.rounds, this.#rounds);
|
|
72
|
+
return info.algorithm !== "bcrypt" || info.options.cost !== rounds;
|
|
73
|
+
}
|
|
74
|
+
info(hashed) {
|
|
75
|
+
return hashInfo(hashed);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// ArgonHasher.ts
|
|
80
|
+
import { hash } from "@node-rs/argon2";
|
|
81
|
+
var ArgonHasher = class {
|
|
82
|
+
constructor(options = {}, algorithm = "argon2i") {
|
|
83
|
+
this.algorithm = algorithm;
|
|
84
|
+
this.#memory = coerceOption("hashing.argon.memory", options.memory, 65536);
|
|
85
|
+
this.#time = coerceOption("hashing.argon.time", options.time, 4);
|
|
86
|
+
this.#threads = coerceOption("hashing.argon.threads", options.threads, 1);
|
|
87
|
+
this.#verify = options.verify ?? true;
|
|
88
|
+
}
|
|
89
|
+
algorithm;
|
|
90
|
+
#memory;
|
|
91
|
+
#time;
|
|
92
|
+
#threads;
|
|
93
|
+
#verify;
|
|
94
|
+
make(value, options = {}) {
|
|
95
|
+
return hash(value, {
|
|
96
|
+
// Algorithm is a const enum in @node-rs/argon2 (Argon2i = 1, Argon2id = 2); isolatedModules forbids reading it.
|
|
97
|
+
algorithm: this.algorithm === "argon2id" ? 2 : 1,
|
|
98
|
+
memoryCost: coerceOption("hashing.argon.memory", options.memory, this.#memory),
|
|
99
|
+
timeCost: coerceOption("hashing.argon.time", options.time, this.#time),
|
|
100
|
+
parallelism: coerceOption("hashing.argon.threads", options.threads, this.#threads)
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
async check(value, hashed) {
|
|
104
|
+
if (typeof hashed !== "string" || hashed === "") return false;
|
|
105
|
+
if (this.#verify && hashInfo(hashed).algorithm !== this.algorithm) {
|
|
106
|
+
throw new HashAlgorithmError(`This password does not use the ${this.algorithm === "argon2id" ? "Argon2id" : "Argon2i"} algorithm.`);
|
|
107
|
+
}
|
|
108
|
+
return passwordVerify(value, hashed);
|
|
109
|
+
}
|
|
110
|
+
needsRehash(hashed, options = {}) {
|
|
111
|
+
const info = hashInfo(hashed);
|
|
112
|
+
const memory = coerceOption("hashing.argon.memory", options.memory, this.#memory);
|
|
113
|
+
const time = coerceOption("hashing.argon.time", options.time, this.#time);
|
|
114
|
+
const threads = coerceOption("hashing.argon.threads", options.threads, this.#threads);
|
|
115
|
+
return info.algorithm !== this.algorithm || info.options.memory_cost !== memory || info.options.time_cost !== time || info.options.threads !== threads;
|
|
116
|
+
}
|
|
117
|
+
info(hashed) {
|
|
118
|
+
return hashInfo(hashed);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// HashManager.ts
|
|
123
|
+
var HashManager = class {
|
|
124
|
+
/** `config` is read lazily, each time a driver is first created. */
|
|
125
|
+
constructor(config) {
|
|
126
|
+
this.config = config;
|
|
127
|
+
}
|
|
128
|
+
config;
|
|
129
|
+
#drivers = /* @__PURE__ */ new Map();
|
|
130
|
+
#custom = /* @__PURE__ */ new Map();
|
|
131
|
+
driver(name) {
|
|
132
|
+
const driver = name ?? this.getDefaultDriver();
|
|
133
|
+
let hasher = this.#drivers.get(driver);
|
|
134
|
+
if (hasher === void 0) {
|
|
135
|
+
hasher = this.#create(driver);
|
|
136
|
+
this.#drivers.set(driver, hasher);
|
|
137
|
+
}
|
|
138
|
+
return hasher;
|
|
139
|
+
}
|
|
140
|
+
/** Register a custom driver: Hash.extend('sha', (config) => new ShaHasher()). */
|
|
141
|
+
extend(driver, factory) {
|
|
142
|
+
this.#custom.set(driver, factory);
|
|
143
|
+
this.#drivers.delete(driver);
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
getDefaultDriver() {
|
|
147
|
+
return this.config().driver ?? "bcrypt";
|
|
148
|
+
}
|
|
149
|
+
make(value) {
|
|
150
|
+
return this.driver().make(value);
|
|
151
|
+
}
|
|
152
|
+
check(value, hashed) {
|
|
153
|
+
return this.driver().check(value, hashed);
|
|
154
|
+
}
|
|
155
|
+
needsRehash(hashed) {
|
|
156
|
+
return this.driver().needsRehash(hashed);
|
|
157
|
+
}
|
|
158
|
+
info(hashed) {
|
|
159
|
+
return this.driver().info(hashed);
|
|
160
|
+
}
|
|
161
|
+
/** Whether the value is already a bcrypt or argon2 hash (Laravel's Hash::isHashed). */
|
|
162
|
+
isHashed(value) {
|
|
163
|
+
return hashInfo(value).algorithm !== "unknown";
|
|
164
|
+
}
|
|
165
|
+
#create(driver) {
|
|
166
|
+
const config = this.config();
|
|
167
|
+
const custom = this.#custom.get(driver);
|
|
168
|
+
if (custom !== void 0) return custom(config);
|
|
169
|
+
if (driver === "bcrypt") return new BcryptHasher(config.bcrypt);
|
|
170
|
+
if (driver === "argon") return new ArgonHasher(config.argon, "argon2i");
|
|
171
|
+
if (driver === "argon2id") return new ArgonHasher(config.argon, "argon2id");
|
|
172
|
+
throw new Error(`Driver [${driver}] not supported.`);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// facade.ts
|
|
177
|
+
import { Hasher } from "@orieljs/contracts";
|
|
178
|
+
import { inject } from "@orieljs/container";
|
|
179
|
+
import { facade } from "@orieljs/support";
|
|
180
|
+
var manager = () => inject(Hasher);
|
|
181
|
+
var Hash = facade(Hasher, {
|
|
182
|
+
driver: (name) => manager().driver(name),
|
|
183
|
+
isHashed: (value) => manager().isHashed(value)
|
|
184
|
+
});
|
|
185
|
+
function bcrypt3(value, options = {}) {
|
|
186
|
+
return manager().driver("bcrypt").make(value, options);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// HashingServiceProvider.ts
|
|
190
|
+
import { ConfigRepository, Hasher as Hasher2 } from "@orieljs/contracts";
|
|
191
|
+
import { ServiceProvider } from "@orieljs/support";
|
|
192
|
+
var HashingServiceProvider = class extends ServiceProvider {
|
|
193
|
+
register() {
|
|
194
|
+
this.mergeConfigFrom(
|
|
195
|
+
{
|
|
196
|
+
driver: "bcrypt",
|
|
197
|
+
bcrypt: { rounds: 12, verify: true },
|
|
198
|
+
argon: { memory: 65536, threads: 1, time: 4, verify: true },
|
|
199
|
+
rehash_on_login: true
|
|
200
|
+
},
|
|
201
|
+
"hashing"
|
|
202
|
+
);
|
|
203
|
+
this.app.singleton(Hasher2, (container) => new HashManager(() => container.make(ConfigRepository).get("hashing", {})));
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
export {
|
|
207
|
+
ArgonHasher,
|
|
208
|
+
BcryptHasher,
|
|
209
|
+
Hash,
|
|
210
|
+
HashAlgorithmError,
|
|
211
|
+
HashManager,
|
|
212
|
+
HashingServiceProvider,
|
|
213
|
+
bcrypt3 as bcrypt,
|
|
214
|
+
hashInfo,
|
|
215
|
+
passwordVerify
|
|
216
|
+
};
|
|
217
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../errors.ts","../info.ts","../BcryptHasher.ts","../coerce.ts","../ArgonHasher.ts","../HashManager.ts","../facade.ts","../HashingServiceProvider.ts"],"sourcesContent":["import type { OrielError } from '@orieljs/contracts'\n\n/**\n * Thrown by check() when `verify` is on and the hash uses another algorithm (Laravel's RuntimeException).\n * A reported 500 ('Server' kind); the message is shown only with app.debug.\n */\nexport class HashAlgorithmError extends Error implements OrielError {\n override readonly name = 'HashAlgorithmError'\n readonly kind = 'Server' as const\n readonly status = 500\n}\n","import bcrypt from 'bcryptjs'\nimport { verify as argonVerify } from '@node-rs/argon2'\n\nexport interface HashInfo {\n algorithm: string\n options: Record<string, unknown>\n}\n\nconst BCRYPT = /^\\$2[abxy]\\$(\\d{2})\\$[./A-Za-z0-9]{53}$/\nconst ARGON = /^\\$(argon2id|argon2i)\\$v=\\d+\\$m=(\\d+),t=(\\d+),p=(\\d+)\\$/\n\n/** PHP's password_get_info(): the algorithm name ('bcrypt', 'argon2i', 'argon2id' or 'unknown') and its options. */\nexport function hashInfo(hashed: string): HashInfo {\n const bcryptMatch = BCRYPT.exec(hashed)\n if (bcryptMatch) return { algorithm: 'bcrypt', options: { cost: Number(bcryptMatch[1]) } }\n const argonMatch = ARGON.exec(hashed)\n if (argonMatch) {\n return {\n algorithm: argonMatch[1]!,\n options: { memory_cost: Number(argonMatch[2]), time_cost: Number(argonMatch[3]), threads: Number(argonMatch[4]) },\n }\n }\n return { algorithm: 'unknown', options: {} }\n}\n\n/** PHP's password_verify(): checks a value against a bcrypt or argon2 hash, whatever the configured driver. */\nexport async function passwordVerify(value: string, hashed: string): Promise<boolean> {\n const { algorithm } = hashInfo(hashed)\n try {\n if (algorithm === 'bcrypt') return await bcrypt.compare(value, hashed)\n if (algorithm === 'argon2i' || algorithm === 'argon2id') return await argonVerify(hashed, value)\n } catch {\n return false\n }\n return false\n}\n","import bcrypt from 'bcryptjs'\nimport type { Hasher } from '@orieljs/contracts'\nimport { coerceOption } from './coerce'\nimport { HashAlgorithmError } from './errors'\nimport { hashInfo, passwordVerify, type HashInfo } from './info'\n\nexport interface BcryptOptions {\n rounds?: number\n verify?: boolean\n}\n\n/** Laravel's BcryptHasher: `$2y$` hashes (what PHP's password_hash produces), cost `rounds` (default 12). */\nexport class BcryptHasher implements Hasher {\n readonly #rounds: number\n readonly #verify: boolean\n\n constructor(options: BcryptOptions = {}) {\n this.#rounds = coerceOption('hashing.bcrypt.rounds', options.rounds, 12)\n this.#verify = options.verify ?? true\n }\n\n async make(value: string, options: { rounds?: number } = {}): Promise<string> {\n const rounds = coerceOption('hashing.bcrypt.rounds', options.rounds, this.#rounds)\n const hashed = await bcrypt.hash(value, rounds)\n return hashed.replace(/^\\$2b\\$/, '$2y$')\n }\n\n async check(value: string, hashed: string): Promise<boolean> {\n if (typeof hashed !== 'string' || hashed === '') return false\n if (this.#verify && hashInfo(hashed).algorithm !== 'bcrypt') {\n throw new HashAlgorithmError('This password does not use the Bcrypt algorithm.')\n }\n return passwordVerify(value, hashed)\n }\n\n needsRehash(hashed: string, options: { rounds?: number } = {}): boolean {\n const info = hashInfo(hashed)\n const rounds = coerceOption('hashing.bcrypt.rounds', options.rounds, this.#rounds)\n return info.algorithm !== 'bcrypt' || info.options.cost !== rounds\n }\n\n info(hashed: string): HashInfo {\n return hashInfo(hashed)\n }\n}\n","/**\n * `env()` returns numeric values as strings, so a config file that writes `rounds: env('BCRYPT_ROUNDS', 12)` (or\n * the argon equivalents) hands the hasher a string. bcryptjs and @node-rs/argon2 both misbehave on a string cost\n * (bcryptjs throws \"Invalid salt version\"), so every numeric hashing option is coerced with Number() here, with a\n * clear configuration error for anything that doesn't come out finite.\n */\nexport function coerceOption(name: string, value: unknown, fallback: number): number {\n if (value === undefined || value === null) return fallback\n const coerced = Number(value)\n if (!Number.isFinite(coerced)) {\n throw new Error(`Invalid hashing configuration: [${name}] must be a number, got ${JSON.stringify(value)}.`)\n }\n return coerced\n}\n","import { hash, type Algorithm } from '@node-rs/argon2'\nimport type { Hasher } from '@orieljs/contracts'\nimport { coerceOption } from './coerce'\nimport { HashAlgorithmError } from './errors'\nimport { hashInfo, passwordVerify, type HashInfo } from './info'\n\nexport interface ArgonOptions {\n /** Memory cost in KiB (default 65536). */\n memory?: number\n /** Time cost / passes (default 4). */\n time?: number\n /** Parallelism (default 1). */\n threads?: number\n verify?: boolean\n}\n\n/** Laravel's ArgonHasher (`argon`, argon2i) and Argon2IdHasher (`argon2id`). */\nexport class ArgonHasher implements Hasher {\n readonly #memory: number\n readonly #time: number\n readonly #threads: number\n readonly #verify: boolean\n\n constructor(\n options: ArgonOptions = {},\n readonly algorithm: 'argon2i' | 'argon2id' = 'argon2i',\n ) {\n this.#memory = coerceOption('hashing.argon.memory', options.memory, 65536)\n this.#time = coerceOption('hashing.argon.time', options.time, 4)\n this.#threads = coerceOption('hashing.argon.threads', options.threads, 1)\n this.#verify = options.verify ?? true\n }\n\n make(value: string, options: Omit<ArgonOptions, 'verify'> = {}): Promise<string> {\n return hash(value, {\n // Algorithm is a const enum in @node-rs/argon2 (Argon2i = 1, Argon2id = 2); isolatedModules forbids reading it.\n algorithm: (this.algorithm === 'argon2id' ? 2 : 1) as Algorithm,\n memoryCost: coerceOption('hashing.argon.memory', options.memory, this.#memory),\n timeCost: coerceOption('hashing.argon.time', options.time, this.#time),\n parallelism: coerceOption('hashing.argon.threads', options.threads, this.#threads),\n })\n }\n\n async check(value: string, hashed: string): Promise<boolean> {\n if (typeof hashed !== 'string' || hashed === '') return false\n if (this.#verify && hashInfo(hashed).algorithm !== this.algorithm) {\n throw new HashAlgorithmError(`This password does not use the ${this.algorithm === 'argon2id' ? 'Argon2id' : 'Argon2i'} algorithm.`)\n }\n return passwordVerify(value, hashed)\n }\n\n needsRehash(hashed: string, options: Omit<ArgonOptions, 'verify'> = {}): boolean {\n const info = hashInfo(hashed)\n const memory = coerceOption('hashing.argon.memory', options.memory, this.#memory)\n const time = coerceOption('hashing.argon.time', options.time, this.#time)\n const threads = coerceOption('hashing.argon.threads', options.threads, this.#threads)\n return (\n info.algorithm !== this.algorithm ||\n info.options.memory_cost !== memory ||\n info.options.time_cost !== time ||\n info.options.threads !== threads\n )\n }\n\n info(hashed: string): HashInfo {\n return hashInfo(hashed)\n }\n}\n","import type { Hasher } from '@orieljs/contracts'\nimport { ArgonHasher, type ArgonOptions } from './ArgonHasher'\nimport { BcryptHasher, type BcryptOptions } from './BcryptHasher'\nimport { hashInfo, type HashInfo } from './info'\n\nexport interface HashingConfig {\n driver?: string\n bcrypt?: BcryptOptions\n argon?: ArgonOptions\n rehash_on_login?: boolean\n}\n\nexport type HasherFactory = (config: HashingConfig) => Hasher\n\n/** Laravel's HashManager: the `Hasher` binding. Delegates to the default driver (config('hashing.driver')). */\nexport class HashManager implements Hasher {\n readonly #drivers = new Map<string, Hasher>()\n readonly #custom = new Map<string, HasherFactory>()\n\n /** `config` is read lazily, each time a driver is first created. */\n constructor(private readonly config: () => HashingConfig) {}\n\n driver(name?: string): Hasher {\n const driver = name ?? this.getDefaultDriver()\n let hasher = this.#drivers.get(driver)\n if (hasher === undefined) {\n hasher = this.#create(driver)\n this.#drivers.set(driver, hasher)\n }\n return hasher\n }\n\n /** Register a custom driver: Hash.extend('sha', (config) => new ShaHasher()). */\n extend(driver: string, factory: HasherFactory): this {\n this.#custom.set(driver, factory)\n this.#drivers.delete(driver)\n return this\n }\n\n getDefaultDriver(): string {\n return this.config().driver ?? 'bcrypt'\n }\n\n make(value: string): Promise<string> {\n return this.driver().make(value)\n }\n\n check(value: string, hashed: string): Promise<boolean> {\n return this.driver().check(value, hashed)\n }\n\n needsRehash(hashed: string): boolean {\n return this.driver().needsRehash(hashed)\n }\n\n info(hashed: string): HashInfo {\n return this.driver().info(hashed)\n }\n\n /** Whether the value is already a bcrypt or argon2 hash (Laravel's Hash::isHashed). */\n isHashed(value: string): boolean {\n return hashInfo(value).algorithm !== 'unknown'\n }\n\n #create(driver: string): Hasher {\n const config = this.config()\n const custom = this.#custom.get(driver)\n if (custom !== undefined) return custom(config)\n if (driver === 'bcrypt') return new BcryptHasher(config.bcrypt)\n if (driver === 'argon') return new ArgonHasher(config.argon, 'argon2i')\n if (driver === 'argon2id') return new ArgonHasher(config.argon, 'argon2id')\n throw new Error(`Driver [${driver}] not supported.`)\n }\n}\n","import { Hasher } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport { facade } from '@orieljs/support'\nimport type { BcryptHasher } from './BcryptHasher'\nimport type { HashManager } from './HashManager'\n\nconst manager = (): HashManager => inject(Hasher) as HashManager\n\n/** The Hash facade. `Hash.driver('argon2id')` and `Hash.isHashed()` need the HashManager binding. */\nexport const Hash = facade(Hasher, {\n driver: (name?: string): Hasher => manager().driver(name),\n isHashed: (value: string): boolean => manager().isHashed(value),\n})\n\n/** bcrypt() helper: hashes with the bcrypt driver whatever the default driver is (Laravel's bcrypt()). */\nexport function bcrypt(value: string, options: { rounds?: number } = {}): Promise<string> {\n return (manager().driver('bcrypt') as BcryptHasher).make(value, options)\n}\n","import { ConfigRepository, Hasher } from '@orieljs/contracts'\nimport { ServiceProvider } from '@orieljs/support'\nimport { HashManager, type HashingConfig } from './HashManager'\n\nexport class HashingServiceProvider extends ServiceProvider {\n override register(): void {\n this.mergeConfigFrom(\n {\n driver: 'bcrypt',\n bcrypt: { rounds: 12, verify: true },\n argon: { memory: 65536, threads: 1, time: 4, verify: true },\n rehash_on_login: true,\n },\n 'hashing',\n )\n this.app.singleton(Hasher, (container) => new HashManager(() => container.make(ConfigRepository).get<HashingConfig>('hashing', {})))\n }\n}\n"],"mappings":";AAMO,IAAM,qBAAN,cAAiC,MAA4B;AAAA,EAChD,OAAO;AAAA,EAChB,OAAO;AAAA,EACP,SAAS;AACpB;;;ACVA,OAAO,YAAY;AACnB,SAAS,UAAU,mBAAmB;AAOtC,IAAM,SAAS;AACf,IAAM,QAAQ;AAGP,SAAS,SAAS,QAA0B;AACjD,QAAM,cAAc,OAAO,KAAK,MAAM;AACtC,MAAI,YAAa,QAAO,EAAE,WAAW,UAAU,SAAS,EAAE,MAAM,OAAO,YAAY,CAAC,CAAC,EAAE,EAAE;AACzF,QAAM,aAAa,MAAM,KAAK,MAAM;AACpC,MAAI,YAAY;AACd,WAAO;AAAA,MACL,WAAW,WAAW,CAAC;AAAA,MACvB,SAAS,EAAE,aAAa,OAAO,WAAW,CAAC,CAAC,GAAG,WAAW,OAAO,WAAW,CAAC,CAAC,GAAG,SAAS,OAAO,WAAW,CAAC,CAAC,EAAE;AAAA,IAClH;AAAA,EACF;AACA,SAAO,EAAE,WAAW,WAAW,SAAS,CAAC,EAAE;AAC7C;AAGA,eAAsB,eAAe,OAAe,QAAkC;AACpF,QAAM,EAAE,UAAU,IAAI,SAAS,MAAM;AACrC,MAAI;AACF,QAAI,cAAc,SAAU,QAAO,MAAM,OAAO,QAAQ,OAAO,MAAM;AACrE,QAAI,cAAc,aAAa,cAAc,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crypt","bcrypt","Hasher","Hasher"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@orieljs/hashing",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "The Oriel Hashing component.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/orieljs/framework.git",
|
|
11
|
+
"directory": "src/Oriel/Hashing"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=22"
|
|
15
|
+
},
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"NOTICE"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"bcryptjs": "3.0.3",
|
|
33
|
+
"@node-rs/argon2": "2.2.1",
|
|
34
|
+
"@orieljs/contracts": "0.1.0-alpha.1",
|
|
35
|
+
"@orieljs/support": "0.1.0-alpha.1",
|
|
36
|
+
"@orieljs/container": "0.1.0-alpha.1"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsup && node ../../../scripts/copy-license.mjs"
|
|
40
|
+
}
|
|
41
|
+
}
|