@ocap/mcrypto 1.30.24 → 1.30.26
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/esm/crypter/aes-legacy.d.mts +11 -0
- package/esm/crypter/aes-legacy.mjs +67 -15
- package/esm/crypter/aes.d.mts +14 -2
- package/esm/crypter/aes.mjs +69 -3
- package/esm/encode.mjs +1 -1
- package/esm/hasher/keccak.mjs +7 -2
- package/esm/hasher/sha2.d.mts +1 -1
- package/esm/hasher/sha2.mjs +26 -11
- package/esm/hasher/sha3.d.mts +1 -1
- package/esm/hasher/sha3.mjs +21 -6
- package/esm/index.d.mts +1 -1
- package/esm/signer/ed25519.d.mts +1 -1
- package/esm/signer/ed25519.mjs +143 -16
- package/esm/signer/ethereum.mjs +7 -3
- package/esm/signer/secp256k1.mjs +3 -2
- package/esm/webauthn.d.mts +68 -2
- package/esm/webauthn.mjs +64 -16
- package/lib/_vendor/@noble/curves/LICENSE +21 -0
- package/lib/_vendor/@noble/curves/abstract/curve.cjs +373 -0
- package/lib/_vendor/@noble/curves/abstract/modular.cjs +616 -0
- package/lib/_vendor/@noble/curves/abstract/weierstrass.cjs +1020 -0
- package/lib/_vendor/@noble/curves/nist.cjs +91 -0
- package/lib/_vendor/@noble/curves/secp256k1.cjs +73 -0
- package/lib/_vendor/@noble/curves/utils.cjs +463 -0
- package/lib/_vendor/@noble/ed25519/LICENSE +21 -0
- package/lib/_vendor/@noble/ed25519/index.cjs +512 -0
- package/lib/_vendor/@noble/hashes/LICENSE +21 -0
- package/lib/_vendor/@noble/hashes/_md.cjs +230 -0
- package/lib/_vendor/@noble/hashes/_u64.cjs +67 -0
- package/lib/_vendor/@noble/hashes/hmac.cjs +86 -0
- package/lib/_vendor/@noble/hashes/sha2.cjs +477 -0
- package/lib/_vendor/@noble/hashes/sha3.cjs +329 -0
- package/lib/_vendor/@noble/hashes/utils.cjs +410 -0
- package/lib/crypter/aes-legacy.cjs +68 -21
- package/lib/crypter/aes-legacy.d.cts +11 -0
- package/lib/crypter/aes.cjs +69 -2
- package/lib/crypter/aes.d.cts +14 -2
- package/lib/encode.cjs +1 -1
- package/lib/hasher/keccak.cjs +13 -8
- package/lib/hasher/sha2.cjs +32 -17
- package/lib/hasher/sha2.d.cts +1 -1
- package/lib/hasher/sha3.cjs +27 -12
- package/lib/hasher/sha3.d.cts +1 -1
- package/lib/index.d.cts +1 -1
- package/lib/signer/ed25519.cjs +146 -20
- package/lib/signer/ed25519.d.cts +1 -1
- package/lib/signer/ethereum.cjs +16 -12
- package/lib/signer/secp256k1.cjs +11 -10
- package/lib/webauthn.cjs +80 -31
- package/lib/webauthn.d.cts +68 -2
- package/package.json +6 -7
package/lib/webauthn.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const require_sha2 = require('./_vendor/@noble/hashes/sha2.cjs');
|
|
3
|
+
const require_secp256k1 = require('./_vendor/@noble/curves/secp256k1.cjs');
|
|
4
|
+
const require_nist = require('./_vendor/@noble/curves/nist.cjs');
|
|
5
5
|
|
|
6
6
|
//#region src/webauthn.ts
|
|
7
7
|
/**
|
|
@@ -26,6 +26,7 @@ var webauthn_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
|
26
26
|
isoCBOR: () => isoCBOR,
|
|
27
27
|
isoUint8Array: () => isoUint8Array,
|
|
28
28
|
parseAuthenticatorData: () => parseAuthenticatorData,
|
|
29
|
+
parseCoseEc2PublicKey: () => parseCoseEc2PublicKey,
|
|
29
30
|
toHash: () => toHash,
|
|
30
31
|
verifyRegistrationResponse: () => verifyRegistrationResponse,
|
|
31
32
|
verifySignature: () => verifySignature
|
|
@@ -121,39 +122,52 @@ const isoUint8Array = {
|
|
|
121
122
|
return bytes;
|
|
122
123
|
}
|
|
123
124
|
};
|
|
124
|
-
function decodeCBORInternal(data, offset) {
|
|
125
|
+
function decodeCBORInternal(data, offset, depth = 0, state = { items: 0 }) {
|
|
126
|
+
if (depth > 16) throw new Error("CBOR: maximum nesting depth exceeded");
|
|
127
|
+
if (++state.items > 1024) throw new Error("CBOR: maximum item count exceeded");
|
|
128
|
+
if (offset >= data.length) throw new Error("CBOR: unexpected end of buffer");
|
|
125
129
|
const major = data[offset] >> 5;
|
|
126
130
|
const additional = data[offset] & 31;
|
|
127
131
|
offset++;
|
|
128
132
|
let length;
|
|
129
133
|
if (additional < 24) length = additional;
|
|
130
|
-
else if (additional === 24)
|
|
131
|
-
|
|
134
|
+
else if (additional === 24) {
|
|
135
|
+
if (offset + 1 > data.length) throw new Error("CBOR: unexpected end of buffer");
|
|
136
|
+
length = data[offset++];
|
|
137
|
+
} else if (additional === 25) {
|
|
138
|
+
if (offset + 2 > data.length) throw new Error("CBOR: unexpected end of buffer");
|
|
132
139
|
length = data[offset] << 8 | data[offset + 1];
|
|
133
140
|
offset += 2;
|
|
134
141
|
} else if (additional === 26) {
|
|
135
|
-
|
|
142
|
+
if (offset + 4 > data.length) throw new Error("CBOR: unexpected end of buffer");
|
|
143
|
+
length = (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
|
|
136
144
|
offset += 4;
|
|
137
145
|
} else throw new Error(`CBOR: unsupported additional info ${additional}`);
|
|
138
146
|
switch (major) {
|
|
139
147
|
case 0: return [length, offset];
|
|
140
148
|
case 1: return [-1 - length, offset];
|
|
141
|
-
case 2:
|
|
142
|
-
|
|
149
|
+
case 2:
|
|
150
|
+
if (offset + length > data.length) throw new Error("CBOR: unexpected end of buffer");
|
|
151
|
+
return [data.slice(offset, offset + length), offset + length];
|
|
152
|
+
case 3:
|
|
153
|
+
if (offset + length > data.length) throw new Error("CBOR: unexpected end of buffer");
|
|
154
|
+
return [new TextDecoder().decode(data.slice(offset, offset + length)), offset + length];
|
|
143
155
|
case 4: {
|
|
156
|
+
if (length > data.length - offset) throw new Error("CBOR: array length exceeds remaining buffer");
|
|
144
157
|
const arr = [];
|
|
145
158
|
for (let i = 0; i < length; i++) {
|
|
146
|
-
const [value, newOffset] = decodeCBORInternal(data, offset);
|
|
159
|
+
const [value, newOffset] = decodeCBORInternal(data, offset, depth + 1, state);
|
|
147
160
|
arr.push(value);
|
|
148
161
|
offset = newOffset;
|
|
149
162
|
}
|
|
150
163
|
return [arr, offset];
|
|
151
164
|
}
|
|
152
165
|
case 5: {
|
|
166
|
+
if (length > data.length - offset) throw new Error("CBOR: map length exceeds remaining buffer");
|
|
153
167
|
const map = /* @__PURE__ */ new Map();
|
|
154
168
|
for (let i = 0; i < length; i++) {
|
|
155
|
-
const [key, keyOffset] = decodeCBORInternal(data, offset);
|
|
156
|
-
const [value, valueOffset] = decodeCBORInternal(data, keyOffset);
|
|
169
|
+
const [key, keyOffset] = decodeCBORInternal(data, offset, depth + 1, state);
|
|
170
|
+
const [value, valueOffset] = decodeCBORInternal(data, keyOffset, depth + 1, state);
|
|
157
171
|
map.set(key, value);
|
|
158
172
|
offset = valueOffset;
|
|
159
173
|
}
|
|
@@ -219,19 +233,19 @@ async function toHash(data, algorithm = COSEALG.ES256) {
|
|
|
219
233
|
COSEALG.PS256,
|
|
220
234
|
COSEALG.RS256,
|
|
221
235
|
COSEALG.ES256K
|
|
222
|
-
].includes(algorithm)) return
|
|
236
|
+
].includes(algorithm)) return require_sha2.sha256(input);
|
|
223
237
|
if ([
|
|
224
238
|
COSEALG.ES384,
|
|
225
239
|
COSEALG.PS384,
|
|
226
240
|
COSEALG.RS384
|
|
227
|
-
].includes(algorithm)) return
|
|
241
|
+
].includes(algorithm)) return require_sha2.sha384(input);
|
|
228
242
|
if ([
|
|
229
243
|
COSEALG.ES512,
|
|
230
244
|
COSEALG.PS512,
|
|
231
245
|
COSEALG.RS512,
|
|
232
246
|
COSEALG.EdDSA
|
|
233
|
-
].includes(algorithm)) return
|
|
234
|
-
return
|
|
247
|
+
].includes(algorithm)) return require_sha2.sha512(input);
|
|
248
|
+
return require_sha2.sha256(input);
|
|
235
249
|
}
|
|
236
250
|
function decodeClientDataJSON(data) {
|
|
237
251
|
return JSON.parse(isoBase64URL.toUTF8String(data));
|
|
@@ -259,9 +273,11 @@ function parseAuthenticatorData(authData) {
|
|
|
259
273
|
let credentialID;
|
|
260
274
|
let credentialPublicKey;
|
|
261
275
|
if (flags.at) {
|
|
276
|
+
if (pointer + 18 > authData.byteLength) throw new Error("Authenticator data too short for attested credential data");
|
|
262
277
|
aaguid = authData.slice(pointer, pointer += 16);
|
|
263
278
|
const credIDLen = dataView.getUint16(pointer);
|
|
264
279
|
pointer += 2;
|
|
280
|
+
if (pointer + credIDLen > authData.byteLength) throw new Error("Authenticator data too short for credential ID");
|
|
265
281
|
credentialID = authData.slice(pointer, pointer += credIDLen);
|
|
266
282
|
const firstDecoded = isoCBOR.decodeFirst(authData.slice(pointer));
|
|
267
283
|
const firstEncoded = isoCBOR.encode(firstDecoded);
|
|
@@ -292,31 +308,43 @@ function parseAuthenticatorData(authData) {
|
|
|
292
308
|
function getCurveForCrv(crv) {
|
|
293
309
|
switch (crv) {
|
|
294
310
|
case COSECRV.P256: return {
|
|
295
|
-
curve:
|
|
296
|
-
hash:
|
|
311
|
+
curve: require_nist.p256,
|
|
312
|
+
hash: require_sha2.sha256,
|
|
297
313
|
componentLen: 32
|
|
298
314
|
};
|
|
299
315
|
case COSECRV.P384: return {
|
|
300
|
-
curve:
|
|
301
|
-
hash:
|
|
316
|
+
curve: require_nist.p384,
|
|
317
|
+
hash: require_sha2.sha384,
|
|
302
318
|
componentLen: 48
|
|
303
319
|
};
|
|
304
320
|
case COSECRV.P521: return {
|
|
305
|
-
curve:
|
|
306
|
-
hash:
|
|
321
|
+
curve: require_nist.p521,
|
|
322
|
+
hash: require_sha2.sha512,
|
|
307
323
|
componentLen: 66
|
|
308
324
|
};
|
|
309
325
|
case COSECRV.SECP256K1: return {
|
|
310
|
-
curve:
|
|
311
|
-
hash:
|
|
326
|
+
curve: require_secp256k1.secp256k1,
|
|
327
|
+
hash: require_sha2.sha256,
|
|
312
328
|
componentLen: 32
|
|
313
329
|
};
|
|
314
330
|
default: throw new Error(`Unsupported COSE curve: ${crv}`);
|
|
315
331
|
}
|
|
316
332
|
}
|
|
317
|
-
|
|
318
|
-
|
|
333
|
+
/**
|
|
334
|
+
* Parse an EC2 COSE public key into a validated uncompressed SEC1 point.
|
|
335
|
+
* Throws on any malformed input: non-map key, wrong kty, unsupported curve,
|
|
336
|
+
* non-bytes / empty / oversized coordinates, or a point that is not on the curve.
|
|
337
|
+
*
|
|
338
|
+
* `strict` additionally requires the exact canonical byte form: coordinates of exactly the
|
|
339
|
+
* curve component length, no trailing bytes, no duplicate map keys, minimal CBOR heads.
|
|
340
|
+
* Registration uses strict. The transaction verify path stays lenient on purpose: it verifies
|
|
341
|
+
* against raw on-chain `pk` bytes that clients supplied, and tightening it could invalidate
|
|
342
|
+
* already-declared accounts when replaying history.
|
|
343
|
+
*/
|
|
344
|
+
function parseCoseEc2PublicKey(credentialPublicKey, opts = {}) {
|
|
319
345
|
const coseKey = isoCBOR.decodeFirst(credentialPublicKey);
|
|
346
|
+
if (!(coseKey instanceof Map)) throw new Error("Invalid COSE public key");
|
|
347
|
+
if (opts.strict && !isoUint8Array.areEqual(isoCBOR.encode(coseKey), credentialPublicKey)) throw new Error("COSE public key is not in canonical form");
|
|
320
348
|
const kty = coseKey.get(COSEKEYS.kty);
|
|
321
349
|
if (kty !== COSEKTY.EC2) throw new Error(`Unsupported COSE key type: ${kty} (only EC2 is supported)`);
|
|
322
350
|
const crv = coseKey.get(COSEKEYS.crv);
|
|
@@ -324,13 +352,31 @@ async function verifySignature(opts) {
|
|
|
324
352
|
const y = coseKey.get(COSEKEYS.y);
|
|
325
353
|
if (!x || !y) throw new Error("COSE public key missing x or y coordinate");
|
|
326
354
|
const { curve, hash, componentLen } = getCurveForCrv(crv);
|
|
355
|
+
if (!(x instanceof Uint8Array) || !(y instanceof Uint8Array) || x.length === 0 || y.length === 0 || x.length > componentLen || y.length > componentLen || opts.strict && (x.length !== componentLen || y.length !== componentLen)) throw new Error("Invalid COSE EC2 coordinate length");
|
|
327
356
|
const pubKeyBytes = new Uint8Array(1 + componentLen * 2);
|
|
328
357
|
pubKeyBytes[0] = 4;
|
|
329
|
-
pubKeyBytes.set(x
|
|
330
|
-
pubKeyBytes.set(y
|
|
331
|
-
|
|
358
|
+
pubKeyBytes.set(x, 1 + (componentLen - x.length));
|
|
359
|
+
pubKeyBytes.set(y, 1 + componentLen + (componentLen - y.length));
|
|
360
|
+
try {
|
|
361
|
+
curve.Point.fromBytes(pubKeyBytes).assertValidity();
|
|
362
|
+
} catch {
|
|
363
|
+
throw new Error("COSE EC2 public key is not a valid point on the curve");
|
|
364
|
+
}
|
|
365
|
+
return {
|
|
366
|
+
curve,
|
|
367
|
+
hash,
|
|
368
|
+
pubKeyBytes
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Verify a DER ECDSA signature against a COSE public key. Never throws: any
|
|
373
|
+
* malformed key / signature input yields `false`.
|
|
374
|
+
*/
|
|
375
|
+
async function verifySignature(opts) {
|
|
332
376
|
try {
|
|
333
|
-
|
|
377
|
+
const { signature, data, credentialPublicKey } = opts;
|
|
378
|
+
const { curve, hash, pubKeyBytes } = parseCoseEc2PublicKey(credentialPublicKey);
|
|
379
|
+
return curve.verify(signature, hash(data), pubKeyBytes, {
|
|
334
380
|
prehash: false,
|
|
335
381
|
format: "der",
|
|
336
382
|
lowS: false
|
|
@@ -348,7 +394,7 @@ function convertAAGUIDToString(aaguid) {
|
|
|
348
394
|
}
|
|
349
395
|
async function matchExpectedRPID(rpIdHash, expectedRPIDs) {
|
|
350
396
|
for (const rpID of expectedRPIDs) {
|
|
351
|
-
const expectedHash =
|
|
397
|
+
const expectedHash = require_sha2.sha256(new TextEncoder().encode(rpID));
|
|
352
398
|
if (isoUint8Array.areEqual(rpIdHash, expectedHash)) return rpID;
|
|
353
399
|
}
|
|
354
400
|
throw new Error(`Unexpected RP ID hash, expected one of: ${expectedRPIDs.join(", ")}`);
|
|
@@ -466,11 +512,13 @@ async function verifyRegistrationResponse(options) {
|
|
|
466
512
|
if (requireUserPresence && !flags.up) throw new Error("User presence was required, but user was not present");
|
|
467
513
|
if (requireUserVerification && !flags.uv) throw new Error("User verification was required, but user could not be verified");
|
|
468
514
|
if (!credentialID) throw new Error("No credential ID was provided by authenticator");
|
|
515
|
+
if (id !== isoBase64URL.fromBuffer(credentialID)) throw new Error("Credential ID does not match the credential ID in authenticator data");
|
|
469
516
|
if (!credentialPublicKey) throw new Error("No public key was provided by authenticator");
|
|
470
517
|
if (!aaguid) throw new Error("No AAGUID was present during registration");
|
|
471
518
|
const alg = isoCBOR.decodeFirst(credentialPublicKey).get(COSEKEYS.alg);
|
|
472
519
|
if (typeof alg !== "number") throw new Error("Credential public key was missing numeric alg");
|
|
473
520
|
if (!supportedAlgorithmIDs.includes(alg)) throw new Error(`Unexpected public key alg "${alg}", expected one of "${supportedAlgorithmIDs.join(", ")}"`);
|
|
521
|
+
parseCoseEc2PublicKey(credentialPublicKey, { strict: true });
|
|
474
522
|
let verified = false;
|
|
475
523
|
if (fmt === "none") {
|
|
476
524
|
if (attStmt.size > 0) throw new Error("None attestation had unexpected attestation statement");
|
|
@@ -523,6 +571,7 @@ exports.isoBase64URL = isoBase64URL;
|
|
|
523
571
|
exports.isoCBOR = isoCBOR;
|
|
524
572
|
exports.isoUint8Array = isoUint8Array;
|
|
525
573
|
exports.parseAuthenticatorData = parseAuthenticatorData;
|
|
574
|
+
exports.parseCoseEc2PublicKey = parseCoseEc2PublicKey;
|
|
526
575
|
exports.toHash = toHash;
|
|
527
576
|
exports.verifyRegistrationResponse = verifyRegistrationResponse;
|
|
528
577
|
exports.verifySignature = verifySignature;
|
package/lib/webauthn.d.cts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import * as _noble_curves_abstract_weierstrass_js0 from "@noble/curves/abstract/weierstrass.js";
|
|
2
|
+
import * as _noble_hashes_utils_js0 from "@noble/hashes/utils.js";
|
|
3
|
+
import * as _noble_hashes_sha2_js0 from "@noble/hashes/sha2.js";
|
|
4
|
+
|
|
5
|
+
//#region src/webauthn.d.ts
|
|
1
6
|
declare namespace webauthn_d_exports {
|
|
2
|
-
export { COSEALG, COSECRV, COSEKEYS, COSEKTY, GenerateAuthenticationOptionsOpts, GenerateRegistrationOptionsOpts, ParsedAuthenticatorData, RegistrationResponseJSON, VerifiedRegistrationResponse, cose, decodeClientDataJSON, generateAuthenticationOptions, generateChallenge, generateRegistrationOptions, isoBase64URL, isoCBOR, isoUint8Array, parseAuthenticatorData, toHash, verifyRegistrationResponse, verifySignature };
|
|
7
|
+
export { COSEALG, COSECRV, COSEKEYS, COSEKTY, GenerateAuthenticationOptionsOpts, GenerateRegistrationOptionsOpts, ParsedAuthenticatorData, RegistrationResponseJSON, VerifiedRegistrationResponse, cose, decodeClientDataJSON, generateAuthenticationOptions, generateChallenge, generateRegistrationOptions, isoBase64URL, isoCBOR, isoUint8Array, parseAuthenticatorData, parseCoseEc2PublicKey, toHash, verifyRegistrationResponse, verifySignature };
|
|
3
8
|
}
|
|
4
9
|
declare const COSEKEYS: {
|
|
5
10
|
readonly kty: 1;
|
|
@@ -117,6 +122,67 @@ interface ParsedAuthenticatorData {
|
|
|
117
122
|
extensionsDataBuffer?: Uint8Array;
|
|
118
123
|
}
|
|
119
124
|
declare function parseAuthenticatorData(authData: Uint8Array): ParsedAuthenticatorData;
|
|
125
|
+
/**
|
|
126
|
+
* Parse an EC2 COSE public key into a validated uncompressed SEC1 point.
|
|
127
|
+
* Throws on any malformed input: non-map key, wrong kty, unsupported curve,
|
|
128
|
+
* non-bytes / empty / oversized coordinates, or a point that is not on the curve.
|
|
129
|
+
*
|
|
130
|
+
* `strict` additionally requires the exact canonical byte form: coordinates of exactly the
|
|
131
|
+
* curve component length, no trailing bytes, no duplicate map keys, minimal CBOR heads.
|
|
132
|
+
* Registration uses strict. The transaction verify path stays lenient on purpose: it verifies
|
|
133
|
+
* against raw on-chain `pk` bytes that clients supplied, and tightening it could invalidate
|
|
134
|
+
* already-declared accounts when replaying history.
|
|
135
|
+
*/
|
|
136
|
+
declare function parseCoseEc2PublicKey(credentialPublicKey: Uint8Array, opts?: {
|
|
137
|
+
strict?: boolean;
|
|
138
|
+
}): {
|
|
139
|
+
curve: _noble_curves_abstract_weierstrass_js0.ECDSA;
|
|
140
|
+
hash: ({
|
|
141
|
+
outputLen: number;
|
|
142
|
+
blockLen: number;
|
|
143
|
+
canXOF: boolean;
|
|
144
|
+
} & _noble_hashes_utils_js0.HashInfo & {
|
|
145
|
+
(msg: _noble_hashes_utils_js0.TArg<Uint8Array>): _noble_hashes_utils_js0.TRet<Uint8Array>;
|
|
146
|
+
create(): _noble_hashes_sha2_js0._SHA256;
|
|
147
|
+
} & ((msg: _noble_hashes_utils_js0.TArg<_noble_hashes_utils_js0.TArg<Uint8Array<ArrayBufferLike>>>) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>) & {
|
|
148
|
+
outputLen: number;
|
|
149
|
+
blockLen: number;
|
|
150
|
+
canXOF: boolean;
|
|
151
|
+
oid?: _noble_hashes_utils_js0.TRet<Uint8Array> | undefined;
|
|
152
|
+
create: () => _noble_hashes_sha2_js0._SHA256;
|
|
153
|
+
}) | ({
|
|
154
|
+
outputLen: number;
|
|
155
|
+
blockLen: number;
|
|
156
|
+
canXOF: boolean;
|
|
157
|
+
} & _noble_hashes_utils_js0.HashInfo & {
|
|
158
|
+
(msg: _noble_hashes_utils_js0.TArg<Uint8Array>): _noble_hashes_utils_js0.TRet<Uint8Array>;
|
|
159
|
+
create(): _noble_hashes_sha2_js0._SHA384;
|
|
160
|
+
} & ((msg: _noble_hashes_utils_js0.TArg<_noble_hashes_utils_js0.TArg<Uint8Array<ArrayBufferLike>>>) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>) & {
|
|
161
|
+
outputLen: number;
|
|
162
|
+
blockLen: number;
|
|
163
|
+
canXOF: boolean;
|
|
164
|
+
oid?: _noble_hashes_utils_js0.TRet<Uint8Array> | undefined;
|
|
165
|
+
create: () => _noble_hashes_sha2_js0._SHA384;
|
|
166
|
+
}) | ({
|
|
167
|
+
outputLen: number;
|
|
168
|
+
blockLen: number;
|
|
169
|
+
canXOF: boolean;
|
|
170
|
+
} & _noble_hashes_utils_js0.HashInfo & {
|
|
171
|
+
(msg: _noble_hashes_utils_js0.TArg<Uint8Array>): _noble_hashes_utils_js0.TRet<Uint8Array>;
|
|
172
|
+
create(): _noble_hashes_sha2_js0._SHA512;
|
|
173
|
+
} & ((msg: _noble_hashes_utils_js0.TArg<_noble_hashes_utils_js0.TArg<Uint8Array<ArrayBufferLike>>>) => Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>) & {
|
|
174
|
+
outputLen: number;
|
|
175
|
+
blockLen: number;
|
|
176
|
+
canXOF: boolean;
|
|
177
|
+
oid?: _noble_hashes_utils_js0.TRet<Uint8Array> | undefined;
|
|
178
|
+
create: () => _noble_hashes_sha2_js0._SHA512;
|
|
179
|
+
});
|
|
180
|
+
pubKeyBytes: Uint8Array<ArrayBuffer>;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Verify a DER ECDSA signature against a COSE public key. Never throws: any
|
|
184
|
+
* malformed key / signature input yields `false`.
|
|
185
|
+
*/
|
|
120
186
|
declare function verifySignature(opts: {
|
|
121
187
|
signature: Uint8Array;
|
|
122
188
|
data: Uint8Array;
|
|
@@ -207,4 +273,4 @@ declare function verifyRegistrationResponse(options: {
|
|
|
207
273
|
supportedAlgorithmIDs?: number[];
|
|
208
274
|
}): Promise<VerifiedRegistrationResponse>;
|
|
209
275
|
//#endregion
|
|
210
|
-
export { COSEALG, COSECRV, COSEKEYS, COSEKTY, GenerateAuthenticationOptionsOpts, GenerateRegistrationOptionsOpts, ParsedAuthenticatorData, RegistrationResponseJSON, VerifiedRegistrationResponse, cose, decodeClientDataJSON, generateAuthenticationOptions, generateChallenge, generateRegistrationOptions, isoBase64URL, isoCBOR, isoUint8Array, parseAuthenticatorData, toHash, verifyRegistrationResponse, verifySignature, webauthn_d_exports };
|
|
276
|
+
export { COSEALG, COSECRV, COSEKEYS, COSEKTY, GenerateAuthenticationOptionsOpts, GenerateRegistrationOptionsOpts, ParsedAuthenticatorData, RegistrationResponseJSON, VerifiedRegistrationResponse, cose, decodeClientDataJSON, generateAuthenticationOptions, generateChallenge, generateRegistrationOptions, isoBase64URL, isoCBOR, isoUint8Array, parseAuthenticatorData, parseCoseEc2PublicKey, toHash, verifyRegistrationResponse, verifySignature, webauthn_d_exports };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocap/mcrypto",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.26",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Crypto lib that provides signer,crypter,hasher interface",
|
|
6
6
|
"keywords": [
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"import": "./esm/index.mjs",
|
|
33
33
|
"default": "./lib/index.cjs"
|
|
34
34
|
},
|
|
35
|
+
"./lib/_vendor/*": null,
|
|
35
36
|
"./lib/*.js": {
|
|
36
37
|
"types": "./esm/*.d.mts",
|
|
37
38
|
"import": "./esm/*.mjs",
|
|
@@ -48,7 +49,6 @@
|
|
|
48
49
|
"esm"
|
|
49
50
|
],
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"@types/crypto-js": "^4.2.2",
|
|
52
52
|
"@types/node": "^22.7.5",
|
|
53
53
|
"@types/randombytes": "^2.0.3",
|
|
54
54
|
"tsdown": "^0.18.4",
|
|
@@ -72,11 +72,10 @@
|
|
|
72
72
|
"url": "https://github.com/ArcBlock/blockchain/issues"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@noble/curves": "
|
|
76
|
-
"@noble/ed25519": "
|
|
77
|
-
"@noble/hashes": "
|
|
78
|
-
"@ocap/util": "1.30.
|
|
79
|
-
"crypto-js": "^4.2.0",
|
|
75
|
+
"@noble/curves": "2.2.0",
|
|
76
|
+
"@noble/ed25519": "3.0.1",
|
|
77
|
+
"@noble/hashes": "2.2.0",
|
|
78
|
+
"@ocap/util": "1.30.26",
|
|
80
79
|
"interface": "^1.2.1",
|
|
81
80
|
"randombytes": "^2.1.0"
|
|
82
81
|
},
|