Skip to content

Commit cf83bdd

Browse files
committed
same changes in the v16 and v18 folders
1 parent 6ff3f91 commit cf83bdd

4 files changed

Lines changed: 136 additions & 8 deletions

File tree

types/node/v16/crypto.d.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,7 @@ declare module "crypto" {
13181318
interface SignKeyObjectInput extends SigningOptions {
13191319
key: KeyObject;
13201320
}
1321+
interface SignJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
13211322
interface VerifyPublicKeyInput extends PublicKeyInput, SigningOptions {}
13221323
interface VerifyKeyObjectInput extends SigningOptions {
13231324
key: KeyObject;
@@ -1413,9 +1414,9 @@ declare module "crypto" {
14131414
* called. Multiple calls to `sign.sign()` will result in an error being thrown.
14141415
* @since v0.1.92
14151416
*/
1416-
sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput): Buffer;
1417+
sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput): Buffer;
14171418
sign(
1418-
privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
1419+
privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
14191420
outputFormat: BinaryToTextEncoding,
14201421
): string;
14211422
}
@@ -3297,12 +3298,12 @@ declare module "crypto" {
32973298
function sign(
32983299
algorithm: string | null | undefined,
32993300
data: NodeJS.ArrayBufferView,
3300-
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
3301+
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
33013302
): Buffer;
33023303
function sign(
33033304
algorithm: string | null | undefined,
33043305
data: NodeJS.ArrayBufferView,
3305-
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
3306+
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
33063307
callback: (error: Error | null, data: Buffer) => void,
33073308
): void;
33083309
/**

types/node/v16/test/crypto.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,28 @@ import { promisify } from "node:util";
11191119
key,
11201120
dsaEncoding: "der",
11211121
});
1122+
1123+
const jwk = key.export({ format: "jwk" });
1124+
crypto.sign("sha256", Buffer.from("asd"), {
1125+
format: "jwk",
1126+
key: jwk,
1127+
dsaEncoding: "der",
1128+
});
1129+
crypto.sign("sha256", Buffer.from("asd"), {
1130+
format: "jwk",
1131+
key: jwk,
1132+
dsaEncoding: "der",
1133+
}, callback);
1134+
promisify(crypto.sign)("sha256", Buffer.from("asd"), {
1135+
format: "jwk",
1136+
key: jwk,
1137+
dsaEncoding: "der",
1138+
}).then((signature: Buffer) => {});
1139+
crypto.createSign("sha256").update(Buffer.from("asd")).sign({
1140+
format: "jwk",
1141+
key: jwk,
1142+
dsaEncoding: "der",
1143+
});
11221144
}
11231145

11241146
{
@@ -1178,6 +1200,47 @@ import { promisify } from "node:util";
11781200
},
11791201
Buffer.from("sig"),
11801202
);
1203+
1204+
const jwk = key.export({ format: "jwk" });
1205+
crypto.verify(
1206+
"sha256",
1207+
Buffer.from("asd"),
1208+
{
1209+
format: "jwk",
1210+
key: jwk,
1211+
dsaEncoding: "der",
1212+
},
1213+
Buffer.from("sig"),
1214+
);
1215+
crypto.verify(
1216+
"sha256",
1217+
Buffer.from("asd"),
1218+
{
1219+
format: "jwk",
1220+
key: jwk,
1221+
dsaEncoding: "der",
1222+
},
1223+
Buffer.from("sig"),
1224+
callback,
1225+
);
1226+
promisify(crypto.verify)(
1227+
"sha256",
1228+
Buffer.from("asd"),
1229+
{
1230+
format: "jwk",
1231+
key: jwk,
1232+
dsaEncoding: "der",
1233+
},
1234+
Buffer.from("sig"),
1235+
).then((result: boolean) => {});
1236+
crypto.createVerify("sha256").update(Buffer.from("asd")).verify(
1237+
{
1238+
format: "jwk",
1239+
key: jwk,
1240+
dsaEncoding: "der",
1241+
},
1242+
Buffer.from("sig"),
1243+
);
11811244
}
11821245

11831246
{

types/node/v18/crypto.d.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,7 @@ declare module "crypto" {
13491349
interface SignKeyObjectInput extends SigningOptions {
13501350
key: KeyObject;
13511351
}
1352+
interface SignJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
13521353
interface VerifyPublicKeyInput extends PublicKeyInput, SigningOptions {}
13531354
interface VerifyKeyObjectInput extends SigningOptions {
13541355
key: KeyObject;
@@ -1444,9 +1445,9 @@ declare module "crypto" {
14441445
* called. Multiple calls to `sign.sign()` will result in an error being thrown.
14451446
* @since v0.1.92
14461447
*/
1447-
sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput): Buffer;
1448+
sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput): Buffer;
14481449
sign(
1449-
privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
1450+
privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
14501451
outputFormat: BinaryToTextEncoding,
14511452
): string;
14521453
}
@@ -3336,12 +3337,12 @@ declare module "crypto" {
33363337
function sign(
33373338
algorithm: string | null | undefined,
33383339
data: NodeJS.ArrayBufferView,
3339-
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
3340+
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
33403341
): Buffer;
33413342
function sign(
33423343
algorithm: string | null | undefined,
33433344
data: NodeJS.ArrayBufferView,
3344-
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
3345+
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
33453346
callback: (error: Error | null, data: Buffer) => void,
33463347
): void;
33473348
/**

types/node/v18/test/crypto.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,28 @@ import { promisify } from "node:util";
11171117
key,
11181118
dsaEncoding: "der",
11191119
});
1120+
1121+
const jwk = key.export({ format: "jwk" });
1122+
crypto.sign("sha256", Buffer.from("asd"), {
1123+
format: "jwk",
1124+
key: jwk,
1125+
dsaEncoding: "der",
1126+
});
1127+
crypto.sign("sha256", Buffer.from("asd"), {
1128+
format: "jwk",
1129+
key: jwk,
1130+
dsaEncoding: "der",
1131+
}, callback);
1132+
promisify(crypto.sign)("sha256", Buffer.from("asd"), {
1133+
format: "jwk",
1134+
key: jwk,
1135+
dsaEncoding: "der",
1136+
}).then((signature: Buffer) => {});
1137+
crypto.createSign("sha256").update(Buffer.from("asd")).sign({
1138+
format: "jwk",
1139+
key: jwk,
1140+
dsaEncoding: "der",
1141+
});
11201142
}
11211143

11221144
{
@@ -1176,6 +1198,47 @@ import { promisify } from "node:util";
11761198
},
11771199
Buffer.from("sig"),
11781200
);
1201+
1202+
const jwk = key.export({ format: "jwk" });
1203+
crypto.verify(
1204+
"sha256",
1205+
Buffer.from("asd"),
1206+
{
1207+
format: "jwk",
1208+
key: jwk,
1209+
dsaEncoding: "der",
1210+
},
1211+
Buffer.from("sig"),
1212+
);
1213+
crypto.verify(
1214+
"sha256",
1215+
Buffer.from("asd"),
1216+
{
1217+
format: "jwk",
1218+
key: jwk,
1219+
dsaEncoding: "der",
1220+
},
1221+
Buffer.from("sig"),
1222+
callback,
1223+
);
1224+
promisify(crypto.verify)(
1225+
"sha256",
1226+
Buffer.from("asd"),
1227+
{
1228+
format: "jwk",
1229+
key: jwk,
1230+
dsaEncoding: "der",
1231+
},
1232+
Buffer.from("sig"),
1233+
).then((result: boolean) => {});
1234+
crypto.createVerify("sha256").update(Buffer.from("asd")).verify(
1235+
{
1236+
format: "jwk",
1237+
key: jwk,
1238+
dsaEncoding: "der",
1239+
},
1240+
Buffer.from("sig"),
1241+
);
11791242
}
11801243

11811244
{

0 commit comments

Comments
 (0)