From 6872ff74e0d6a29e5e5e3497dcd9de289838765e Mon Sep 17 00:00:00 2001 From: microshine Date: Fri, 25 Jan 2019 15:48:21 +0300 Subject: [PATCH] Update json-schema version --- src/mechs/aes/crypto.ts | 2 +- src/mechs/des/crypto.ts | 2 +- src/mechs/ec/crypto.ts | 4 ++-- src/mechs/ec/private_key.ts | 2 +- src/mechs/ec/public_key.ts | 2 +- src/mechs/hmac/hmac.ts | 2 +- src/mechs/rsa/crypto.ts | 4 ++-- src/mechs/rsa/private_key.ts | 2 +- src/mechs/rsa/public_key.ts | 2 +- test/asn.ts | 6 +++--- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/mechs/aes/crypto.ts b/src/mechs/aes/crypto.ts index 2575ecc..6d6efa1 100644 --- a/src/mechs/aes/crypto.ts +++ b/src/mechs/aes/crypto.ts @@ -38,7 +38,7 @@ export class AesCrypto { switch (format.toLowerCase()) { case "jwk": - key = JsonParser.fromJSON(keyData, AesCryptoKey); + key = JsonParser.fromJSON(keyData, { targetSchema: AesCryptoKey }); break; case "raw": key = new AesCryptoKey(); diff --git a/src/mechs/des/crypto.ts b/src/mechs/des/crypto.ts index 40f5681..ce049c6 100644 --- a/src/mechs/des/crypto.ts +++ b/src/mechs/des/crypto.ts @@ -33,7 +33,7 @@ export class DesCrypto { switch (format.toLowerCase()) { case "jwk": - key = JsonParser.fromJSON(keyData, DesCryptoKey); + key = JsonParser.fromJSON(keyData, { targetSchema: DesCryptoKey }); break; case "raw": key = new DesCryptoKey(); diff --git a/src/mechs/ec/crypto.ts b/src/mechs/ec/crypto.ts index 0cf11ea..f5ccdb8 100644 --- a/src/mechs/ec/crypto.ts +++ b/src/mechs/ec/crypto.ts @@ -120,10 +120,10 @@ export class EcCrypto { case "jwk": const jwk = keyData as JsonWebKey; if (jwk.d) { - const asnKey = JsonParser.fromJSON(keyData, asn.EcPrivateKey); + const asnKey = JsonParser.fromJSON(keyData, { targetSchema: asn.EcPrivateKey }); return this.importPrivateKey(asnKey, algorithm, extractable, keyUsages); } else { - const asnKey = JsonParser.fromJSON(keyData, asn.EcPublicKey); + const asnKey = JsonParser.fromJSON(keyData, { targetSchema: asn.EcPublicKey }); return this.importPublicKey(asnKey, algorithm, extractable, keyUsages); } case "raw": { diff --git a/src/mechs/ec/private_key.ts b/src/mechs/ec/private_key.ts index 274c3fb..49eb197 100644 --- a/src/mechs/ec/private_key.ts +++ b/src/mechs/ec/private_key.ts @@ -38,7 +38,7 @@ export class EcPrivateKey extends AsymmetricKey implements IJsonConvertible { keyInfo.privateKeyAlgorithm.parameters = AsnSerializer.serialize( new ObjectIdentifier(getOidByNamedCurve(json.crv!)), ); - const key = JsonParser.fromJSON(json, asn.EcPrivateKey); + const key = JsonParser.fromJSON(json, { targetSchema: asn.EcPrivateKey }); keyInfo.privateKey = AsnSerializer.serialize(key); this.data = Buffer.from(AsnSerializer.serialize(keyInfo)); diff --git a/src/mechs/ec/public_key.ts b/src/mechs/ec/public_key.ts index 4c1ac12..88c85d6 100644 --- a/src/mechs/ec/public_key.ts +++ b/src/mechs/ec/public_key.ts @@ -29,7 +29,7 @@ export class EcPublicKey extends AsymmetricKey implements IJsonConvertible { } public fromJSON(json: JsonWebKey) { - const key = JsonParser.fromJSON(json, asn.EcPublicKey); + const key = JsonParser.fromJSON(json, { targetSchema: asn.EcPublicKey }); const keyInfo = new asn.PublicKeyInfo(); keyInfo.publicKeyAlgorithm.algorithm = "1.2.840.10045.2.1"; diff --git a/src/mechs/hmac/hmac.ts b/src/mechs/hmac/hmac.ts index 8aae409..6c11e4b 100644 --- a/src/mechs/hmac/hmac.ts +++ b/src/mechs/hmac/hmac.ts @@ -40,7 +40,7 @@ export class HmacProvider extends core.HmacProvider { switch (format.toLowerCase()) { case "jwk": - key = JsonParser.fromJSON(keyData, HmacCryptoKey); + key = JsonParser.fromJSON(keyData, { targetSchema: HmacCryptoKey }); break; case "raw": key = new HmacCryptoKey(); diff --git a/src/mechs/rsa/crypto.ts b/src/mechs/rsa/crypto.ts index e9eadcc..0c3e0b5 100644 --- a/src/mechs/rsa/crypto.ts +++ b/src/mechs/rsa/crypto.ts @@ -77,10 +77,10 @@ export class RsaCrypto { case "jwk": const jwk = keyData as JsonWebKey; if (jwk.d) { - const asnKey = JsonParser.fromJSON(keyData, asn.RsaPrivateKey); + const asnKey = JsonParser.fromJSON(keyData, { targetSchema: asn.RsaPrivateKey }); return this.importPrivateKey(asnKey, algorithm, extractable, keyUsages); } else { - const asnKey = JsonParser.fromJSON(keyData, asn.RsaPublicKey); + const asnKey = JsonParser.fromJSON(keyData, { targetSchema: asn.RsaPublicKey }); return this.importPublicKey(asnKey, algorithm, extractable, keyUsages); } case "spki": { diff --git a/src/mechs/rsa/private_key.ts b/src/mechs/rsa/private_key.ts index 09a2415..494cb53 100644 --- a/src/mechs/rsa/private_key.ts +++ b/src/mechs/rsa/private_key.ts @@ -27,7 +27,7 @@ export class RsaPrivateKey extends AsymmetricKey { } public fromJSON(json: JsonWebKey) { - const key = JsonParser.fromJSON(json, asn.RsaPrivateKey); + const key = JsonParser.fromJSON(json, { targetSchema: asn.RsaPrivateKey }); const keyInfo = new asn.PrivateKeyInfo(); keyInfo.privateKeyAlgorithm.algorithm = "1.2.840.113549.1.1.1"; diff --git a/src/mechs/rsa/public_key.ts b/src/mechs/rsa/public_key.ts index d5f43d5..41984d1 100644 --- a/src/mechs/rsa/public_key.ts +++ b/src/mechs/rsa/public_key.ts @@ -27,7 +27,7 @@ export class RsaPublicKey extends AsymmetricKey { } public fromJSON(json: JsonWebKey) { - const key = JsonParser.fromJSON(json, asn.RsaPublicKey); + const key = JsonParser.fromJSON(json, { targetSchema: asn.RsaPublicKey }); const keyInfo = new asn.PublicKeyInfo(); keyInfo.publicKeyAlgorithm.algorithm = "1.2.840.113549.1.1.1"; diff --git a/test/asn.ts b/test/asn.ts index 5efcefe..d9c9c71 100644 --- a/test/asn.ts +++ b/test/asn.ts @@ -30,7 +30,7 @@ context("ASN", () => { }); it("serialize", () => { - const key = JsonParser.fromJSON(json, asn.RsaPrivateKey); + const key = JsonParser.fromJSON(json, { targetSchema: asn.RsaPrivateKey }); const keyInfo = new asn.PrivateKeyInfo(); keyInfo.privateKeyAlgorithm.algorithm = "1.2.840.113549.1.1.1"; @@ -60,7 +60,7 @@ context("ASN", () => { }); it("serialize", () => { - const key = JsonParser.fromJSON(json, asn.RsaPublicKey); + const key = JsonParser.fromJSON(json, { targetSchema: asn.RsaPublicKey }); const keyInfo = new asn.PublicKeyInfo(); keyInfo.publicKeyAlgorithm.algorithm = "1.2.840.113549.1.1.1"; @@ -100,7 +100,7 @@ context("ASN", () => { keyInfo.privateKeyAlgorithm.parameters = AsnSerializer.serialize( new asn.ObjectIdentifier("1.2.840.10045.3.1.7"), ); - const key = JsonParser.fromJSON(json, asn.EcPrivateKey); + const key = JsonParser.fromJSON(json, { targetSchema: asn.EcPrivateKey }); keyInfo.privateKey = AsnSerializer.serialize(key); const asnKeyInfo = Buffer.from(AsnSerializer.serialize(keyInfo));