@substrate-system/keys 0.2.10 → 0.2.12
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/dist/_base.cjs +12 -11
- package/dist/_base.cjs.map +3 -3
- package/dist/_base.d.ts +2 -2
- package/dist/_base.d.ts.map +1 -1
- package/dist/_base.js +6 -4
- package/dist/_base.js.map +2 -2
- package/dist/_base.min.cjs +1 -1
- package/dist/_base.min.cjs.map +3 -3
- package/dist/_base.min.js +2 -2
- package/dist/_base.min.js.map +4 -4
- package/dist/aes/index.cjs +3 -2
- package/dist/aes/index.cjs.map +2 -2
- package/dist/aes/index.js +1 -1
- package/dist/aes/index.js.map +2 -2
- package/dist/aes/index.min.cjs +1 -1
- package/dist/aes/index.min.cjs.map +3 -3
- package/dist/aes/index.min.js +2 -2
- package/dist/aes/index.min.js.map +4 -4
- package/dist/browser/index.js +178 -177
- package/dist/browser/index.min.js +2 -2
- package/dist/crypto.cjs +221 -0
- package/dist/crypto.cjs.map +7 -0
- package/dist/crypto.d.ts +54 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +208 -0
- package/dist/crypto.js.map +7 -0
- package/dist/crypto.min.cjs +4 -0
- package/dist/crypto.min.cjs.map +7 -0
- package/dist/crypto.min.js +4 -0
- package/dist/crypto.min.js.map +7 -0
- package/dist/ecc/index.min.js +2 -2
- package/dist/ecc/index.min.js.map +4 -4
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +4 -4
- package/dist/meta.json +99 -34
- package/dist/rsa/index.cjs +12 -11
- package/dist/rsa/index.cjs.map +3 -3
- package/dist/rsa/index.d.ts +2 -2
- package/dist/rsa/index.d.ts.map +1 -1
- package/dist/rsa/index.js +8 -6
- package/dist/rsa/index.js.map +2 -2
- package/dist/rsa/index.min.cjs +1 -1
- package/dist/rsa/index.min.cjs.map +3 -3
- package/dist/rsa/index.min.js +2 -2
- package/dist/rsa/index.min.js.map +4 -4
- package/dist/util.cjs +13 -203
- package/dist/util.cjs.map +3 -3
- package/dist/util.d.ts +4 -54
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +14 -198
- package/dist/util.js.map +3 -3
- package/dist/util.min.cjs +1 -3
- package/dist/util.min.cjs.map +3 -3
- package/dist/util.min.js +1 -3
- package/dist/util.min.js.map +4 -4
- package/package.json +5 -1
package/dist/util.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
7
|
var __export = (target, all) => {
|
|
@@ -18,33 +16,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
16
|
}
|
|
19
17
|
return to;
|
|
20
18
|
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
20
|
var util_exports = {};
|
|
31
21
|
__export(util_exports, {
|
|
32
22
|
InvalidKeyUse: () => InvalidKeyUse,
|
|
33
23
|
InvalidMaxValue: () => InvalidMaxValue,
|
|
34
24
|
base64ToArrBuf: () => base64ToArrBuf,
|
|
35
|
-
checkValidKeyUse: () => checkValidKeyUse,
|
|
36
25
|
createDeviceName: () => createDeviceName,
|
|
37
|
-
did: () => did,
|
|
38
26
|
didToPublicKey: () => didToPublicKey,
|
|
39
|
-
ed25519Verify: () => ed25519Verify,
|
|
40
27
|
fromBase64: () => fromBase64,
|
|
41
28
|
getDeviceName: () => getDeviceName,
|
|
42
|
-
getPublicKeyAsArrayBuffer: () => getPublicKeyAsArrayBuffer,
|
|
43
|
-
getPublicKeyAsUint8Array: () => getPublicKeyAsUint8Array,
|
|
44
29
|
importKey: () => importKey,
|
|
45
|
-
importPublicKey: () => importPublicKey,
|
|
46
|
-
importRsaKey: () => importRsaKey,
|
|
47
|
-
isCryptoKey: () => isCryptoKey,
|
|
48
30
|
joinBufs: () => joinBufs,
|
|
49
31
|
makeEccKeypair: () => makeEccKeypair,
|
|
50
32
|
makeRSAKeypair: () => makeRSAKeypair,
|
|
@@ -53,52 +35,25 @@ __export(util_exports, {
|
|
|
53
35
|
normalizeUnicodeToBuf: () => normalizeUnicodeToBuf,
|
|
54
36
|
normalizeUtf16ToBuf: () => normalizeUtf16ToBuf,
|
|
55
37
|
normalizeUtf8ToBuf: () => normalizeUtf8ToBuf,
|
|
56
|
-
publicKeyToDid: () => publicKeyToDid,
|
|
57
38
|
randomBuf: () => randomBuf,
|
|
58
|
-
rsaOperations: () => rsaOperations,
|
|
59
|
-
rsaVerify: () => rsaVerify2,
|
|
60
39
|
sha256: () => sha256,
|
|
61
40
|
strToArrBuf: () => strToArrBuf,
|
|
41
|
+
toArrayBuffer: () => toArrayBuffer,
|
|
62
42
|
toBase64: () => toBase64
|
|
63
43
|
});
|
|
64
44
|
module.exports = __toCommonJS(util_exports);
|
|
65
45
|
var import_one_webcrypto = require("@substrate-system/one-webcrypto");
|
|
66
46
|
var import_uint8arrays = require("uint8arrays");
|
|
67
|
-
var import_tweetnacl = __toESM(require("tweetnacl"), 1);
|
|
68
47
|
var import_types = require("./types.js");
|
|
69
48
|
var import_constants = require("./constants.js");
|
|
49
|
+
const InvalidKeyUse = new Error("Invalid key use. Please use 'encryption' or 'signing");
|
|
50
|
+
const InvalidMaxValue = new Error("Max must be less than 256 and greater than 0");
|
|
70
51
|
function toArrayBuffer(data) {
|
|
71
52
|
return new Uint8Array(data).buffer;
|
|
72
53
|
}
|
|
73
54
|
__name(toArrayBuffer, "toArrayBuffer");
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"bls12-381": {
|
|
77
|
-
magicBytes: new Uint8Array([234, 1]),
|
|
78
|
-
verify: /* @__PURE__ */ __name(() => {
|
|
79
|
-
throw new Error("Not implemented");
|
|
80
|
-
}, "verify")
|
|
81
|
-
},
|
|
82
|
-
rsa: {
|
|
83
|
-
magicBytes: new Uint8Array([0, 245, 2]),
|
|
84
|
-
verify: rsaVerify2
|
|
85
|
-
},
|
|
86
|
-
ed25519: {
|
|
87
|
-
magicBytes: new Uint8Array([237, 1]),
|
|
88
|
-
verify: ed25519Verify
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
async function ed25519Verify({
|
|
93
|
-
message,
|
|
94
|
-
publicKey,
|
|
95
|
-
signature
|
|
96
|
-
}) {
|
|
97
|
-
return import_tweetnacl.default.sign.detached.verify(message, signature, publicKey);
|
|
98
|
-
}
|
|
99
|
-
__name(ed25519Verify, "ed25519Verify");
|
|
100
|
-
async function createDeviceName(did2) {
|
|
101
|
-
const normalizedDid = did2.normalize("NFD");
|
|
55
|
+
async function createDeviceName(did) {
|
|
56
|
+
const normalizedDid = did.normalize("NFD");
|
|
102
57
|
const hashedUsername = await sha256(
|
|
103
58
|
new TextEncoder().encode(normalizedDid)
|
|
104
59
|
);
|
|
@@ -111,118 +66,6 @@ async function sha256(bytes) {
|
|
|
111
66
|
);
|
|
112
67
|
}
|
|
113
68
|
__name(sha256, "sha256");
|
|
114
|
-
async function publicKeyToDid(_publicKey, keyType = "rsa") {
|
|
115
|
-
const publicKey = _publicKey instanceof CryptoKey ? new Uint8Array(await getPublicKeyAsArrayBuffer(_publicKey)) : _publicKey;
|
|
116
|
-
const prefix = did.keyTypes[keyType]?.magicBytes;
|
|
117
|
-
if (!prefix) {
|
|
118
|
-
throw new Error(`Key type '${keyType}' not supported, available types: ${Object.keys(did.keyTypes).join(", ")}`);
|
|
119
|
-
}
|
|
120
|
-
const prefixedBuf = (0, import_uint8arrays.concat)([prefix, publicKey]);
|
|
121
|
-
return import_constants.BASE58_DID_PREFIX + (0, import_uint8arrays.toString)(prefixedBuf, "base58btc");
|
|
122
|
-
}
|
|
123
|
-
__name(publicKeyToDid, "publicKeyToDid");
|
|
124
|
-
const rsaOperations = {
|
|
125
|
-
verify: /* @__PURE__ */ __name(async function rsaVerify(msg, sig, publicKey, charSize = import_constants.DEFAULT_CHAR_SIZE, hashAlg = import_constants.DEFAULT_HASH_ALGORITHM) {
|
|
126
|
-
return import_one_webcrypto.webcrypto.subtle.verify(
|
|
127
|
-
{
|
|
128
|
-
name: import_constants.RSA_SIGN_ALGORITHM,
|
|
129
|
-
saltLength: import_constants.SALT_LENGTH
|
|
130
|
-
},
|
|
131
|
-
typeof publicKey === "string" ? await importPublicKey(publicKey, hashAlg, import_types.KeyUse.Sign) : publicKey,
|
|
132
|
-
normalizeBase64ToBuf(sig),
|
|
133
|
-
normalizeUnicodeToBuf(msg, charSize)
|
|
134
|
-
);
|
|
135
|
-
}, "rsaVerify"),
|
|
136
|
-
sign: /* @__PURE__ */ __name(async function sign(msg, privateKey, charSize = import_constants.DEFAULT_CHAR_SIZE) {
|
|
137
|
-
return import_one_webcrypto.webcrypto.subtle.sign(
|
|
138
|
-
{ name: import_constants.RSA_SIGN_ALGORITHM, saltLength: import_constants.SALT_LENGTH },
|
|
139
|
-
privateKey,
|
|
140
|
-
normalizeUnicodeToBuf(msg, charSize)
|
|
141
|
-
);
|
|
142
|
-
}, "sign"),
|
|
143
|
-
/**
|
|
144
|
-
* Encrypt the given AES key *to* a given public key.
|
|
145
|
-
*/
|
|
146
|
-
encrypt: /* @__PURE__ */ __name(async function rsaEncrypt(msg, publicKey, charSize = import_constants.DEFAULT_CHAR_SIZE, hashAlg = import_constants.DEFAULT_HASH_ALGORITHM) {
|
|
147
|
-
let pubKey;
|
|
148
|
-
if (typeof publicKey === "string") {
|
|
149
|
-
pubKey = await importPublicKey(publicKey, hashAlg, import_types.KeyUse.Exchange);
|
|
150
|
-
} else {
|
|
151
|
-
pubKey = publicKey instanceof Uint8Array ? await importPublicKey(toArrayBuffer(publicKey), hashAlg, import_types.KeyUse.Exchange) : publicKey;
|
|
152
|
-
}
|
|
153
|
-
return import_one_webcrypto.webcrypto.subtle.encrypt(
|
|
154
|
-
{ name: import_constants.RSA_ALGORITHM },
|
|
155
|
-
pubKey,
|
|
156
|
-
normalizeUnicodeToBuf(msg, charSize)
|
|
157
|
-
);
|
|
158
|
-
}, "rsaEncrypt"),
|
|
159
|
-
/**
|
|
160
|
-
* Use RSA to decrypt the given data.
|
|
161
|
-
*/
|
|
162
|
-
decrypt: /* @__PURE__ */ __name(async function rsaDecrypt(_data, privateKey) {
|
|
163
|
-
const key = isCryptoKey(privateKey) ? privateKey : await importRsaKey(privateKey, ["decrypt"]);
|
|
164
|
-
let data;
|
|
165
|
-
if (typeof _data === "string") {
|
|
166
|
-
data = (0, import_uint8arrays.fromString)(_data, "base64pad");
|
|
167
|
-
} else {
|
|
168
|
-
data = _data;
|
|
169
|
-
}
|
|
170
|
-
const arrayBuffer = await import_one_webcrypto.webcrypto.subtle.decrypt(
|
|
171
|
-
{ name: import_constants.RSA_ALGORITHM },
|
|
172
|
-
key,
|
|
173
|
-
data instanceof Uint8Array ? toArrayBuffer(data) : data
|
|
174
|
-
);
|
|
175
|
-
const arr = new Uint8Array(arrayBuffer);
|
|
176
|
-
return arr;
|
|
177
|
-
}, "rsaDecrypt")
|
|
178
|
-
};
|
|
179
|
-
async function rsaVerify2({
|
|
180
|
-
message,
|
|
181
|
-
publicKey,
|
|
182
|
-
signature
|
|
183
|
-
}) {
|
|
184
|
-
return rsaOperations.verify(
|
|
185
|
-
message,
|
|
186
|
-
signature,
|
|
187
|
-
await import_one_webcrypto.webcrypto.subtle.importKey(
|
|
188
|
-
"spki",
|
|
189
|
-
toArrayBuffer(publicKey),
|
|
190
|
-
{ name: import_constants.RSA_SIGN_ALGORITHM, hash: import_constants.RSA_HASHING_ALGORITHM },
|
|
191
|
-
false,
|
|
192
|
-
["verify"]
|
|
193
|
-
),
|
|
194
|
-
8
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
__name(rsaVerify2, "rsaVerify");
|
|
198
|
-
async function importPublicKey(base64Key, hashAlg, use) {
|
|
199
|
-
checkValidKeyUse(use);
|
|
200
|
-
const alg = use === import_types.KeyUse.Exchange ? import_constants.RSA_ALGORITHM : import_constants.RSA_SIGN_ALGORITHM;
|
|
201
|
-
const uses = use === import_types.KeyUse.Exchange ? ["encrypt"] : ["verify"];
|
|
202
|
-
const buf = typeof base64Key === "string" ? base64ToArrBuf(stripKeyHeader(base64Key)) : base64Key;
|
|
203
|
-
return import_one_webcrypto.webcrypto.subtle.importKey("spki", buf, {
|
|
204
|
-
name: alg,
|
|
205
|
-
hash: { name: hashAlg }
|
|
206
|
-
}, true, uses);
|
|
207
|
-
}
|
|
208
|
-
__name(importPublicKey, "importPublicKey");
|
|
209
|
-
const InvalidKeyUse = new Error("Invalid key use. Please use 'encryption' or 'signing");
|
|
210
|
-
const InvalidMaxValue = new Error("Max must be less than 256 and greater than 0");
|
|
211
|
-
function checkValidKeyUse(use) {
|
|
212
|
-
checkValid(use, [import_types.KeyUse.Sign, import_types.KeyUse.Exchange], InvalidKeyUse);
|
|
213
|
-
}
|
|
214
|
-
__name(checkValidKeyUse, "checkValidKeyUse");
|
|
215
|
-
function checkValid(toCheck, opts, error) {
|
|
216
|
-
const match = opts.some((opt) => opt === toCheck);
|
|
217
|
-
if (!match) {
|
|
218
|
-
throw error;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
__name(checkValid, "checkValid");
|
|
222
|
-
function stripKeyHeader(base64Key) {
|
|
223
|
-
return base64Key.replace("-----BEGIN PUBLIC KEY-----\n", "").replace("\n-----END PUBLIC KEY-----", "");
|
|
224
|
-
}
|
|
225
|
-
__name(stripKeyHeader, "stripKeyHeader");
|
|
226
69
|
function base64ToArrBuf(string) {
|
|
227
70
|
const uint8 = (0, import_uint8arrays.fromString)(string, "base64pad");
|
|
228
71
|
return toArrayBuffer(uint8);
|
|
@@ -265,47 +108,13 @@ function normalizeUnicodeToBuf(msg, charSize) {
|
|
|
265
108
|
}
|
|
266
109
|
}
|
|
267
110
|
__name(normalizeUnicodeToBuf, "normalizeUnicodeToBuf");
|
|
268
|
-
function
|
|
269
|
-
|
|
270
|
-
"spki",
|
|
271
|
-
key instanceof Uint8Array ? toArrayBuffer(key) : key,
|
|
272
|
-
{ name: import_constants.RSA_ALGORITHM, hash: import_constants.RSA_HASHING_ALGORITHM },
|
|
273
|
-
false,
|
|
274
|
-
keyUsages
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
__name(importRsaKey, "importRsaKey");
|
|
278
|
-
function isCryptoKey(val) {
|
|
279
|
-
return hasProp(val, "algorithm") && hasProp(val, "extractable") && hasProp(val, "type");
|
|
280
|
-
}
|
|
281
|
-
__name(isCryptoKey, "isCryptoKey");
|
|
282
|
-
function hasProp(data, prop) {
|
|
283
|
-
return typeof data === "object" && data != null && prop in data;
|
|
284
|
-
}
|
|
285
|
-
__name(hasProp, "hasProp");
|
|
286
|
-
async function getPublicKeyAsArrayBuffer(keypair) {
|
|
287
|
-
const spki = keypair instanceof CryptoKey ? await import_one_webcrypto.webcrypto.subtle.exportKey(
|
|
288
|
-
"spki",
|
|
289
|
-
keypair
|
|
290
|
-
) : await import_one_webcrypto.webcrypto.subtle.exportKey(
|
|
291
|
-
"spki",
|
|
292
|
-
keypair.publicKey
|
|
293
|
-
);
|
|
294
|
-
return spki;
|
|
295
|
-
}
|
|
296
|
-
__name(getPublicKeyAsArrayBuffer, "getPublicKeyAsArrayBuffer");
|
|
297
|
-
async function getPublicKeyAsUint8Array(keypair) {
|
|
298
|
-
const arr = await getPublicKeyAsArrayBuffer(keypair);
|
|
299
|
-
return new Uint8Array(arr);
|
|
300
|
-
}
|
|
301
|
-
__name(getPublicKeyAsUint8Array, "getPublicKeyAsUint8Array");
|
|
302
|
-
function didToPublicKey(did2) {
|
|
303
|
-
if (!did2.startsWith(import_constants.BASE58_DID_PREFIX)) {
|
|
111
|
+
function didToPublicKey(did) {
|
|
112
|
+
if (!did.startsWith(import_constants.BASE58_DID_PREFIX)) {
|
|
304
113
|
throw new Error(
|
|
305
114
|
"Please use a base58-encoded DID formatted `did:key:z...`"
|
|
306
115
|
);
|
|
307
116
|
}
|
|
308
|
-
const didWithoutPrefix = "" +
|
|
117
|
+
const didWithoutPrefix = "" + did.substring(import_constants.BASE58_DID_PREFIX.length);
|
|
309
118
|
const magicalBuf = (0, import_uint8arrays.fromString)(didWithoutPrefix, "base58btc");
|
|
310
119
|
const { keyBuffer, type } = parseMagicBytes(toArrayBuffer(magicalBuf));
|
|
311
120
|
return {
|
|
@@ -417,7 +226,8 @@ async function makeEccKeypair(curve, uses) {
|
|
|
417
226
|
return keys;
|
|
418
227
|
}
|
|
419
228
|
__name(makeEccKeypair, "makeEccKeypair");
|
|
420
|
-
async function makeRSAKeypair(size, hashAlg, use) {
|
|
229
|
+
async function makeRSAKeypair(size, hashAlg, use, extractable) {
|
|
230
|
+
const isExtractable = extractable || false;
|
|
421
231
|
if (!Object.values(import_types.KeyUse).includes(use)) {
|
|
422
232
|
throw new Error("invalid key use");
|
|
423
233
|
}
|
|
@@ -428,16 +238,16 @@ async function makeRSAKeypair(size, hashAlg, use) {
|
|
|
428
238
|
modulusLength: size,
|
|
429
239
|
publicExponent: publicExponent(),
|
|
430
240
|
hash: { name: hashAlg }
|
|
431
|
-
},
|
|
241
|
+
}, isExtractable, uses);
|
|
432
242
|
}
|
|
433
243
|
__name(makeRSAKeypair, "makeRSAKeypair");
|
|
434
244
|
function publicExponent() {
|
|
435
245
|
return new Uint8Array([1, 0, 1]);
|
|
436
246
|
}
|
|
437
247
|
__name(publicExponent, "publicExponent");
|
|
438
|
-
async function getDeviceName(
|
|
248
|
+
async function getDeviceName(did) {
|
|
439
249
|
const hashedUsername = await sha256(
|
|
440
|
-
new TextEncoder().encode(
|
|
250
|
+
new TextEncoder().encode(did.normalize("NFD"))
|
|
441
251
|
);
|
|
442
252
|
return (0, import_uint8arrays.toString)(hashedUsername, "base32").slice(0, 32);
|
|
443
253
|
}
|
package/dist/util.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/util.ts"],
|
|
4
|
-
"sourcesContent": ["import { webcrypto } from '@substrate-system/one-webcrypto'\nimport { fromString, concat, toString as uToString } from 'uint8arrays'\nimport tweetnacl from 'tweetnacl'\nimport type {\n DID,\n Msg,\n HashAlg,\n SymmKeyOpts,\n SymmKey,\n RsaSize\n} from './types.js'\nimport {\n KeyUse,\n CharSize,\n} from './types.js'\nimport {\n BASE58_DID_PREFIX,\n KEY_USE,\n RSA_SIGN_ALGORITHM,\n RSA_ALGORITHM,\n DEFAULT_HASH_ALGORITHM,\n DEFAULT_CHAR_SIZE,\n SALT_LENGTH,\n RSA_HASHING_ALGORITHM,\n RSA_DID_PREFIX,\n KEY_TYPE,\n EDWARDS_DID_PREFIX,\n BLS_DID_PREFIX,\n DEFAULT_SYMM_ALGORITHM,\n DEFAULT_SYMM_LENGTH,\n} from './constants.js'\n\n// Helper function to ensure proper ArrayBuffer type\nfunction toArrayBuffer (data: Uint8Array): ArrayBuffer {\n return new Uint8Array(data).buffer\n}\n\nexport type VerifyArgs = {\n message:Uint8Array\n publicKey:Uint8Array\n signature:Uint8Array\n}\n\n/**\n * Using the key type as the record property name (ie. string = key type)\n *\n * The magic bytes are the `code` found in {@link https://github.com/multiformats/multicodec/blob/master/table.csv}\n * encoded as a variable integer (more info about that at {@link https://github.com/multiformats/unsigned-varint)}.\n *\n * The key type is also found in that table.\n * It's the name of the codec minus the `-pub` suffix.\n *\n * Example\n * -------\n * Ed25519 public key\n * Key type: \"ed25519\"\n * Magic bytes: [ 0xed, 0x01 ]\n */\ntype KeyTypes = Record<string, {\n magicBytes:Uint8Array\n verify:(args:VerifyArgs)=>Promise<boolean>\n}>\n\nexport const did:{ keyTypes:KeyTypes } = {\n keyTypes: {\n 'bls12-381': {\n magicBytes: new Uint8Array([0xea, 0x01]),\n verify: () => { throw new Error('Not implemented') },\n },\n rsa: {\n magicBytes: new Uint8Array([0x00, 0xf5, 0x02]),\n verify: rsaVerify,\n },\n ed25519: {\n magicBytes: new Uint8Array([0xed, 0x01]),\n verify: ed25519Verify\n },\n }\n}\n\nexport async function ed25519Verify ({\n message,\n publicKey,\n signature\n}:VerifyArgs):Promise<boolean> {\n return tweetnacl.sign.detached.verify(message, signature, publicKey)\n}\n\n/**\n * Create a 32 character, DNS-friendly hash of the given DID.\n *\n * @param {DID} did String representation of the DID for the device\n * @returns {string} The 32 character, DNS friendly hash\n */\nexport async function createDeviceName (did:DID):Promise<string> {\n const normalizedDid = did.normalize('NFD')\n const hashedUsername = await sha256(\n new TextEncoder().encode(normalizedDid)\n )\n return uToString(hashedUsername, 'base32').slice(0, 32)\n}\n\nexport async function sha256 (bytes:Uint8Array):Promise<Uint8Array> {\n return new Uint8Array(\n await webcrypto.subtle.digest('sha-256', bytes.buffer as ArrayBuffer)\n )\n}\n\n/**\n * Convert a public key to a DID format string.\n *\n * @param {Uint8Array|CryptoKey|CryptoKeyPair} publicKey Public key as Uint8Array\n * @param {'rsa'} [keyType] 'rsa' or 'ecc'\n * @returns {DID} A DID format string\n */\nexport async function publicKeyToDid (\n _publicKey:Uint8Array|CryptoKey,\n keyType:'rsa'|'ed25519' = 'rsa'\n):Promise<DID> {\n const publicKey = ((_publicKey instanceof CryptoKey) ?\n new Uint8Array(await getPublicKeyAsArrayBuffer(_publicKey)) :\n _publicKey\n )\n\n // Prefix public-write key\n const prefix = did.keyTypes[keyType]?.magicBytes\n if (!prefix) {\n throw new Error(`Key type '${keyType}' not supported, ` +\n `available types: ${Object.keys(did.keyTypes).join(', ')}`)\n }\n\n const prefixedBuf = concat([prefix, publicKey])\n\n return (BASE58_DID_PREFIX + uToString(prefixedBuf, 'base58btc')) as DID\n}\n\nexport const rsaOperations = {\n verify: async function rsaVerify (\n msg:Msg,\n sig:Msg,\n publicKey:string|CryptoKey,\n charSize:CharSize = DEFAULT_CHAR_SIZE,\n hashAlg:HashAlg = DEFAULT_HASH_ALGORITHM\n ):Promise<boolean> {\n return webcrypto.subtle.verify(\n {\n name: RSA_SIGN_ALGORITHM,\n saltLength: SALT_LENGTH\n },\n (typeof publicKey === 'string' ?\n await importPublicKey(publicKey, hashAlg, KeyUse.Sign) :\n publicKey),\n normalizeBase64ToBuf(sig),\n normalizeUnicodeToBuf(msg, charSize)\n )\n },\n\n sign: async function sign (\n msg:Msg,\n privateKey:CryptoKey,\n charSize:CharSize = DEFAULT_CHAR_SIZE\n ):Promise<ArrayBuffer> {\n return webcrypto.subtle.sign(\n { name: RSA_SIGN_ALGORITHM, saltLength: SALT_LENGTH },\n privateKey,\n normalizeUnicodeToBuf(msg, charSize)\n )\n },\n\n /**\n * Encrypt the given AES key *to* a given public key.\n */\n encrypt: async function rsaEncrypt (\n msg:Msg,\n publicKey:string|CryptoKey|Uint8Array,\n charSize:CharSize = DEFAULT_CHAR_SIZE,\n hashAlg:HashAlg = DEFAULT_HASH_ALGORITHM\n ):Promise<ArrayBuffer> {\n let pubKey:CryptoKey\n if (typeof publicKey === 'string') {\n pubKey = await importPublicKey(publicKey, hashAlg, KeyUse.Exchange)\n } else {\n pubKey = publicKey instanceof Uint8Array ?\n await importPublicKey(toArrayBuffer(publicKey), hashAlg, KeyUse.Exchange) :\n publicKey\n }\n\n return webcrypto.subtle.encrypt(\n { name: RSA_ALGORITHM },\n pubKey,\n normalizeUnicodeToBuf(msg, charSize)\n )\n },\n\n /**\n * Use RSA to decrypt the given data.\n */\n decrypt: async function rsaDecrypt (\n _data:Uint8Array|string|ArrayBuffer,\n privateKey:CryptoKey|Uint8Array|ArrayBuffer\n ):Promise<Uint8Array> {\n const key = isCryptoKey(privateKey) ?\n privateKey :\n await importRsaKey(privateKey, ['decrypt'])\n\n let data:Uint8Array|ArrayBuffer\n if (typeof _data === 'string') {\n data = fromString(_data, 'base64pad')\n } else {\n data = _data\n }\n\n const arrayBuffer = await webcrypto.subtle.decrypt(\n { name: RSA_ALGORITHM },\n key,\n data instanceof Uint8Array ? toArrayBuffer(data) : data\n )\n\n const arr = new Uint8Array(arrayBuffer)\n\n return arr\n }\n}\n\nexport async function rsaVerify ({\n message,\n publicKey,\n signature\n}:VerifyArgs):Promise<boolean> {\n return rsaOperations.verify(\n message,\n signature,\n await webcrypto.subtle.importKey(\n 'spki',\n toArrayBuffer(publicKey),\n { name: RSA_SIGN_ALGORITHM, hash: RSA_HASHING_ALGORITHM },\n false,\n ['verify']\n ),\n 8\n )\n}\n\nexport async function importPublicKey (\n base64Key:string|ArrayBuffer,\n hashAlg:HashAlg,\n use:KeyUse\n):Promise<CryptoKey> {\n checkValidKeyUse(use)\n const alg = (use === KeyUse.Exchange ? RSA_ALGORITHM : RSA_SIGN_ALGORITHM)\n const uses:KeyUsage[] = use === KeyUse.Exchange ?\n ['encrypt'] :\n ['verify']\n const buf = typeof base64Key === 'string' ?\n base64ToArrBuf(stripKeyHeader(base64Key)) :\n base64Key\n\n return webcrypto.subtle.importKey('spki', buf, {\n name: alg,\n hash: { name: hashAlg }\n }, true, uses)\n}\n\nexport const InvalidKeyUse = new Error(\"Invalid key use. Please use 'encryption' or 'signing\")\nexport const InvalidMaxValue = new Error('Max must be less than 256 and greater than 0')\n\nexport function checkValidKeyUse (use:KeyUse):void {\n checkValid(use, [KeyUse.Sign, KeyUse.Exchange], InvalidKeyUse)\n}\n\nfunction checkValid<T> (toCheck: T, opts: T[], error: Error): void {\n const match = opts.some(opt => opt === toCheck)\n if (!match) {\n throw error\n }\n}\n\nfunction stripKeyHeader (base64Key:string):string {\n return base64Key\n .replace('-----BEGIN PUBLIC KEY-----\\n', '')\n .replace('\\n-----END PUBLIC KEY-----', '')\n}\n\nexport function base64ToArrBuf (string:string):ArrayBuffer {\n const uint8 = fromString(string, 'base64pad')\n return toArrayBuffer(uint8)\n}\n\nexport const normalizeToBuf = (\n msg:Msg,\n strConv:(str:string)=>ArrayBuffer\n):ArrayBuffer => {\n if (typeof msg === 'string') {\n return strConv(msg)\n } else if (typeof msg === 'object' && msg.byteLength !== undefined) {\n // this is the best runtime check I could find for ArrayBuffer/Uint8Array\n const temp = new Uint8Array(msg)\n return temp.buffer\n } else {\n throw new Error('Improper value. Must be a string, ArrayBuffer, Uint8Array')\n }\n}\n\nexport function normalizeBase64ToBuf (msg:Msg):ArrayBuffer {\n return normalizeToBuf(msg, base64ToArrBuf)\n}\n\nexport const normalizeUtf8ToBuf = (msg:Msg): ArrayBuffer => {\n return normalizeToBuf(msg, (str) => strToArrBuf(str, CharSize.B8))\n}\n\nexport function strToArrBuf (str:string, charSize:CharSize):ArrayBuffer {\n const view = charSize === 8 ?\n new Uint8Array(str.length) :\n new Uint16Array(str.length)\n\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n view[i] = str.charCodeAt(i)\n }\n\n return view.buffer\n}\n\nexport const normalizeUtf16ToBuf = (msg:Msg): ArrayBuffer => {\n return normalizeToBuf(msg, (str) => strToArrBuf(str, CharSize.B16))\n}\n\nexport function normalizeUnicodeToBuf (msg:Msg, charSize:CharSize) {\n switch (charSize) {\n case 8: return normalizeUtf8ToBuf(msg)\n default: return normalizeUtf16ToBuf(msg)\n }\n}\n\nexport function importRsaKey (\n key:Uint8Array|ArrayBuffer,\n keyUsages:KeyUsage[]\n):Promise<CryptoKey> {\n return webcrypto.subtle.importKey(\n 'spki',\n key instanceof Uint8Array ? toArrayBuffer(key) : key,\n { name: RSA_ALGORITHM, hash: RSA_HASHING_ALGORITHM },\n false,\n keyUsages\n )\n}\n\nexport function isCryptoKey (val:unknown):val is CryptoKey {\n return (\n hasProp(val, 'algorithm') &&\n hasProp(val, 'extractable') &&\n hasProp(val, 'type')\n )\n}\n\nfunction hasProp<K extends PropertyKey> (\n data:unknown,\n prop:K\n): data is Record<K, unknown> {\n return (typeof data === 'object' && data != null && prop in data)\n}\n\nexport async function getPublicKeyAsArrayBuffer (\n keypair:CryptoKeyPair|CryptoKey\n):Promise<ArrayBuffer> {\n const spki = (keypair instanceof CryptoKey ?\n await webcrypto.subtle.exportKey(\n 'spki',\n keypair\n ) :\n await webcrypto.subtle.exportKey(\n 'spki',\n keypair.publicKey\n )\n )\n\n return spki\n}\n\nexport async function getPublicKeyAsUint8Array (\n keypair:CryptoKeyPair|CryptoKey\n):Promise<Uint8Array> {\n const arr = await getPublicKeyAsArrayBuffer(keypair)\n return new Uint8Array(arr)\n}\n\nexport function didToPublicKey (did:string):({\n publicKey:Uint8Array,\n type:'rsa' | 'ed25519' | 'bls12-381'\n}) {\n if (!did.startsWith(BASE58_DID_PREFIX)) {\n throw new Error(\n 'Please use a base58-encoded DID formatted `did:key:z...`')\n }\n\n const didWithoutPrefix = ('' + did.substring(BASE58_DID_PREFIX.length))\n const magicalBuf = fromString(didWithoutPrefix, 'base58btc')\n const { keyBuffer, type } = parseMagicBytes(toArrayBuffer(magicalBuf))\n\n return {\n publicKey: new Uint8Array(keyBuffer),\n type\n }\n}\n\n/**\n * Parse magic bytes on prefixed key-buffer\n * to determine cryptosystem & the unprefixed key-buffer.\n */\nfunction parseMagicBytes (prefixedKey:ArrayBuffer) {\n // RSA\n if (hasPrefix(prefixedKey, toArrayBuffer(RSA_DID_PREFIX))) {\n return {\n keyBuffer: prefixedKey.slice(RSA_DID_PREFIX.byteLength),\n type: KEY_TYPE.RSA\n }\n // EDWARDS\n } else if (hasPrefix(prefixedKey, toArrayBuffer(EDWARDS_DID_PREFIX))) {\n return {\n keyBuffer: prefixedKey.slice(EDWARDS_DID_PREFIX.byteLength),\n type: KEY_TYPE.Edwards\n }\n // BLS\n } else if (hasPrefix(prefixedKey, toArrayBuffer(BLS_DID_PREFIX))) {\n return {\n keyBuffer: prefixedKey.slice(BLS_DID_PREFIX.byteLength),\n type: KEY_TYPE.BLS\n }\n }\n\n throw new Error('Unsupported key algorithm. Try using RSA.')\n}\n\nconst arrBufs = {\n equal: (aBuf:ArrayBuffer, bBuf:ArrayBuffer) => {\n const a = new Uint8Array(aBuf)\n const b = new Uint8Array(bBuf)\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false\n }\n return true\n }\n}\n\nfunction hasPrefix (prefixedKey:ArrayBuffer, prefix:ArrayBuffer) {\n return arrBufs.equal(prefix, prefixedKey.slice(0, prefix.byteLength))\n}\n\nexport function toBase64 (arr:Uint8Array|ArrayBuffer) {\n return uToString(\n arr instanceof ArrayBuffer ?\n new Uint8Array(arr) :\n arr,\n 'base64pad'\n )\n}\n\nexport function fromBase64 (str:string) {\n return fromString(str, 'base64pad')\n}\n\nexport async function importKey (\n key:string|Uint8Array,\n opts?:Partial<SymmKeyOpts>\n):Promise<SymmKey> {\n const buf = typeof key === 'string' ? base64ToArrBuf(key) : toArrayBuffer(key)\n\n return webcrypto.subtle.importKey(\n 'raw',\n buf,\n {\n name: opts?.alg || DEFAULT_SYMM_ALGORITHM,\n length: opts?.length || DEFAULT_SYMM_LENGTH,\n },\n true,\n ['encrypt', 'decrypt']\n )\n}\n\nexport function randomBuf (\n length:number,\n { max }:{ max:number } = { max: 255 }\n):ArrayBuffer {\n if (max < 1 || max > 255) {\n throw InvalidMaxValue\n }\n\n const arr = new Uint8Array(length)\n\n if (max === 255) {\n webcrypto.getRandomValues(arr)\n return arr.buffer\n }\n\n let index = 0\n const interval = max + 1\n const divisibleMax = Math.floor(256 / interval) * interval\n const tmp = new Uint8Array(1)\n\n while (index < arr.length) {\n webcrypto.getRandomValues(tmp)\n if (tmp[0] < divisibleMax) {\n arr[index] = tmp[0] % interval\n index++\n }\n }\n\n return arr.buffer\n}\n\nexport function joinBufs (fst:ArrayBuffer|Uint8Array, snd:ArrayBuffer|Uint8Array):ArrayBuffer {\n const view1 = fst instanceof ArrayBuffer ? new Uint8Array(fst) : new Uint8Array(toArrayBuffer(fst))\n const view2 = snd instanceof ArrayBuffer ? new Uint8Array(snd) : new Uint8Array(toArrayBuffer(snd))\n const joined = new Uint8Array(view1.length + view2.length)\n joined.set(view1)\n joined.set(view2, view1.length)\n return joined.buffer\n}\n\nexport async function makeEccKeypair (\n curve:'X25519'|'ECDSA',\n uses:'encyrpt'|'sign'\n):Promise<CryptoKeyPair> {\n const keys = await webcrypto.subtle.generateKey(\n { name: curve }, // X25519 or ECDSA\n false, // extractable\n KEY_USE[uses]\n ) as CryptoKeyPair\n\n return keys\n}\n\nexport async function makeRSAKeypair (\n size:RsaSize,\n hashAlg:HashAlg,\n use:KeyUse\n):Promise<CryptoKeyPair> {\n if (!(Object.values(KeyUse).includes(use))) {\n throw new Error('invalid key use')\n }\n const alg = use === KeyUse.Exchange ? RSA_ALGORITHM : RSA_SIGN_ALGORITHM\n const uses:KeyUsage[] = (use === KeyUse.Exchange ?\n ['encrypt', 'decrypt'] :\n ['sign', 'verify'])\n\n return webcrypto.subtle.generateKey({\n name: alg,\n modulusLength: size,\n publicExponent: publicExponent(),\n hash: { name: hashAlg }\n } as RsaHashedKeyGenParams, false, uses)\n}\n\nfunction publicExponent ():Uint8Array {\n return new Uint8Array([0x01, 0x00, 0x01])\n}\n\nexport async function getDeviceName (did:DID|string) {\n const hashedUsername = await sha256(\n new TextEncoder().encode(did.normalize('NFD'))\n )\n\n return uToString(hashedUsername, 'base32').slice(0, 32)\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { webcrypto } from '@substrate-system/one-webcrypto'\nimport { fromString, toString as uToString } from 'uint8arrays'\nimport type {\n DID,\n Msg,\n HashAlg,\n SymmKeyOpts,\n SymmKey,\n RsaSize\n} from './types.js'\nimport {\n KeyUse,\n CharSize,\n} from './types.js'\nimport {\n BASE58_DID_PREFIX,\n KEY_USE,\n RSA_SIGN_ALGORITHM,\n RSA_ALGORITHM,\n RSA_DID_PREFIX,\n KEY_TYPE,\n EDWARDS_DID_PREFIX,\n BLS_DID_PREFIX,\n DEFAULT_SYMM_ALGORITHM,\n DEFAULT_SYMM_LENGTH,\n} from './constants.js'\n\nexport const InvalidKeyUse = new Error('Invalid key use. Please use ' +\n \"'encryption' or 'signing\")\nexport const InvalidMaxValue = new Error('Max must be less than 256 and ' +\n 'greater than 0')\n\n// Helper function to ensure proper ArrayBuffer type\nexport function toArrayBuffer (data: Uint8Array): ArrayBuffer {\n return new Uint8Array(data).buffer\n}\n\nexport type VerifyArgs = {\n message:Uint8Array\n publicKey:Uint8Array\n signature:Uint8Array\n}\n\n/**\n * Create a 32 character, DNS-friendly hash of the given DID.\n *\n * @param {DID} did String representation of the DID for the device\n * @returns {string} The 32 character, DNS friendly hash\n */\nexport async function createDeviceName (did:DID):Promise<string> {\n const normalizedDid = did.normalize('NFD')\n const hashedUsername = await sha256(\n new TextEncoder().encode(normalizedDid)\n )\n return uToString(hashedUsername, 'base32').slice(0, 32)\n}\n\nexport async function sha256 (bytes:Uint8Array):Promise<Uint8Array> {\n return new Uint8Array(\n await webcrypto.subtle.digest('sha-256', bytes.buffer as ArrayBuffer)\n )\n}\n\nexport function base64ToArrBuf (string:string):ArrayBuffer {\n const uint8 = fromString(string, 'base64pad')\n return toArrayBuffer(uint8)\n}\n\nexport const normalizeToBuf = (\n msg:Msg,\n strConv:(str:string)=>ArrayBuffer\n):ArrayBuffer => {\n if (typeof msg === 'string') {\n return strConv(msg)\n } else if (typeof msg === 'object' && msg.byteLength !== undefined) {\n // this is the best runtime check I could find for ArrayBuffer/Uint8Array\n const temp = new Uint8Array(msg)\n return temp.buffer\n } else {\n throw new Error('Improper value. Must be a string, ArrayBuffer, Uint8Array')\n }\n}\n\nexport function normalizeBase64ToBuf (msg:Msg):ArrayBuffer {\n return normalizeToBuf(msg, base64ToArrBuf)\n}\n\nexport const normalizeUtf8ToBuf = (msg:Msg): ArrayBuffer => {\n return normalizeToBuf(msg, (str) => strToArrBuf(str, CharSize.B8))\n}\n\nexport function strToArrBuf (str:string, charSize:CharSize):ArrayBuffer {\n const view = charSize === 8 ?\n new Uint8Array(str.length) :\n new Uint16Array(str.length)\n\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n view[i] = str.charCodeAt(i)\n }\n\n return view.buffer\n}\n\nexport const normalizeUtf16ToBuf = (msg:Msg): ArrayBuffer => {\n return normalizeToBuf(msg, (str) => strToArrBuf(str, CharSize.B16))\n}\n\nexport function normalizeUnicodeToBuf (msg:Msg, charSize:CharSize) {\n switch (charSize) {\n case 8: return normalizeUtf8ToBuf(msg)\n default: return normalizeUtf16ToBuf(msg)\n }\n}\n\nexport function didToPublicKey (did:string):({\n publicKey:Uint8Array,\n type:'rsa' | 'ed25519' | 'bls12-381'\n}) {\n if (!did.startsWith(BASE58_DID_PREFIX)) {\n throw new Error(\n 'Please use a base58-encoded DID formatted `did:key:z...`')\n }\n\n const didWithoutPrefix = ('' + did.substring(BASE58_DID_PREFIX.length))\n const magicalBuf = fromString(didWithoutPrefix, 'base58btc')\n const { keyBuffer, type } = parseMagicBytes(toArrayBuffer(magicalBuf))\n\n return {\n publicKey: new Uint8Array(keyBuffer),\n type\n }\n}\n\n/**\n * Parse magic bytes on prefixed key-buffer\n * to determine cryptosystem & the unprefixed key-buffer.\n */\nfunction parseMagicBytes (prefixedKey:ArrayBuffer) {\n // RSA\n if (hasPrefix(prefixedKey, toArrayBuffer(RSA_DID_PREFIX))) {\n return {\n keyBuffer: prefixedKey.slice(RSA_DID_PREFIX.byteLength),\n type: KEY_TYPE.RSA\n }\n // EDWARDS\n } else if (hasPrefix(prefixedKey, toArrayBuffer(EDWARDS_DID_PREFIX))) {\n return {\n keyBuffer: prefixedKey.slice(EDWARDS_DID_PREFIX.byteLength),\n type: KEY_TYPE.Edwards\n }\n // BLS\n } else if (hasPrefix(prefixedKey, toArrayBuffer(BLS_DID_PREFIX))) {\n return {\n keyBuffer: prefixedKey.slice(BLS_DID_PREFIX.byteLength),\n type: KEY_TYPE.BLS\n }\n }\n\n throw new Error('Unsupported key algorithm. Try using RSA.')\n}\n\nconst arrBufs = {\n equal: (aBuf:ArrayBuffer, bBuf:ArrayBuffer) => {\n const a = new Uint8Array(aBuf)\n const b = new Uint8Array(bBuf)\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false\n }\n return true\n }\n}\n\nfunction hasPrefix (prefixedKey:ArrayBuffer, prefix:ArrayBuffer) {\n return arrBufs.equal(prefix, prefixedKey.slice(0, prefix.byteLength))\n}\n\nexport function toBase64 (arr:Uint8Array|ArrayBuffer) {\n return uToString(\n arr instanceof ArrayBuffer ?\n new Uint8Array(arr) :\n arr,\n 'base64pad'\n )\n}\n\nexport function fromBase64 (str:string) {\n return fromString(str, 'base64pad')\n}\n\nexport async function importKey (\n key:string|Uint8Array,\n opts?:Partial<SymmKeyOpts>\n):Promise<SymmKey> {\n const buf = typeof key === 'string' ? base64ToArrBuf(key) : toArrayBuffer(key)\n\n return webcrypto.subtle.importKey(\n 'raw',\n buf,\n {\n name: opts?.alg || DEFAULT_SYMM_ALGORITHM,\n length: opts?.length || DEFAULT_SYMM_LENGTH,\n },\n true,\n ['encrypt', 'decrypt']\n )\n}\n\nexport function randomBuf (\n length:number,\n { max }:{ max:number } = { max: 255 }\n):ArrayBuffer {\n if (max < 1 || max > 255) {\n throw InvalidMaxValue\n }\n\n const arr = new Uint8Array(length)\n\n if (max === 255) {\n webcrypto.getRandomValues(arr)\n return arr.buffer\n }\n\n let index = 0\n const interval = max + 1\n const divisibleMax = Math.floor(256 / interval) * interval\n const tmp = new Uint8Array(1)\n\n while (index < arr.length) {\n webcrypto.getRandomValues(tmp)\n if (tmp[0] < divisibleMax) {\n arr[index] = tmp[0] % interval\n index++\n }\n }\n\n return arr.buffer\n}\n\nexport function joinBufs (fst:ArrayBuffer|Uint8Array, snd:ArrayBuffer|Uint8Array):ArrayBuffer {\n const view1 = fst instanceof ArrayBuffer ? new Uint8Array(fst) : new Uint8Array(toArrayBuffer(fst))\n const view2 = snd instanceof ArrayBuffer ? new Uint8Array(snd) : new Uint8Array(toArrayBuffer(snd))\n const joined = new Uint8Array(view1.length + view2.length)\n joined.set(view1)\n joined.set(view2, view1.length)\n return joined.buffer\n}\n\nexport async function makeEccKeypair (\n curve:'X25519'|'ECDSA',\n uses:'encyrpt'|'sign'\n):Promise<CryptoKeyPair> {\n const keys = await webcrypto.subtle.generateKey(\n { name: curve }, // X25519 or ECDSA\n false, // extractable\n KEY_USE[uses]\n ) as CryptoKeyPair\n\n return keys\n}\n\nexport async function makeRSAKeypair (\n size:RsaSize,\n hashAlg:HashAlg,\n use:KeyUse,\n extractable?:boolean\n):Promise<CryptoKeyPair> {\n const isExtractable = extractable || false\n if (!(Object.values(KeyUse).includes(use))) {\n throw new Error('invalid key use')\n }\n const alg = use === KeyUse.Exchange ? RSA_ALGORITHM : RSA_SIGN_ALGORITHM\n const uses:KeyUsage[] = (use === KeyUse.Exchange ?\n ['encrypt', 'decrypt'] :\n ['sign', 'verify'])\n\n return webcrypto.subtle.generateKey({\n name: alg,\n modulusLength: size,\n publicExponent: publicExponent(),\n hash: { name: hashAlg }\n } as RsaHashedKeyGenParams, isExtractable, uses)\n}\n\nfunction publicExponent ():Uint8Array {\n return new Uint8Array([0x01, 0x00, 0x01])\n}\n\nexport async function getDeviceName (did:DID|string) {\n const hashedUsername = await sha256(\n new TextEncoder().encode(did.normalize('NFD'))\n )\n\n return uToString(hashedUsername, 'base32').slice(0, 32)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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,QAAQ,oBAAO,WAAW,iCAAgB;AACtD,QAAM,OAAmB,QAAQ,oBAAO,WACpC,CAAC,WAAW,SAAS,IACrB,CAAC,QAAQ,QAAQ;AAErB,SAAO,+BAAU,OAAO,YAAY;AAAA,IAChC,MAAM;AAAA,IACN,eAAe;AAAA,IACf,gBAAgB,eAAe;AAAA,IAC/B,MAAM,EAAE,MAAM,QAAQ;AAAA,EAC1B,GAA4B,eAAe,IAAI;AACnD;AArBsB;AAuBtB,SAAS,iBAA6B;AAClC,SAAO,IAAI,WAAW,CAAC,GAAM,GAAM,CAAI,CAAC;AAC5C;AAFS;AAIT,eAAsB,cAAe,KAAgB;AACjD,QAAM,iBAAiB,MAAM;AAAA,IACzB,IAAI,YAAY,EAAE,OAAO,IAAI,UAAU,KAAK,CAAC;AAAA,EACjD;AAEA,aAAO,mBAAAA,UAAU,gBAAgB,QAAQ,EAAE,MAAM,GAAG,EAAE;AAC1D;AANsB;",
|
|
6
|
+
"names": ["uToString"]
|
|
7
7
|
}
|
package/dist/util.d.ts
CHANGED
|
@@ -1,33 +1,13 @@
|
|
|
1
1
|
import type { DID, Msg, HashAlg, SymmKeyOpts, SymmKey, RsaSize } from './types.js';
|
|
2
2
|
import { KeyUse, CharSize } from './types.js';
|
|
3
|
+
export declare const InvalidKeyUse: Error;
|
|
4
|
+
export declare const InvalidMaxValue: Error;
|
|
5
|
+
export declare function toArrayBuffer(data: Uint8Array): ArrayBuffer;
|
|
3
6
|
export type VerifyArgs = {
|
|
4
7
|
message: Uint8Array;
|
|
5
8
|
publicKey: Uint8Array;
|
|
6
9
|
signature: Uint8Array;
|
|
7
10
|
};
|
|
8
|
-
/**
|
|
9
|
-
* Using the key type as the record property name (ie. string = key type)
|
|
10
|
-
*
|
|
11
|
-
* The magic bytes are the `code` found in {@link https://github.com/multiformats/multicodec/blob/master/table.csv}
|
|
12
|
-
* encoded as a variable integer (more info about that at {@link https://github.com/multiformats/unsigned-varint)}.
|
|
13
|
-
*
|
|
14
|
-
* The key type is also found in that table.
|
|
15
|
-
* It's the name of the codec minus the `-pub` suffix.
|
|
16
|
-
*
|
|
17
|
-
* Example
|
|
18
|
-
* -------
|
|
19
|
-
* Ed25519 public key
|
|
20
|
-
* Key type: "ed25519"
|
|
21
|
-
* Magic bytes: [ 0xed, 0x01 ]
|
|
22
|
-
*/
|
|
23
|
-
type KeyTypes = Record<string, {
|
|
24
|
-
magicBytes: Uint8Array;
|
|
25
|
-
verify: (args: VerifyArgs) => Promise<boolean>;
|
|
26
|
-
}>;
|
|
27
|
-
export declare const did: {
|
|
28
|
-
keyTypes: KeyTypes;
|
|
29
|
-
};
|
|
30
|
-
export declare function ed25519Verify({ message, publicKey, signature }: VerifyArgs): Promise<boolean>;
|
|
31
11
|
/**
|
|
32
12
|
* Create a 32 character, DNS-friendly hash of the given DID.
|
|
33
13
|
*
|
|
@@ -36,31 +16,6 @@ export declare function ed25519Verify({ message, publicKey, signature }: VerifyA
|
|
|
36
16
|
*/
|
|
37
17
|
export declare function createDeviceName(did: DID): Promise<string>;
|
|
38
18
|
export declare function sha256(bytes: Uint8Array): Promise<Uint8Array>;
|
|
39
|
-
/**
|
|
40
|
-
* Convert a public key to a DID format string.
|
|
41
|
-
*
|
|
42
|
-
* @param {Uint8Array|CryptoKey|CryptoKeyPair} publicKey Public key as Uint8Array
|
|
43
|
-
* @param {'rsa'} [keyType] 'rsa' or 'ecc'
|
|
44
|
-
* @returns {DID} A DID format string
|
|
45
|
-
*/
|
|
46
|
-
export declare function publicKeyToDid(_publicKey: Uint8Array | CryptoKey, keyType?: 'rsa' | 'ed25519'): Promise<DID>;
|
|
47
|
-
export declare const rsaOperations: {
|
|
48
|
-
verify: (msg: Msg, sig: Msg, publicKey: string | CryptoKey, charSize?: CharSize, hashAlg?: HashAlg) => Promise<boolean>;
|
|
49
|
-
sign: (msg: Msg, privateKey: CryptoKey, charSize?: CharSize) => Promise<ArrayBuffer>;
|
|
50
|
-
/**
|
|
51
|
-
* Encrypt the given AES key *to* a given public key.
|
|
52
|
-
*/
|
|
53
|
-
encrypt: (msg: Msg, publicKey: string | CryptoKey | Uint8Array, charSize?: CharSize, hashAlg?: HashAlg) => Promise<ArrayBuffer>;
|
|
54
|
-
/**
|
|
55
|
-
* Use RSA to decrypt the given data.
|
|
56
|
-
*/
|
|
57
|
-
decrypt: (_data: Uint8Array | string | ArrayBuffer, privateKey: CryptoKey | Uint8Array | ArrayBuffer) => Promise<Uint8Array>;
|
|
58
|
-
};
|
|
59
|
-
export declare function rsaVerify({ message, publicKey, signature }: VerifyArgs): Promise<boolean>;
|
|
60
|
-
export declare function importPublicKey(base64Key: string | ArrayBuffer, hashAlg: HashAlg, use: KeyUse): Promise<CryptoKey>;
|
|
61
|
-
export declare const InvalidKeyUse: Error;
|
|
62
|
-
export declare const InvalidMaxValue: Error;
|
|
63
|
-
export declare function checkValidKeyUse(use: KeyUse): void;
|
|
64
19
|
export declare function base64ToArrBuf(string: string): ArrayBuffer;
|
|
65
20
|
export declare const normalizeToBuf: (msg: Msg, strConv: (str: string) => ArrayBuffer) => ArrayBuffer;
|
|
66
21
|
export declare function normalizeBase64ToBuf(msg: Msg): ArrayBuffer;
|
|
@@ -68,10 +23,6 @@ export declare const normalizeUtf8ToBuf: (msg: Msg) => ArrayBuffer;
|
|
|
68
23
|
export declare function strToArrBuf(str: string, charSize: CharSize): ArrayBuffer;
|
|
69
24
|
export declare const normalizeUtf16ToBuf: (msg: Msg) => ArrayBuffer;
|
|
70
25
|
export declare function normalizeUnicodeToBuf(msg: Msg, charSize: CharSize): ArrayBuffer;
|
|
71
|
-
export declare function importRsaKey(key: Uint8Array | ArrayBuffer, keyUsages: KeyUsage[]): Promise<CryptoKey>;
|
|
72
|
-
export declare function isCryptoKey(val: unknown): val is CryptoKey;
|
|
73
|
-
export declare function getPublicKeyAsArrayBuffer(keypair: CryptoKeyPair | CryptoKey): Promise<ArrayBuffer>;
|
|
74
|
-
export declare function getPublicKeyAsUint8Array(keypair: CryptoKeyPair | CryptoKey): Promise<Uint8Array>;
|
|
75
26
|
export declare function didToPublicKey(did: string): ({
|
|
76
27
|
publicKey: Uint8Array;
|
|
77
28
|
type: 'rsa' | 'ed25519' | 'bls12-381';
|
|
@@ -84,7 +35,6 @@ export declare function randomBuf(length: number, { max }?: {
|
|
|
84
35
|
}): ArrayBuffer;
|
|
85
36
|
export declare function joinBufs(fst: ArrayBuffer | Uint8Array, snd: ArrayBuffer | Uint8Array): ArrayBuffer;
|
|
86
37
|
export declare function makeEccKeypair(curve: 'X25519' | 'ECDSA', uses: 'encyrpt' | 'sign'): Promise<CryptoKeyPair>;
|
|
87
|
-
export declare function makeRSAKeypair(size: RsaSize, hashAlg: HashAlg, use: KeyUse): Promise<CryptoKeyPair>;
|
|
38
|
+
export declare function makeRSAKeypair(size: RsaSize, hashAlg: HashAlg, use: KeyUse, extractable?: boolean): Promise<CryptoKeyPair>;
|
|
88
39
|
export declare function getDeviceName(did: DID | string): Promise<string>;
|
|
89
|
-
export {};
|
|
90
40
|
//# sourceMappingURL=util.d.ts.map
|
package/dist/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,GAAG,EACH,GAAG,EACH,OAAO,EACP,WAAW,EACX,OAAO,EACP,OAAO,EACV,MAAM,YAAY,CAAA;AACnB,OAAO,EACH,MAAM,EACN,QAAQ,EACX,MAAM,YAAY,CAAA;AAcnB,eAAO,MAAM,aAAa,OACK,CAAA;AAC/B,eAAO,MAAM,eAAe,OACP,CAAA;AAGrB,wBAAgB,aAAa,CAAE,IAAI,EAAE,UAAU,GAAG,WAAW,CAE5D;AAED,MAAM,MAAM,UAAU,GAAG;IACrB,OAAO,EAAC,UAAU,CAAA;IAClB,SAAS,EAAC,UAAU,CAAA;IACpB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