Skip to content

Commit 1dfd70a

Browse files
authored
Update node types (#7548)
1 parent 61aff74 commit 1dfd70a

File tree

2 files changed

+60
-19
lines changed

2 files changed

+60
-19
lines changed

js/ccf-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"devDependencies": {
2121
"@types/chai": "^5.0.0",
2222
"@types/mocha": "^10.0.0",
23-
"@types/node": "^24.2.0",
23+
"@types/node": "^25.0.2",
2424
"@types/node-forge": "^1.0.0",
2525
"chai": "^6.0.1",
2626
"cross-env": "^10.0.0",

js/ccf-app/src/polyfill.ts

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
SnpAttestation,
3333
SnpAttestationResult,
3434
SigningAlgorithm,
35+
JsonWebKey,
3536
JsonWebKeyECPublic,
3637
JsonWebKeyECPrivate,
3738
JsonWebKeyRSAPublic,
@@ -469,8 +470,14 @@ class CCFPolyfill implements CCF {
469470
const jwk = key.export({
470471
format: "jwk",
471472
});
472-
jwk.kid = kid;
473-
return jwk as JsonWebKeyECPrivate;
473+
const jwkWithKid = {
474+
kty: jwk.kty,
475+
crv: jwk.crv,
476+
x: jwk.x,
477+
y: jwk.y,
478+
kid: kid,
479+
};
480+
return jwkWithKid as JsonWebKeyECPublic;
474481
},
475482
pemToJwk(pem: string, kid?: string): JsonWebKeyECPrivate {
476483
const key = jscrypto.createPrivateKey({
@@ -479,8 +486,15 @@ class CCFPolyfill implements CCF {
479486
const jwk = key.export({
480487
format: "jwk",
481488
});
482-
jwk.kid = kid;
483-
return jwk as JsonWebKeyECPrivate;
489+
const jwkWithKid = {
490+
kty: jwk.kty,
491+
crv: jwk.crv,
492+
x: jwk.x,
493+
y: jwk.y,
494+
d: jwk.d,
495+
kid: kid,
496+
};
497+
return jwkWithKid as JsonWebKeyECPrivate;
484498
},
485499
pubRsaPemToJwk(pem: string, kid?: string): JsonWebKeyRSAPublic {
486500
const key = jscrypto.createPublicKey({
@@ -489,8 +503,13 @@ class CCFPolyfill implements CCF {
489503
const jwk = key.export({
490504
format: "jwk",
491505
});
492-
jwk.kid = kid;
493-
return jwk as JsonWebKeyRSAPublic;
506+
const jwkWithKid = {
507+
kty: jwk.kty,
508+
n: jwk.n,
509+
e: jwk.e,
510+
kid: kid,
511+
};
512+
return jwkWithKid as JsonWebKeyRSAPublic;
494513
},
495514
rsaPemToJwk(pem: string, kid?: string): JsonWebKeyRSAPrivate {
496515
const key = jscrypto.createPrivateKey({
@@ -499,8 +518,19 @@ class CCFPolyfill implements CCF {
499518
const jwk = key.export({
500519
format: "jwk",
501520
});
502-
jwk.kid = kid;
503-
return jwk as JsonWebKeyRSAPrivate;
521+
const jwkWithKid = {
522+
kty: jwk.kty,
523+
n: jwk.n,
524+
e: jwk.e,
525+
d: jwk.d,
526+
p: jwk.p,
527+
q: jwk.q,
528+
dp: jwk.dp,
529+
dq: jwk.dq,
530+
qi: jwk.qi,
531+
kid: kid,
532+
};
533+
return jwkWithKid as JsonWebKeyRSAPrivate;
504534
},
505535
pubEddsaPemToJwk(pem: string, kid?: string): JsonWebKeyEdDSAPublic {
506536
const key = jscrypto.createPublicKey({
@@ -509,8 +539,13 @@ class CCFPolyfill implements CCF {
509539
const jwk = key.export({
510540
format: "jwk",
511541
});
512-
jwk.kid = kid;
513-
return jwk as JsonWebKeyEdDSAPublic;
542+
const jwkWithKid = {
543+
kty: jwk.kty,
544+
crv: jwk.crv,
545+
x: jwk.x,
546+
kid: kid,
547+
};
548+
return jwkWithKid as JsonWebKeyEdDSAPublic;
514549
},
515550
eddsaPemToJwk(pem: string, kid?: string): JsonWebKeyEdDSAPrivate {
516551
const key = jscrypto.createPrivateKey({
@@ -519,47 +554,53 @@ class CCFPolyfill implements CCF {
519554
const jwk = key.export({
520555
format: "jwk",
521556
});
522-
jwk.kid = kid;
523-
return jwk as JsonWebKeyEdDSAPrivate;
557+
const jwkWithKid = {
558+
kty: jwk.kty,
559+
crv: jwk.crv,
560+
x: jwk.x,
561+
d: jwk.d,
562+
kid: kid,
563+
};
564+
return jwkWithKid as JsonWebKeyEdDSAPrivate;
524565
},
525566
pubJwkToPem(jwk: JsonWebKeyECPublic): string {
526567
const key = jscrypto.createPublicKey({
527-
key: jwk as jscrypto.JsonWebKey,
568+
key: jwk as JsonWebKey,
528569
format: "jwk",
529570
});
530571
return key.export({ type: "spki", format: "pem" }).toString();
531572
},
532573
jwkToPem(jwk: JsonWebKeyECPrivate): string {
533574
const key = jscrypto.createPrivateKey({
534-
key: jwk as jscrypto.JsonWebKey,
575+
key: jwk as JsonWebKey,
535576
format: "jwk",
536577
});
537578
return key.export({ type: "pkcs8", format: "pem" }).toString();
538579
},
539580
pubRsaJwkToPem(jwk: JsonWebKeyRSAPublic): string {
540581
const key = jscrypto.createPublicKey({
541-
key: jwk as jscrypto.JsonWebKey,
582+
key: jwk as JsonWebKey,
542583
format: "jwk",
543584
});
544585
return key.export({ type: "spki", format: "pem" }).toString();
545586
},
546587
rsaJwkToPem(jwk: JsonWebKeyRSAPrivate): string {
547588
const key = jscrypto.createPrivateKey({
548-
key: jwk as jscrypto.JsonWebKey,
589+
key: jwk as JsonWebKey,
549590
format: "jwk",
550591
});
551592
return key.export({ type: "pkcs8", format: "pem" }).toString();
552593
},
553594
pubEddsaJwkToPem(jwk: JsonWebKeyEdDSAPublic): string {
554595
const key = jscrypto.createPublicKey({
555-
key: jwk as jscrypto.JsonWebKey,
596+
key: jwk as JsonWebKey,
556597
format: "jwk",
557598
});
558599
return key.export({ type: "spki", format: "pem" }).toString();
559600
},
560601
eddsaJwkToPem(jwk: JsonWebKeyEdDSAPrivate): string {
561602
const key = jscrypto.createPrivateKey({
562-
key: jwk as jscrypto.JsonWebKey,
603+
key: jwk as JsonWebKey,
563604
format: "jwk",
564605
});
565606
return key.export({ type: "pkcs8", format: "pem" }).toString();

0 commit comments

Comments
 (0)