@sphereon/ssi-sdk-ext.key-utils 0.10.2-next.20
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/README.md +21 -0
- package/dist/digest-methods.d.ts +7 -0
- package/dist/digest-methods.d.ts.map +1 -0
- package/dist/digest-methods.js +95 -0
- package/dist/digest-methods.js.map +1 -0
- package/dist/functions.d.ts +30 -0
- package/dist/functions.d.ts.map +1 -0
- package/dist/functions.js +150 -0
- package/dist/functions.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/jwk-jcs.d.ts +22 -0
- package/dist/jwk-jcs.d.ts.map +1 -0
- package/dist/jwk-jcs.js +178 -0
- package/dist/jwk-jcs.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/key-util-types.d.ts +36 -0
- package/dist/types/key-util-types.d.ts.map +1 -0
- package/dist/types/key-util-types.js +30 -0
- package/dist/types/key-util-types.js.map +1 -0
- package/dist/x509-utils.d.ts +24 -0
- package/dist/x509-utils.d.ts.map +1 -0
- package/dist/x509-utils.js +175 -0
- package/dist/x509-utils.js.map +1 -0
- package/package.json +49 -0
- package/src/digest-methods.ts +74 -0
- package/src/functions.ts +147 -0
- package/src/index.ts +11 -0
- package/src/jwk-jcs.ts +177 -0
- package/src/types/elliptic.d.ts +1 -0
- package/src/types/index.ts +1 -0
- package/src/types/key-util-types.ts +44 -0
- package/src/x509-utils.ts +145 -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 [2022] [Sphereon BV, info@sphereon.com]
|
|
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/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<!--suppress HtmlDeprecatedAttribute -->
|
|
2
|
+
<h1 align="center">
|
|
3
|
+
<br>
|
|
4
|
+
<a href="https://www.sphereon.com"><img src="https://sphereon.com/content/themes/sphereon/assets/img/logo.svg" alt="Sphereon" width="400"></a>
|
|
5
|
+
<br>Key Utils
|
|
6
|
+
<br>
|
|
7
|
+
</h1>
|
|
8
|
+
|
|
9
|
+
This package contains Key generation and transformation functions used by other modules.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
yarn add @sphereon/ssi-sdk-ext.key-utils
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Build
|
|
18
|
+
|
|
19
|
+
```shell
|
|
20
|
+
yarn build
|
|
21
|
+
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type HashAlgorithm = 'SHA-256' | 'SHA-512';
|
|
2
|
+
export type TDigestMethod = (input: string) => string;
|
|
3
|
+
export declare const digestMethodParams: (hashAlgorithm: HashAlgorithm) => {
|
|
4
|
+
hashAlgorithm: HashAlgorithm;
|
|
5
|
+
digestMethod: TDigestMethod;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=digest-methods.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest-methods.d.ts","sourceRoot":"","sources":["../src/digest-methods.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,CAAA;AACjD,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;AAErD,eAAO,MAAM,kBAAkB,kBAAmB,aAAa;mBAAoB,aAAa;kBAAgB,aAAa;CAM5H,CAAA"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.digestMethodParams = void 0;
|
|
27
|
+
const sha256_1 = require("@stablelib/sha256");
|
|
28
|
+
const sha512_1 = require("@stablelib/sha512");
|
|
29
|
+
const u8a = __importStar(require("uint8arrays"));
|
|
30
|
+
const digestMethodParams = (hashAlgorithm) => {
|
|
31
|
+
if (hashAlgorithm === 'SHA-256') {
|
|
32
|
+
return { hashAlgorithm: 'SHA-256', digestMethod: sha256DigestMethod };
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return { hashAlgorithm: 'SHA-512', digestMethod: sha512DigestMethod };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.digestMethodParams = digestMethodParams;
|
|
39
|
+
const sha256DigestMethod = (input) => {
|
|
40
|
+
return u8a.toString((0, sha256_1.hash)(u8a.fromString(input, 'utf-8')), 'base16');
|
|
41
|
+
};
|
|
42
|
+
const sha512DigestMethod = (input) => {
|
|
43
|
+
return u8a.toString((0, sha512_1.hash)(u8a.fromString(input, 'utf-8')), 'base16');
|
|
44
|
+
};
|
|
45
|
+
/*
|
|
46
|
+
// PKCS#1 (PSS) mask generation function
|
|
47
|
+
function pss_mgf1_str(seed, len, hash) {
|
|
48
|
+
var mask = '', i = 0;
|
|
49
|
+
|
|
50
|
+
while (mask.length < len) {
|
|
51
|
+
mask += hextorstr(hash(rstrtohex(seed + String.fromCharCode.apply(String, [
|
|
52
|
+
(i & 0xff000000) >> 24,
|
|
53
|
+
(i & 0x00ff0000) >> 16,
|
|
54
|
+
(i & 0x0000ff00) >> 8,
|
|
55
|
+
i & 0x000000ff]))));
|
|
56
|
+
i += 1;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return mask;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
*/
|
|
63
|
+
/*
|
|
64
|
+
|
|
65
|
+
/!**
|
|
66
|
+
* Generate mask of specified length.
|
|
67
|
+
*
|
|
68
|
+
* @param {String} seed The seed for mask generation.
|
|
69
|
+
* @param maskLen Number of bytes to generate.
|
|
70
|
+
* @return {String} The generated mask.
|
|
71
|
+
*!/
|
|
72
|
+
export const mgf1 = (dm: TDigestMethod, seed: string, maskLen: number) => {
|
|
73
|
+
/!* 2. Let T be the empty octet string. *!/
|
|
74
|
+
var t = new forge.util.ByteBuffer();
|
|
75
|
+
|
|
76
|
+
/!* 3. For counter from 0 to ceil(maskLen / hLen), do the following: *!/
|
|
77
|
+
var len = Math.ceil(maskLen / md.digestLength);
|
|
78
|
+
for(var i = 0; i < len; i++) {
|
|
79
|
+
/!* a. Convert counter to an octet string C of length 4 octets *!/
|
|
80
|
+
var c = new forge.util.ByteBuffer();
|
|
81
|
+
c.putInt32(i);
|
|
82
|
+
|
|
83
|
+
/!* b. Concatenate the hash of the seed mgfSeed and C to the octet
|
|
84
|
+
* string T: *!/
|
|
85
|
+
md.start();
|
|
86
|
+
md.update(seed + c.getBytes());
|
|
87
|
+
t.putBuffer(md.digest());
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/!* Output the leading maskLen octets of T as the octet string mask. *!/
|
|
91
|
+
t.truncate(t.length() - maskLen);
|
|
92
|
+
return t.getBytes();
|
|
93
|
+
}
|
|
94
|
+
*/
|
|
95
|
+
//# sourceMappingURL=digest-methods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest-methods.js","sourceRoot":"","sources":["../src/digest-methods.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAkD;AAClD,8CAAkD;AAClD,iDAAkC;AAK3B,MAAM,kBAAkB,GAAG,CAAC,aAA4B,EAAiE,EAAE;IAChI,IAAI,aAAa,KAAK,SAAS,EAAE;QAC/B,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAE,CAAA;KACtE;SAAM;QACL,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAE,CAAA;KACtE;AACH,CAAC,CAAA;AANY,QAAA,kBAAkB,sBAM9B;AAED,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAU,EAAE;IACnD,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAA,aAAM,EAAC,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA;AACvE,CAAC,CAAA;AAED,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAU,EAAE;IACnD,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAA,aAAM,EAAC,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA;AACvE,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { JsonWebKey } from 'did-resolver';
|
|
2
|
+
import { JwkKeyUse, TKeyType } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Generates a random Private Hex Key for the specified key type
|
|
5
|
+
* @param type The key type
|
|
6
|
+
* @return The private key in Hex form
|
|
7
|
+
*/
|
|
8
|
+
export declare const generatePrivateKeyHex: (type: TKeyType) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Converts hex value to base64url
|
|
11
|
+
* @param value hex value
|
|
12
|
+
* @return Base64Url encoded value
|
|
13
|
+
*/
|
|
14
|
+
export declare const hex2base64url: (value: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Converts a public key in hex format to a JWK
|
|
17
|
+
* @param publicKeyHex public key in hex
|
|
18
|
+
* @param type The type of the key (Ed25519, Secp256k1/r1)
|
|
19
|
+
* @param use The optional use for the key (sig/enc)
|
|
20
|
+
* @return The JWK
|
|
21
|
+
*/
|
|
22
|
+
export declare const toJwk: (publicKeyHex: string, type: TKeyType, use?: JwkKeyUse) => JsonWebKey;
|
|
23
|
+
/**
|
|
24
|
+
* Determines the use param based upon the key/signature type or supplied use value.
|
|
25
|
+
*
|
|
26
|
+
* @param type The key type
|
|
27
|
+
* @param suppliedUse A supplied use. Will be used in case it is present
|
|
28
|
+
*/
|
|
29
|
+
export declare const jwkDetermineUse: (type: TKeyType, suppliedUse?: JwkKeyUse) => JwkKeyUse | undefined;
|
|
30
|
+
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,EAAwC,SAAS,EAAgB,QAAQ,EAAE,MAAM,SAAS,CAAA;AAGjG;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,SAAU,QAAQ,KAAG,MAetD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,UAAW,MAAM,WAM1C,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,iBAAkB,MAAM,QAAQ,QAAQ,QAAQ,SAAS,KAAG,UAW7E,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,SAAU,QAAQ,gBAAgB,SAAS,KAAG,SAAS,GAAG,SAQrF,CAAA"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.jwkDetermineUse = exports.toJwk = exports.hex2base64url = exports.generatePrivateKeyHex = void 0;
|
|
30
|
+
const random_1 = require("@ethersproject/random");
|
|
31
|
+
const ed25519_1 = require("@stablelib/ed25519");
|
|
32
|
+
const u8a = __importStar(require("uint8arrays"));
|
|
33
|
+
const types_1 = require("./types");
|
|
34
|
+
const elliptic_1 = __importDefault(require("elliptic"));
|
|
35
|
+
/**
|
|
36
|
+
* Generates a random Private Hex Key for the specified key type
|
|
37
|
+
* @param type The key type
|
|
38
|
+
* @return The private key in Hex form
|
|
39
|
+
*/
|
|
40
|
+
const generatePrivateKeyHex = (type) => {
|
|
41
|
+
switch (type) {
|
|
42
|
+
case types_1.Key.Ed25519: {
|
|
43
|
+
const keyPairEd25519 = (0, ed25519_1.generateKeyPair)();
|
|
44
|
+
return u8a.toString(keyPairEd25519.secretKey, 'base16');
|
|
45
|
+
}
|
|
46
|
+
// The Secp256 types use the same method to generate the key
|
|
47
|
+
case types_1.Key.Secp256r1:
|
|
48
|
+
case types_1.Key.Secp256k1: {
|
|
49
|
+
const privateBytes = (0, random_1.randomBytes)(32);
|
|
50
|
+
return u8a.toString(privateBytes, 'base16');
|
|
51
|
+
}
|
|
52
|
+
default:
|
|
53
|
+
throw Error(`not_supported: Key type ${type} not yet supported for this did:jwk implementation`);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
exports.generatePrivateKeyHex = generatePrivateKeyHex;
|
|
57
|
+
/**
|
|
58
|
+
* Converts hex value to base64url
|
|
59
|
+
* @param value hex value
|
|
60
|
+
* @return Base64Url encoded value
|
|
61
|
+
*/
|
|
62
|
+
const hex2base64url = (value) => {
|
|
63
|
+
const buffer = Buffer.from(value, 'hex');
|
|
64
|
+
const base64 = buffer.toString('base64');
|
|
65
|
+
const base64url = base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
66
|
+
return base64url;
|
|
67
|
+
};
|
|
68
|
+
exports.hex2base64url = hex2base64url;
|
|
69
|
+
/**
|
|
70
|
+
* Converts a public key in hex format to a JWK
|
|
71
|
+
* @param publicKeyHex public key in hex
|
|
72
|
+
* @param type The type of the key (Ed25519, Secp256k1/r1)
|
|
73
|
+
* @param use The optional use for the key (sig/enc)
|
|
74
|
+
* @return The JWK
|
|
75
|
+
*/
|
|
76
|
+
const toJwk = (publicKeyHex, type, use) => {
|
|
77
|
+
switch (type) {
|
|
78
|
+
case types_1.Key.Ed25519:
|
|
79
|
+
return toEd25519Jwk(publicKeyHex, use);
|
|
80
|
+
case types_1.Key.Secp256k1:
|
|
81
|
+
return toSecp256k1Jwk(publicKeyHex, use);
|
|
82
|
+
case types_1.Key.Secp256r1:
|
|
83
|
+
return toSecp256r1Jwk(publicKeyHex, use);
|
|
84
|
+
default:
|
|
85
|
+
throw new Error(`not_supported: Key type ${type} not yet supported for this did:jwk implementation`);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
exports.toJwk = toJwk;
|
|
89
|
+
/**
|
|
90
|
+
* Determines the use param based upon the key/signature type or supplied use value.
|
|
91
|
+
*
|
|
92
|
+
* @param type The key type
|
|
93
|
+
* @param suppliedUse A supplied use. Will be used in case it is present
|
|
94
|
+
*/
|
|
95
|
+
const jwkDetermineUse = (type, suppliedUse) => {
|
|
96
|
+
return suppliedUse
|
|
97
|
+
? suppliedUse
|
|
98
|
+
: types_1.SIG_KEY_ALGS.includes(type)
|
|
99
|
+
? types_1.JwkKeyUse.Signature
|
|
100
|
+
: types_1.ENC_KEY_ALGS.includes(type)
|
|
101
|
+
? types_1.JwkKeyUse.Encryption
|
|
102
|
+
: undefined;
|
|
103
|
+
};
|
|
104
|
+
exports.jwkDetermineUse = jwkDetermineUse;
|
|
105
|
+
/**
|
|
106
|
+
* Assert the key has a proper length
|
|
107
|
+
*
|
|
108
|
+
* @param keyHex Input key
|
|
109
|
+
* @param expectedKeyLength Expected key length
|
|
110
|
+
*/
|
|
111
|
+
const assertProperKeyLength = (keyHex, expectedKeyLength) => {
|
|
112
|
+
if (keyHex.length !== expectedKeyLength) {
|
|
113
|
+
throw Error(`Invalid key length. Needs to be a hex string with length ${expectedKeyLength} instead of ${keyHex.length}. Input: ${keyHex}`);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Generates a JWK from a Secp256k1 public key
|
|
118
|
+
* @param publicKeyHex Secp256k1 public key in hex
|
|
119
|
+
* @param use The use for the key
|
|
120
|
+
* @return The JWK
|
|
121
|
+
*/
|
|
122
|
+
const toSecp256k1Jwk = (publicKeyHex, use) => {
|
|
123
|
+
assertProperKeyLength(publicKeyHex, 130);
|
|
124
|
+
return Object.assign(Object.assign({ alg: 'ES256K' }, (use !== undefined && { use })), { kty: types_1.KeyType.EC, crv: types_1.KeyCurve.Secp256k1, x: (0, exports.hex2base64url)(publicKeyHex.substr(2, 64)), y: (0, exports.hex2base64url)(publicKeyHex.substr(66, 64)) });
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Generates a JWK from a Secp256r1 public key
|
|
128
|
+
* @param publicKeyHex Secp256r1 public key in hex
|
|
129
|
+
* @param use The use for the key
|
|
130
|
+
* @return The JWK
|
|
131
|
+
*/
|
|
132
|
+
const toSecp256r1Jwk = (publicKeyHex, use) => {
|
|
133
|
+
assertProperKeyLength(publicKeyHex, 64);
|
|
134
|
+
const secp256r1 = new elliptic_1.default.ec('p256');
|
|
135
|
+
const publicKey = `03${publicKeyHex}`; // We add the 'compressed' type 03 prefix
|
|
136
|
+
const key = secp256r1.keyFromPublic(publicKey, 'hex');
|
|
137
|
+
const pubPoint = key.getPublic();
|
|
138
|
+
return Object.assign(Object.assign({ alg: 'ES256' }, (use !== undefined && { use })), { kty: types_1.KeyType.EC, crv: types_1.KeyCurve.P_256, x: (0, exports.hex2base64url)(pubPoint.getX().toString('hex')), y: (0, exports.hex2base64url)(pubPoint.getY().toString('hex')) });
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Generates a JWK from an Ed25519 public key
|
|
142
|
+
* @param publicKeyHex Ed25519 public key in hex
|
|
143
|
+
* @param use The use for the key
|
|
144
|
+
* @return The JWK
|
|
145
|
+
*/
|
|
146
|
+
const toEd25519Jwk = (publicKeyHex, use) => {
|
|
147
|
+
assertProperKeyLength(publicKeyHex, 64);
|
|
148
|
+
return Object.assign(Object.assign({ alg: 'EdDSA' }, (use !== undefined && { use })), { kty: types_1.KeyType.OKP, crv: types_1.KeyCurve.Ed25519, x: (0, exports.hex2base64url)(publicKeyHex.substr(0, 64)) });
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":"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"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides `did:jwk` {@link @veramo/did-provider-jwk#JwkDIDProvider | identifier provider }
|
|
3
|
+
* for the {@link @veramo/did-manager#DIDManager}
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
export * from './functions';
|
|
8
|
+
export * from './jwk-jcs';
|
|
9
|
+
export * from './types';
|
|
10
|
+
export * from './x509-utils';
|
|
11
|
+
export * from './digest-methods';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* Provides `did:jwk` {@link @veramo/did-provider-jwk#JwkDIDProvider | identifier provider }
|
|
19
|
+
* for the {@link @veramo/did-manager#DIDManager}
|
|
20
|
+
*
|
|
21
|
+
* @packageDocumentation
|
|
22
|
+
*/
|
|
23
|
+
__exportStar(require("./functions"), exports);
|
|
24
|
+
__exportStar(require("./jwk-jcs"), exports);
|
|
25
|
+
__exportStar(require("./types"), exports);
|
|
26
|
+
__exportStar(require("./x509-utils"), exports);
|
|
27
|
+
__exportStar(require("./digest-methods"), exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;GAKG;AACH,8CAA2B;AAC3B,4CAAyB;AACzB,0CAAuB;AACvB,+CAA4B;AAC5B,mDAAgC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ByteView } from 'multiformats/codecs/interface';
|
|
2
|
+
import type { JsonWebKey } from 'did-resolver';
|
|
3
|
+
/**
|
|
4
|
+
* Encodes a JWK into a Uint8Array. Only the required JWK members are encoded.
|
|
5
|
+
*
|
|
6
|
+
* @see https://www.rfc-editor.org/rfc/rfc7518#section-6
|
|
7
|
+
* @see https://www.rfc-editor.org/rfc/rfc8037#section-2
|
|
8
|
+
* @see https://github.com/panva/jose/blob/3b8aa47b92d07a711bf5c3125276cc9a011794a4/src/jwk/thumbprint.ts#L37
|
|
9
|
+
*
|
|
10
|
+
* @param jwk - JSON Web Key.
|
|
11
|
+
* @returns Uint8Array-encoded JWK.
|
|
12
|
+
*/
|
|
13
|
+
export declare function jwkJcsEncode(jwk: unknown): Uint8Array;
|
|
14
|
+
/**
|
|
15
|
+
* Decodes an array of bytes into a JWK. Throws an error if the JWK is not valid.
|
|
16
|
+
*
|
|
17
|
+
* @param bytes - The array of bytes to decode.
|
|
18
|
+
* @returns The corresponding JSON Web Key.
|
|
19
|
+
*/
|
|
20
|
+
export declare function jwkJcsDecode(bytes: ByteView<JsonWebKey>): JsonWebKey;
|
|
21
|
+
export declare function jcsCanonicalize(object: any): string;
|
|
22
|
+
//# sourceMappingURL=jwk-jcs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwk-jcs.d.ts","sourceRoot":"","sources":["../src/jwk-jcs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAuF9C;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,UAAU,CAIrD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,UAAU,CAOpE;AAGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,GAAG,UAsD1C"}
|