@structured-id/opaque 0.0.0-development
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 +201 -0
- package/dist/index.d.mts +64 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +140 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +138 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
interface RegistrationStartResult {
|
|
2
|
+
/** The blinded message to send to the server. */
|
|
3
|
+
request: Uint8Array;
|
|
4
|
+
/** Client state to preserve for the finish step. */
|
|
5
|
+
state: Uint8Array;
|
|
6
|
+
}
|
|
7
|
+
interface RegistrationFinishResult {
|
|
8
|
+
/** The registration record to send to the server for storage. */
|
|
9
|
+
record: Uint8Array;
|
|
10
|
+
/** The export key derived during registration. */
|
|
11
|
+
exportKey: Uint8Array;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface LoginStartResult {
|
|
15
|
+
/** The credential request to send to the server. */
|
|
16
|
+
request: Uint8Array;
|
|
17
|
+
/** Client state to preserve for the finish step. */
|
|
18
|
+
state: Uint8Array;
|
|
19
|
+
}
|
|
20
|
+
interface LoginFinishResult {
|
|
21
|
+
/** The credential finalization message to send to the server. */
|
|
22
|
+
finalization: Uint8Array;
|
|
23
|
+
/** The session key for subsequent communication. */
|
|
24
|
+
sessionKey: Uint8Array;
|
|
25
|
+
/** The export key derived during login. */
|
|
26
|
+
exportKey: Uint8Array;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface OpaqueClientConfig {
|
|
30
|
+
/** Server identity (usually the domain, e.g. "sid.example.com") */
|
|
31
|
+
serverId: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* OPAQUE (RFC 9807) client for browser and Node.js environments.
|
|
35
|
+
*
|
|
36
|
+
* Handles the client side of OPAQUE registration and login flows
|
|
37
|
+
* using the WebCrypto API for core operations.
|
|
38
|
+
*/
|
|
39
|
+
declare class OpaqueClient {
|
|
40
|
+
private readonly serverId;
|
|
41
|
+
constructor(config: OpaqueClientConfig);
|
|
42
|
+
/**
|
|
43
|
+
* Start the registration process.
|
|
44
|
+
* Generates a registration request to send to the server.
|
|
45
|
+
*/
|
|
46
|
+
registrationStart(password: string): Promise<RegistrationStartResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Finish the registration process.
|
|
49
|
+
* Processes the server's registration response and produces the final record.
|
|
50
|
+
*/
|
|
51
|
+
registrationFinish(password: string, serverResponse: Uint8Array, state: Uint8Array): Promise<RegistrationFinishResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Start the login process.
|
|
54
|
+
* Generates a credential request to send to the server.
|
|
55
|
+
*/
|
|
56
|
+
loginStart(password: string): Promise<LoginStartResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Finish the login process.
|
|
59
|
+
* Processes the server's credential response and derives session keys.
|
|
60
|
+
*/
|
|
61
|
+
loginFinish(password: string, serverResponse: Uint8Array, state: Uint8Array): Promise<LoginFinishResult>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { type LoginFinishResult, type LoginStartResult, OpaqueClient, type OpaqueClientConfig, type RegistrationFinishResult, type RegistrationStartResult };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
interface RegistrationStartResult {
|
|
2
|
+
/** The blinded message to send to the server. */
|
|
3
|
+
request: Uint8Array;
|
|
4
|
+
/** Client state to preserve for the finish step. */
|
|
5
|
+
state: Uint8Array;
|
|
6
|
+
}
|
|
7
|
+
interface RegistrationFinishResult {
|
|
8
|
+
/** The registration record to send to the server for storage. */
|
|
9
|
+
record: Uint8Array;
|
|
10
|
+
/** The export key derived during registration. */
|
|
11
|
+
exportKey: Uint8Array;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface LoginStartResult {
|
|
15
|
+
/** The credential request to send to the server. */
|
|
16
|
+
request: Uint8Array;
|
|
17
|
+
/** Client state to preserve for the finish step. */
|
|
18
|
+
state: Uint8Array;
|
|
19
|
+
}
|
|
20
|
+
interface LoginFinishResult {
|
|
21
|
+
/** The credential finalization message to send to the server. */
|
|
22
|
+
finalization: Uint8Array;
|
|
23
|
+
/** The session key for subsequent communication. */
|
|
24
|
+
sessionKey: Uint8Array;
|
|
25
|
+
/** The export key derived during login. */
|
|
26
|
+
exportKey: Uint8Array;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface OpaqueClientConfig {
|
|
30
|
+
/** Server identity (usually the domain, e.g. "sid.example.com") */
|
|
31
|
+
serverId: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* OPAQUE (RFC 9807) client for browser and Node.js environments.
|
|
35
|
+
*
|
|
36
|
+
* Handles the client side of OPAQUE registration and login flows
|
|
37
|
+
* using the WebCrypto API for core operations.
|
|
38
|
+
*/
|
|
39
|
+
declare class OpaqueClient {
|
|
40
|
+
private readonly serverId;
|
|
41
|
+
constructor(config: OpaqueClientConfig);
|
|
42
|
+
/**
|
|
43
|
+
* Start the registration process.
|
|
44
|
+
* Generates a registration request to send to the server.
|
|
45
|
+
*/
|
|
46
|
+
registrationStart(password: string): Promise<RegistrationStartResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Finish the registration process.
|
|
49
|
+
* Processes the server's registration response and produces the final record.
|
|
50
|
+
*/
|
|
51
|
+
registrationFinish(password: string, serverResponse: Uint8Array, state: Uint8Array): Promise<RegistrationFinishResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Start the login process.
|
|
54
|
+
* Generates a credential request to send to the server.
|
|
55
|
+
*/
|
|
56
|
+
loginStart(password: string): Promise<LoginStartResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Finish the login process.
|
|
59
|
+
* Processes the server's credential response and derives session keys.
|
|
60
|
+
*/
|
|
61
|
+
loginFinish(password: string, serverResponse: Uint8Array, state: Uint8Array): Promise<LoginFinishResult>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { type LoginFinishResult, type LoginStartResult, OpaqueClient, type OpaqueClientConfig, type RegistrationFinishResult, type RegistrationStartResult };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/crypto/utils.ts
|
|
4
|
+
var encoder = new TextEncoder();
|
|
5
|
+
function encode(input) {
|
|
6
|
+
return encoder.encode(input);
|
|
7
|
+
}
|
|
8
|
+
async function hash(data) {
|
|
9
|
+
return crypto.subtle.digest("SHA-256", data);
|
|
10
|
+
}
|
|
11
|
+
async function hkdfExpand(prk, info, length) {
|
|
12
|
+
const key = await crypto.subtle.importKey(
|
|
13
|
+
"raw",
|
|
14
|
+
prk,
|
|
15
|
+
{ name: "HKDF" },
|
|
16
|
+
false,
|
|
17
|
+
["deriveBits"]
|
|
18
|
+
);
|
|
19
|
+
const derived = await crypto.subtle.deriveBits(
|
|
20
|
+
{
|
|
21
|
+
name: "HKDF",
|
|
22
|
+
hash: "SHA-256",
|
|
23
|
+
salt: new Uint8Array(32),
|
|
24
|
+
info: encode(info)
|
|
25
|
+
},
|
|
26
|
+
key,
|
|
27
|
+
length * 8
|
|
28
|
+
);
|
|
29
|
+
return new Uint8Array(derived);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/crypto/oprf.ts
|
|
33
|
+
async function oprfBlind(password) {
|
|
34
|
+
const input = encode(password);
|
|
35
|
+
const blind = crypto.getRandomValues(new Uint8Array(32));
|
|
36
|
+
const combined = new Uint8Array([...input, ...blind]);
|
|
37
|
+
const blindedElement = new Uint8Array(await hash(combined));
|
|
38
|
+
return { blindedElement, blind };
|
|
39
|
+
}
|
|
40
|
+
async function oprfFinalize(password, evaluatedElement, blind) {
|
|
41
|
+
const input = encode(password);
|
|
42
|
+
const combined = new Uint8Array([...input, ...evaluatedElement, ...blind]);
|
|
43
|
+
return new Uint8Array(await hash(combined));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/crypto/envelope.ts
|
|
47
|
+
async function buildEnvelope(oprfOutput, serverId) {
|
|
48
|
+
const info = new TextEncoder().encode(`OPAQUE-Envelope-${serverId}`);
|
|
49
|
+
const prk = new Uint8Array(await hash(new Uint8Array([...oprfOutput, ...info])));
|
|
50
|
+
const envelopeKey = await hkdfExpand(prk, "envelope-key", 32);
|
|
51
|
+
const exportKey = await hkdfExpand(prk, "export-key", 32);
|
|
52
|
+
const envelope = new Uint8Array([...envelopeKey]);
|
|
53
|
+
return { envelope, exportKey };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/registration.ts
|
|
57
|
+
async function registrationStart(password, _serverId) {
|
|
58
|
+
const { blindedElement, blind } = await oprfBlind(password);
|
|
59
|
+
return {
|
|
60
|
+
request: blindedElement,
|
|
61
|
+
state: blind
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async function registrationFinish(password, serverResponse, state, serverId) {
|
|
65
|
+
const oprfOutput = await oprfFinalize(password, serverResponse, state);
|
|
66
|
+
const { envelope, exportKey } = await buildEnvelope(oprfOutput, serverId);
|
|
67
|
+
const record = new Uint8Array([...envelope]);
|
|
68
|
+
return {
|
|
69
|
+
record,
|
|
70
|
+
exportKey
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/crypto/ake.ts
|
|
75
|
+
async function deriveKeys(oprfOutput, serverId) {
|
|
76
|
+
const info = new TextEncoder().encode(`OPAQUE-AKE-${serverId}`);
|
|
77
|
+
const prk = new Uint8Array(await hash(new Uint8Array([...oprfOutput, ...info])));
|
|
78
|
+
const sessionKey = await hkdfExpand(prk, "session-key", 32);
|
|
79
|
+
const exportKey = await hkdfExpand(prk, "export-key", 32);
|
|
80
|
+
const finalization = await hkdfExpand(prk, "finalization", 32);
|
|
81
|
+
return { sessionKey, exportKey, finalization };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// src/login.ts
|
|
85
|
+
async function loginStart(password, _serverId) {
|
|
86
|
+
const { blindedElement, blind } = await oprfBlind(password);
|
|
87
|
+
return {
|
|
88
|
+
request: blindedElement,
|
|
89
|
+
state: blind
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
async function loginFinish(password, serverResponse, state, serverId) {
|
|
93
|
+
const oprfOutput = await oprfFinalize(password, serverResponse, state);
|
|
94
|
+
const { sessionKey, exportKey, finalization } = await deriveKeys(oprfOutput, serverId);
|
|
95
|
+
return {
|
|
96
|
+
finalization,
|
|
97
|
+
sessionKey,
|
|
98
|
+
exportKey
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// src/client.ts
|
|
103
|
+
var OpaqueClient = class {
|
|
104
|
+
serverId;
|
|
105
|
+
constructor(config) {
|
|
106
|
+
this.serverId = config.serverId;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Start the registration process.
|
|
110
|
+
* Generates a registration request to send to the server.
|
|
111
|
+
*/
|
|
112
|
+
async registrationStart(password) {
|
|
113
|
+
return registrationStart(password, this.serverId);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Finish the registration process.
|
|
117
|
+
* Processes the server's registration response and produces the final record.
|
|
118
|
+
*/
|
|
119
|
+
async registrationFinish(password, serverResponse, state) {
|
|
120
|
+
return registrationFinish(password, serverResponse, state, this.serverId);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Start the login process.
|
|
124
|
+
* Generates a credential request to send to the server.
|
|
125
|
+
*/
|
|
126
|
+
async loginStart(password) {
|
|
127
|
+
return loginStart(password, this.serverId);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Finish the login process.
|
|
131
|
+
* Processes the server's credential response and derives session keys.
|
|
132
|
+
*/
|
|
133
|
+
async loginFinish(password, serverResponse, state) {
|
|
134
|
+
return loginFinish(password, serverResponse, state, this.serverId);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
exports.OpaqueClient = OpaqueClient;
|
|
139
|
+
//# sourceMappingURL=index.js.map
|
|
140
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/crypto/utils.ts","../src/crypto/oprf.ts","../src/crypto/envelope.ts","../src/registration.ts","../src/crypto/ake.ts","../src/login.ts","../src/client.ts"],"names":[],"mappings":";;;AAAA,IAAM,OAAA,GAAU,IAAI,WAAA,EAAY;AAGzB,SAAS,OAAO,KAAA,EAA2B;AAChD,EAAA,OAAO,OAAA,CAAQ,OAAO,KAAK,CAAA;AAC7B;AAQA,eAAsB,KAAK,IAAA,EAAwC;AACjE,EAAA,OAAO,MAAA,CAAO,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,IAA+B,CAAA;AACxE;AAmBA,eAAsB,UAAA,CACpB,GAAA,EACA,IAAA,EACA,MAAA,EACqB;AACrB,EAAA,MAAM,GAAA,GAAM,MAAM,MAAA,CAAO,MAAA,CAAO,SAAA;AAAA,IAC9B,KAAA;AAAA,IACA,GAAA;AAAA,IACA,EAAE,MAAM,MAAA,EAAO;AAAA,IACf,KAAA;AAAA,IACA,CAAC,YAAY;AAAA,GACf;AAEA,EAAA,MAAM,OAAA,GAAU,MAAM,MAAA,CAAO,MAAA,CAAO,UAAA;AAAA,IAClC;AAAA,MACE,IAAA,EAAM,MAAA;AAAA,MACN,IAAA,EAAM,SAAA;AAAA,MACN,IAAA,EAAM,IAAI,UAAA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,EAA6C;AAC5D,IAAA,OAAO,UAAA,CAAW,QAAA,EAAU,IAAA,CAAK,QAAQ,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WAAA,CACJ,QAAA,EACA,cAAA,EACA,KAAA,EAC4B;AAC5B,IAAA,OAAO,WAAA,CAAY,QAAA,EAAU,cAAA,EAAgB,KAAA,EAAO,KAAK,QAAQ,CAAA;AAAA,EACnE;AACF","file":"index.js","sourcesContent":["const encoder = new TextEncoder();\n\n/** Encode a string to UTF-8 bytes. */\nexport function encode(input: string): Uint8Array {\n return encoder.encode(input);\n}\n\n/** Generate cryptographically secure random bytes. */\nexport function randomBytes(length: number): Uint8Array {\n return crypto.getRandomValues(new Uint8Array(length));\n}\n\n/** SHA-256 hash. */\nexport async function hash(data: Uint8Array): Promise<ArrayBuffer> {\n return crypto.subtle.digest('SHA-256', data as unknown as BufferSource);\n}\n\n/** Concatenate multiple Uint8Arrays. */\nexport function concat(...arrays: Uint8Array[]): Uint8Array {\n const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n for (const arr of arrays) {\n result.set(arr, offset);\n offset += arr.length;\n }\n return result;\n}\n\n/**\n * HKDF-Expand using WebCrypto.\n *\n * Derives key material from a pseudorandom key (PRK) with the given info string.\n */\nexport async function hkdfExpand(\n prk: Uint8Array,\n info: string,\n length: number,\n): Promise<Uint8Array> {\n const key = await crypto.subtle.importKey(\n 'raw',\n prk as unknown as BufferSource,\n { name: 'HKDF' },\n false,\n ['deriveBits'],\n );\n\n const derived = await crypto.subtle.deriveBits(\n {\n name: 'HKDF',\n hash: 'SHA-256',\n salt: new Uint8Array(32) as unknown as BufferSource,\n info: encode(info) as unknown as BufferSource,\n },\n key,\n length * 8,\n );\n\n return new Uint8Array(derived);\n}\n","import { encode, hash } from './utils';\n\nexport interface OprfBlindResult {\n blindedElement: Uint8Array;\n blind: Uint8Array;\n}\n\n/**\n * Blind a password for OPRF evaluation.\n *\n * TODO: Replace with proper ristretto255/Pallas OPRF when WASM is ready.\n * Current implementation is a placeholder using HKDF.\n */\nexport async function oprfBlind(password: string): Promise<OprfBlindResult> {\n const input = encode(password);\n const blind = crypto.getRandomValues(new Uint8Array(32));\n\n // Placeholder: hash(password || blind) as blinded element\n const combined = new Uint8Array([...input, ...blind]);\n const blindedElement = new Uint8Array(await hash(combined));\n\n return { blindedElement, blind };\n}\n\n/**\n * Finalize OPRF by unblinding the server's response.\n *\n * TODO: Replace with proper OPRF finalization when WASM is ready.\n */\nexport async function oprfFinalize(\n password: string,\n evaluatedElement: Uint8Array,\n blind: Uint8Array,\n): Promise<Uint8Array> {\n const input = encode(password);\n const combined = new Uint8Array([...input, ...evaluatedElement, ...blind]);\n return new Uint8Array(await hash(combined));\n}\n","import { hash, hkdfExpand } from './utils';\n\nexport interface EnvelopeResult {\n envelope: Uint8Array;\n exportKey: Uint8Array;\n}\n\n/**\n * Build a credential envelope from the OPRF output.\n *\n * TODO: Replace with proper envelope construction per RFC 9807 Section 4.\n * Current implementation is a placeholder.\n */\nexport async function buildEnvelope(\n oprfOutput: Uint8Array,\n serverId: string,\n): Promise<EnvelopeResult> {\n const info = new TextEncoder().encode(`OPAQUE-Envelope-${serverId}`);\n const prk = new Uint8Array(await hash(new Uint8Array([...oprfOutput, ...info])));\n\n const envelopeKey = await hkdfExpand(prk, 'envelope-key', 32);\n const exportKey = await hkdfExpand(prk, 'export-key', 32);\n\n // Placeholder: envelope is just the encrypted key material\n const envelope = new Uint8Array([...envelopeKey]);\n\n return { envelope, exportKey };\n}\n","import { oprfBlind, oprfFinalize } from './crypto/oprf';\nimport { buildEnvelope } from './crypto/envelope';\nimport { randomBytes } from './crypto/utils';\n\nexport interface RegistrationStartResult {\n /** The blinded message to send to the server. */\n request: Uint8Array;\n /** Client state to preserve for the finish step. */\n state: Uint8Array;\n}\n\nexport interface RegistrationFinishResult {\n /** The registration record to send to the server for storage. */\n record: Uint8Array;\n /** The export key derived during registration. */\n exportKey: Uint8Array;\n}\n\n/**\n * Start OPAQUE registration (client side).\n *\n * 1. Sample a blind scalar r.\n * 2. Compute blindedElement = r * Hash-to-Group(password).\n * 3. Return { request: blindedElement, state: r }.\n */\nexport async function registrationStart(\n password: string,\n _serverId: string,\n): Promise<RegistrationStartResult> {\n const { blindedElement, blind } = await oprfBlind(password);\n\n return {\n request: blindedElement,\n state: blind,\n };\n}\n\n/**\n * Finish OPAQUE registration (client side).\n *\n * 1. Finalize the OPRF output: unblind server response.\n * 2. Derive keys from the OPRF output.\n * 3. Build envelope containing encrypted credentials.\n * 4. Return registration record + export key.\n */\nexport async function registrationFinish(\n password: string,\n serverResponse: Uint8Array,\n state: Uint8Array,\n serverId: string,\n): Promise<RegistrationFinishResult> {\n const oprfOutput = await oprfFinalize(password, serverResponse, state);\n const { envelope, exportKey } = await buildEnvelope(oprfOutput, serverId);\n\n // The record contains the envelope and the client's public key\n const record = new Uint8Array([...envelope]);\n\n return {\n record,\n exportKey,\n };\n}\n","import { hash, hkdfExpand } from './utils';\n\nexport interface AkeResult {\n sessionKey: Uint8Array;\n exportKey: Uint8Array;\n finalization: Uint8Array;\n}\n\n/**\n * Derive session and export keys from OPRF output.\n *\n * TODO: Replace with proper 3DH AKE when full implementation is ready.\n * Current implementation uses HKDF as placeholder.\n */\nexport async function deriveKeys(oprfOutput: Uint8Array, serverId: string): Promise<AkeResult> {\n const info = new TextEncoder().encode(`OPAQUE-AKE-${serverId}`);\n const prk = new Uint8Array(await hash(new Uint8Array([...oprfOutput, ...info])));\n\n const sessionKey = await hkdfExpand(prk, 'session-key', 32);\n const exportKey = await hkdfExpand(prk, 'export-key', 32);\n const finalization = await hkdfExpand(prk, 'finalization', 32);\n\n return { sessionKey, exportKey, finalization };\n}\n","import { oprfBlind, oprfFinalize } from './crypto/oprf';\nimport { deriveKeys } from './crypto/ake';\n\nexport interface LoginStartResult {\n /** The credential request to send to the server. */\n request: Uint8Array;\n /** Client state to preserve for the finish step. */\n state: Uint8Array;\n}\n\nexport interface LoginFinishResult {\n /** The credential finalization message to send to the server. */\n finalization: Uint8Array;\n /** The session key for subsequent communication. */\n sessionKey: Uint8Array;\n /** The export key derived during login. */\n exportKey: Uint8Array;\n}\n\n/**\n * Start OPAQUE login (client side).\n *\n * 1. Blind the password (same as registration start).\n * 2. Generate ephemeral key exchange material.\n * 3. Return credential request + client state.\n */\nexport async function loginStart(\n password: string,\n _serverId: string,\n): Promise<LoginStartResult> {\n const { blindedElement, blind } = await oprfBlind(password);\n\n return {\n request: blindedElement,\n state: blind,\n };\n}\n\n/**\n * Finish OPAQUE login (client side).\n *\n * 1. Unblind the server's OPRF response.\n * 2. Recover credentials from the envelope.\n * 3. Perform authenticated key exchange.\n * 4. Derive session key.\n */\nexport async function loginFinish(\n password: string,\n serverResponse: Uint8Array,\n state: Uint8Array,\n serverId: string,\n): Promise<LoginFinishResult> {\n const oprfOutput = await oprfFinalize(password, serverResponse, state);\n const { sessionKey, exportKey, finalization } = await deriveKeys(oprfOutput, serverId);\n\n return {\n finalization,\n sessionKey,\n exportKey,\n };\n}\n","import { registrationStart, registrationFinish } from './registration';\nimport type { RegistrationStartResult, RegistrationFinishResult } from './registration';\nimport { loginStart, loginFinish } from './login';\nimport type { LoginStartResult, LoginFinishResult } from './login';\n\nexport interface OpaqueClientConfig {\n /** Server identity (usually the domain, e.g. \"sid.example.com\") */\n serverId: string;\n}\n\n/**\n * OPAQUE (RFC 9807) client for browser and Node.js environments.\n *\n * Handles the client side of OPAQUE registration and login flows\n * using the WebCrypto API for core operations.\n */\nexport class OpaqueClient {\n private readonly serverId: string;\n\n constructor(config: OpaqueClientConfig) {\n this.serverId = config.serverId;\n }\n\n /**\n * Start the registration process.\n * Generates a registration request to send to the server.\n */\n async registrationStart(password: string): Promise<RegistrationStartResult> {\n return registrationStart(password, this.serverId);\n }\n\n /**\n * Finish the registration process.\n * Processes the server's registration response and produces the final record.\n */\n async registrationFinish(\n password: string,\n serverResponse: Uint8Array,\n state: Uint8Array,\n ): Promise<RegistrationFinishResult> {\n return registrationFinish(password, serverResponse, state, this.serverId);\n }\n\n /**\n * Start the login process.\n * Generates a credential request to send to the server.\n */\n async loginStart(password: string): Promise<LoginStartResult> {\n return loginStart(password, this.serverId);\n }\n\n /**\n * Finish the login process.\n * Processes the server's credential response and derives session keys.\n */\n async loginFinish(\n password: string,\n serverResponse: Uint8Array,\n state: Uint8Array,\n ): Promise<LoginFinishResult> {\n return loginFinish(password, serverResponse, state, this.serverId);\n }\n}\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// src/crypto/utils.ts
|
|
2
|
+
var encoder = new TextEncoder();
|
|
3
|
+
function encode(input) {
|
|
4
|
+
return encoder.encode(input);
|
|
5
|
+
}
|
|
6
|
+
async function hash(data) {
|
|
7
|
+
return crypto.subtle.digest("SHA-256", data);
|
|
8
|
+
}
|
|
9
|
+
async function hkdfExpand(prk, info, length) {
|
|
10
|
+
const key = await crypto.subtle.importKey(
|
|
11
|
+
"raw",
|
|
12
|
+
prk,
|
|
13
|
+
{ name: "HKDF" },
|
|
14
|
+
false,
|
|
15
|
+
["deriveBits"]
|
|
16
|
+
);
|
|
17
|
+
const derived = await crypto.subtle.deriveBits(
|
|
18
|
+
{
|
|
19
|
+
name: "HKDF",
|
|
20
|
+
hash: "SHA-256",
|
|
21
|
+
salt: new Uint8Array(32),
|
|
22
|
+
info: encode(info)
|
|
23
|
+
},
|
|
24
|
+
key,
|
|
25
|
+
length * 8
|
|
26
|
+
);
|
|
27
|
+
return new Uint8Array(derived);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/crypto/oprf.ts
|
|
31
|
+
async function oprfBlind(password) {
|
|
32
|
+
const input = encode(password);
|
|
33
|
+
const blind = crypto.getRandomValues(new Uint8Array(32));
|
|
34
|
+
const combined = new Uint8Array([...input, ...blind]);
|
|
35
|
+
const blindedElement = new Uint8Array(await hash(combined));
|
|
36
|
+
return { blindedElement, blind };
|
|
37
|
+
}
|
|
38
|
+
async function oprfFinalize(password, evaluatedElement, blind) {
|
|
39
|
+
const input = encode(password);
|
|
40
|
+
const combined = new Uint8Array([...input, ...evaluatedElement, ...blind]);
|
|
41
|
+
return new Uint8Array(await hash(combined));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/crypto/envelope.ts
|
|
45
|
+
async function buildEnvelope(oprfOutput, serverId) {
|
|
46
|
+
const info = new TextEncoder().encode(`OPAQUE-Envelope-${serverId}`);
|
|
47
|
+
const prk = new Uint8Array(await hash(new Uint8Array([...oprfOutput, ...info])));
|
|
48
|
+
const envelopeKey = await hkdfExpand(prk, "envelope-key", 32);
|
|
49
|
+
const exportKey = await hkdfExpand(prk, "export-key", 32);
|
|
50
|
+
const envelope = new Uint8Array([...envelopeKey]);
|
|
51
|
+
return { envelope, exportKey };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/registration.ts
|
|
55
|
+
async function registrationStart(password, _serverId) {
|
|
56
|
+
const { blindedElement, blind } = await oprfBlind(password);
|
|
57
|
+
return {
|
|
58
|
+
request: blindedElement,
|
|
59
|
+
state: blind
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async function registrationFinish(password, serverResponse, state, serverId) {
|
|
63
|
+
const oprfOutput = await oprfFinalize(password, serverResponse, state);
|
|
64
|
+
const { envelope, exportKey } = await buildEnvelope(oprfOutput, serverId);
|
|
65
|
+
const record = new Uint8Array([...envelope]);
|
|
66
|
+
return {
|
|
67
|
+
record,
|
|
68
|
+
exportKey
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/crypto/ake.ts
|
|
73
|
+
async function deriveKeys(oprfOutput, serverId) {
|
|
74
|
+
const info = new TextEncoder().encode(`OPAQUE-AKE-${serverId}`);
|
|
75
|
+
const prk = new Uint8Array(await hash(new Uint8Array([...oprfOutput, ...info])));
|
|
76
|
+
const sessionKey = await hkdfExpand(prk, "session-key", 32);
|
|
77
|
+
const exportKey = await hkdfExpand(prk, "export-key", 32);
|
|
78
|
+
const finalization = await hkdfExpand(prk, "finalization", 32);
|
|
79
|
+
return { sessionKey, exportKey, finalization };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/login.ts
|
|
83
|
+
async function loginStart(password, _serverId) {
|
|
84
|
+
const { blindedElement, blind } = await oprfBlind(password);
|
|
85
|
+
return {
|
|
86
|
+
request: blindedElement,
|
|
87
|
+
state: blind
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
async function loginFinish(password, serverResponse, state, serverId) {
|
|
91
|
+
const oprfOutput = await oprfFinalize(password, serverResponse, state);
|
|
92
|
+
const { sessionKey, exportKey, finalization } = await deriveKeys(oprfOutput, serverId);
|
|
93
|
+
return {
|
|
94
|
+
finalization,
|
|
95
|
+
sessionKey,
|
|
96
|
+
exportKey
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// src/client.ts
|
|
101
|
+
var OpaqueClient = class {
|
|
102
|
+
serverId;
|
|
103
|
+
constructor(config) {
|
|
104
|
+
this.serverId = config.serverId;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Start the registration process.
|
|
108
|
+
* Generates a registration request to send to the server.
|
|
109
|
+
*/
|
|
110
|
+
async registrationStart(password) {
|
|
111
|
+
return registrationStart(password, this.serverId);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Finish the registration process.
|
|
115
|
+
* Processes the server's registration response and produces the final record.
|
|
116
|
+
*/
|
|
117
|
+
async registrationFinish(password, serverResponse, state) {
|
|
118
|
+
return registrationFinish(password, serverResponse, state, this.serverId);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Start the login process.
|
|
122
|
+
* Generates a credential request to send to the server.
|
|
123
|
+
*/
|
|
124
|
+
async loginStart(password) {
|
|
125
|
+
return loginStart(password, this.serverId);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Finish the login process.
|
|
129
|
+
* Processes the server's credential response and derives session keys.
|
|
130
|
+
*/
|
|
131
|
+
async loginFinish(password, serverResponse, state) {
|
|
132
|
+
return loginFinish(password, serverResponse, state, this.serverId);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export { OpaqueClient };
|
|
137
|
+
//# sourceMappingURL=index.mjs.map
|
|
138
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/crypto/utils.ts","../src/crypto/oprf.ts","../src/crypto/envelope.ts","../src/registration.ts","../src/crypto/ake.ts","../src/login.ts","../src/client.ts"],"names":[],"mappings":";AAAA,IAAM,OAAA,GAAU,IAAI,WAAA,EAAY;AAGzB,SAAS,OAAO,KAAA,EAA2B;AAChD,EAAA,OAAO,OAAA,CAAQ,OAAO,KAAK,CAAA;AAC7B;AAQA,eAAsB,KAAK,IAAA,EAAwC;AACjE,EAAA,OAAO,MAAA,CAAO,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,IAA+B,CAAA;AACxE;AAmBA,eAAsB,UAAA,CACpB,GAAA,EACA,IAAA,EACA,MAAA,EACqB;AACrB,EAAA,MAAM,GAAA,GAAM,MAAM,MAAA,CAAO,MAAA,CAAO,SAAA;AAAA,IAC9B,KAAA;AAAA,IACA,GAAA;AAAA,IACA,EAAE,MAAM,MAAA,EAAO;AAAA,IACf,KAAA;AAAA,IACA,CAAC,YAAY;AAAA,GACf;AAEA,EAAA,MAAM,OAAA,GAAU,MAAM,MAAA,CAAO,MAAA,CAAO,UAAA;AAAA,IAClC;AAAA,MACE,IAAA,EAAM,MAAA;AAAA,MACN,IAAA,EAAM,SAAA;AAAA,MACN,IAAA,EAAM,IAAI,UAAA,CAAW,EAAE,CAAA;AAAA,MACvB,IAAA,EAAM,OAAO,IAAI;AAAA,KACnB;AAAA,IACA,GAAA;AAAA,IACA,MAAA,GAAS;AAAA,GACX;AAEA,EAAA,OAA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AAA,CACJ,QAAA,EACA,cAAA,EACA,KAAA,EAC4B;AAC5B,IAAA,OAAO,WAAA,CAAY,QAAA,EAAU,cAAA,EAAgB,KAAA,EAAO,KAAK,QAAQ,CAAA;AAAA,EACnE;AACF","file":"index.mjs","sourcesContent":["const encoder = new TextEncoder();\n\n/** Encode a string to UTF-8 bytes. */\nexport function encode(input: string): Uint8Array {\n return encoder.encode(input);\n}\n\n/** Generate cryptographically secure random bytes. */\nexport function randomBytes(length: number): Uint8Array {\n return crypto.getRandomValues(new Uint8Array(length));\n}\n\n/** SHA-256 hash. */\nexport async function hash(data: Uint8Array): Promise<ArrayBuffer> {\n return crypto.subtle.digest('SHA-256', data as unknown as BufferSource);\n}\n\n/** Concatenate multiple Uint8Arrays. */\nexport function concat(...arrays: Uint8Array[]): Uint8Array {\n const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n for (const arr of arrays) {\n result.set(arr, offset);\n offset += arr.length;\n }\n return result;\n}\n\n/**\n * HKDF-Expand using WebCrypto.\n *\n * Derives key material from a pseudorandom key (PRK) with the given info string.\n */\nexport async function hkdfExpand(\n prk: Uint8Array,\n info: string,\n length: number,\n): Promise<Uint8Array> {\n const key = await crypto.subtle.importKey(\n 'raw',\n prk as unknown as BufferSource,\n { name: 'HKDF' },\n false,\n ['deriveBits'],\n );\n\n const derived = await crypto.subtle.deriveBits(\n {\n name: 'HKDF',\n hash: 'SHA-256',\n salt: new Uint8Array(32) as unknown as BufferSource,\n info: encode(info) as unknown as BufferSource,\n },\n key,\n length * 8,\n );\n\n return new Uint8Array(derived);\n}\n","import { encode, hash } from './utils';\n\nexport interface OprfBlindResult {\n blindedElement: Uint8Array;\n blind: Uint8Array;\n}\n\n/**\n * Blind a password for OPRF evaluation.\n *\n * TODO: Replace with proper ristretto255/Pallas OPRF when WASM is ready.\n * Current implementation is a placeholder using HKDF.\n */\nexport async function oprfBlind(password: string): Promise<OprfBlindResult> {\n const input = encode(password);\n const blind = crypto.getRandomValues(new Uint8Array(32));\n\n // Placeholder: hash(password || blind) as blinded element\n const combined = new Uint8Array([...input, ...blind]);\n const blindedElement = new Uint8Array(await hash(combined));\n\n return { blindedElement, blind };\n}\n\n/**\n * Finalize OPRF by unblinding the server's response.\n *\n * TODO: Replace with proper OPRF finalization when WASM is ready.\n */\nexport async function oprfFinalize(\n password: string,\n evaluatedElement: Uint8Array,\n blind: Uint8Array,\n): Promise<Uint8Array> {\n const input = encode(password);\n const combined = new Uint8Array([...input, ...evaluatedElement, ...blind]);\n return new Uint8Array(await hash(combined));\n}\n","import { hash, hkdfExpand } from './utils';\n\nexport interface EnvelopeResult {\n envelope: Uint8Array;\n exportKey: Uint8Array;\n}\n\n/**\n * Build a credential envelope from the OPRF output.\n *\n * TODO: Replace with proper envelope construction per RFC 9807 Section 4.\n * Current implementation is a placeholder.\n */\nexport async function buildEnvelope(\n oprfOutput: Uint8Array,\n serverId: string,\n): Promise<EnvelopeResult> {\n const info = new TextEncoder().encode(`OPAQUE-Envelope-${serverId}`);\n const prk = new Uint8Array(await hash(new Uint8Array([...oprfOutput, ...info])));\n\n const envelopeKey = await hkdfExpand(prk, 'envelope-key', 32);\n const exportKey = await hkdfExpand(prk, 'export-key', 32);\n\n // Placeholder: envelope is just the encrypted key material\n const envelope = new Uint8Array([...envelopeKey]);\n\n return { envelope, exportKey };\n}\n","import { oprfBlind, oprfFinalize } from './crypto/oprf';\nimport { buildEnvelope } from './crypto/envelope';\nimport { randomBytes } from './crypto/utils';\n\nexport interface RegistrationStartResult {\n /** The blinded message to send to the server. */\n request: Uint8Array;\n /** Client state to preserve for the finish step. */\n state: Uint8Array;\n}\n\nexport interface RegistrationFinishResult {\n /** The registration record to send to the server for storage. */\n record: Uint8Array;\n /** The export key derived during registration. */\n exportKey: Uint8Array;\n}\n\n/**\n * Start OPAQUE registration (client side).\n *\n * 1. Sample a blind scalar r.\n * 2. Compute blindedElement = r * Hash-to-Group(password).\n * 3. Return { request: blindedElement, state: r }.\n */\nexport async function registrationStart(\n password: string,\n _serverId: string,\n): Promise<RegistrationStartResult> {\n const { blindedElement, blind } = await oprfBlind(password);\n\n return {\n request: blindedElement,\n state: blind,\n };\n}\n\n/**\n * Finish OPAQUE registration (client side).\n *\n * 1. Finalize the OPRF output: unblind server response.\n * 2. Derive keys from the OPRF output.\n * 3. Build envelope containing encrypted credentials.\n * 4. Return registration record + export key.\n */\nexport async function registrationFinish(\n password: string,\n serverResponse: Uint8Array,\n state: Uint8Array,\n serverId: string,\n): Promise<RegistrationFinishResult> {\n const oprfOutput = await oprfFinalize(password, serverResponse, state);\n const { envelope, exportKey } = await buildEnvelope(oprfOutput, serverId);\n\n // The record contains the envelope and the client's public key\n const record = new Uint8Array([...envelope]);\n\n return {\n record,\n exportKey,\n };\n}\n","import { hash, hkdfExpand } from './utils';\n\nexport interface AkeResult {\n sessionKey: Uint8Array;\n exportKey: Uint8Array;\n finalization: Uint8Array;\n}\n\n/**\n * Derive session and export keys from OPRF output.\n *\n * TODO: Replace with proper 3DH AKE when full implementation is ready.\n * Current implementation uses HKDF as placeholder.\n */\nexport async function deriveKeys(oprfOutput: Uint8Array, serverId: string): Promise<AkeResult> {\n const info = new TextEncoder().encode(`OPAQUE-AKE-${serverId}`);\n const prk = new Uint8Array(await hash(new Uint8Array([...oprfOutput, ...info])));\n\n const sessionKey = await hkdfExpand(prk, 'session-key', 32);\n const exportKey = await hkdfExpand(prk, 'export-key', 32);\n const finalization = await hkdfExpand(prk, 'finalization', 32);\n\n return { sessionKey, exportKey, finalization };\n}\n","import { oprfBlind, oprfFinalize } from './crypto/oprf';\nimport { deriveKeys } from './crypto/ake';\n\nexport interface LoginStartResult {\n /** The credential request to send to the server. */\n request: Uint8Array;\n /** Client state to preserve for the finish step. */\n state: Uint8Array;\n}\n\nexport interface LoginFinishResult {\n /** The credential finalization message to send to the server. */\n finalization: Uint8Array;\n /** The session key for subsequent communication. */\n sessionKey: Uint8Array;\n /** The export key derived during login. */\n exportKey: Uint8Array;\n}\n\n/**\n * Start OPAQUE login (client side).\n *\n * 1. Blind the password (same as registration start).\n * 2. Generate ephemeral key exchange material.\n * 3. Return credential request + client state.\n */\nexport async function loginStart(\n password: string,\n _serverId: string,\n): Promise<LoginStartResult> {\n const { blindedElement, blind } = await oprfBlind(password);\n\n return {\n request: blindedElement,\n state: blind,\n };\n}\n\n/**\n * Finish OPAQUE login (client side).\n *\n * 1. Unblind the server's OPRF response.\n * 2. Recover credentials from the envelope.\n * 3. Perform authenticated key exchange.\n * 4. Derive session key.\n */\nexport async function loginFinish(\n password: string,\n serverResponse: Uint8Array,\n state: Uint8Array,\n serverId: string,\n): Promise<LoginFinishResult> {\n const oprfOutput = await oprfFinalize(password, serverResponse, state);\n const { sessionKey, exportKey, finalization } = await deriveKeys(oprfOutput, serverId);\n\n return {\n finalization,\n sessionKey,\n exportKey,\n };\n}\n","import { registrationStart, registrationFinish } from './registration';\nimport type { RegistrationStartResult, RegistrationFinishResult } from './registration';\nimport { loginStart, loginFinish } from './login';\nimport type { LoginStartResult, LoginFinishResult } from './login';\n\nexport interface OpaqueClientConfig {\n /** Server identity (usually the domain, e.g. \"sid.example.com\") */\n serverId: string;\n}\n\n/**\n * OPAQUE (RFC 9807) client for browser and Node.js environments.\n *\n * Handles the client side of OPAQUE registration and login flows\n * using the WebCrypto API for core operations.\n */\nexport class OpaqueClient {\n private readonly serverId: string;\n\n constructor(config: OpaqueClientConfig) {\n this.serverId = config.serverId;\n }\n\n /**\n * Start the registration process.\n * Generates a registration request to send to the server.\n */\n async registrationStart(password: string): Promise<RegistrationStartResult> {\n return registrationStart(password, this.serverId);\n }\n\n /**\n * Finish the registration process.\n * Processes the server's registration response and produces the final record.\n */\n async registrationFinish(\n password: string,\n serverResponse: Uint8Array,\n state: Uint8Array,\n ): Promise<RegistrationFinishResult> {\n return registrationFinish(password, serverResponse, state, this.serverId);\n }\n\n /**\n * Start the login process.\n * Generates a credential request to send to the server.\n */\n async loginStart(password: string): Promise<LoginStartResult> {\n return loginStart(password, this.serverId);\n }\n\n /**\n * Finish the login process.\n * Processes the server's credential response and derives session keys.\n */\n async loginFinish(\n password: string,\n serverResponse: Uint8Array,\n state: Uint8Array,\n ): Promise<LoginFinishResult> {\n return loginFinish(password, serverResponse, state, this.serverId);\n }\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@structured-id/opaque",
|
|
3
|
+
"version": "0.0.0-development",
|
|
4
|
+
"description": "OPAQUE (RFC 9807) client library with WebCrypto and WASM",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsup",
|
|
22
|
+
"dev": "tsup --watch",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"test:watch": "vitest",
|
|
25
|
+
"test:cov": "vitest run --coverage",
|
|
26
|
+
"lint": "eslint src/ tests/",
|
|
27
|
+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
28
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"prepublishOnly": "yarn build"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"opaque",
|
|
34
|
+
"pake",
|
|
35
|
+
"authentication",
|
|
36
|
+
"cryptography",
|
|
37
|
+
"webauthn",
|
|
38
|
+
"wasm"
|
|
39
|
+
],
|
|
40
|
+
"author": "StructuredID <oss@structured.id>",
|
|
41
|
+
"license": "Apache-2.0",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/structured-id/opaque.git"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/structured-id/opaque/issues"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/structured-id/opaque#readme",
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=20"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@semantic-release/changelog": "^6.0.0",
|
|
55
|
+
"@semantic-release/git": "^10.0.0",
|
|
56
|
+
"@types/node": "^20.0.0",
|
|
57
|
+
"@vitest/coverage-v8": "^2.0.0",
|
|
58
|
+
"eslint": "^9.0.0",
|
|
59
|
+
"prettier": "^3.0.0",
|
|
60
|
+
"semantic-release": "^24.0.0",
|
|
61
|
+
"tsup": "^8.0.0",
|
|
62
|
+
"typescript": "^5.5.0",
|
|
63
|
+
"vitest": "^2.0.0"
|
|
64
|
+
},
|
|
65
|
+
"packageManager": "yarn@4.0.0",
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public"
|
|
68
|
+
}
|
|
69
|
+
}
|