Update json-schema version

This commit is contained in:
microshine 2019-01-25 15:48:21 +03:00
parent 1a2838c08e
commit 6872ff74e0
10 changed files with 14 additions and 14 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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": {

View File

@ -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));

View File

@ -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";

View File

@ -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();

View File

@ -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": {

View File

@ -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";

View File

@ -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";

View File

@ -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));