Skip to content

Commit 8f43bb7

Browse files
🤖 🎨 Autoformat
Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
1 parent 90760ed commit 8f43bb7

3 files changed

Lines changed: 19 additions & 31 deletions

File tree

‎lib/tests/mocha/dpop-proof.spec.ts‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ async function ecdsaKeyPair(namedCurve: 'P-256' | 'P-384' | 'P-521'): Promise<Ke
5050
function derToPem(der: Uint8Array, label: string): string {
5151
let b = '';
5252
for (let i = 0; i < der.length; i++) b += String.fromCharCode(der[i]);
53-
const b64 = btoa(b).match(/.{1,64}/g)?.join('\n') ?? btoa(b);
53+
const b64 =
54+
btoa(b)
55+
.match(/.{1,64}/g)
56+
?.join('\n') ?? btoa(b);
5457
return `-----BEGIN ${label}-----\n${b64}\n-----END ${label}-----`;
5558
}
5659

@@ -61,9 +64,7 @@ const CURVES: Array<{ namedCurve: 'P-256' | 'P-384' | 'P-521'; alg: 'ES256' | 'E
6164
{ namedCurve: 'P-521', alg: 'ES512' },
6265
];
6366

64-
describe('DPoP proof — JWS conformance vs jose.jwtVerify (RFC 9449 + RFC 7518 §3.4)', function (
65-
this: Mocha.Suite
66-
) {
67+
describe('DPoP proof — JWS conformance vs jose.jwtVerify (RFC 9449 + RFC 7518 §3.4)', function (this: Mocha.Suite) {
6768
this.timeout(10_000);
6869

6970
for (const { namedCurve, alg } of CURVES) {
@@ -117,10 +118,7 @@ describe('DPoP proof — JWS conformance vs jose.jwtVerify (RFC 9449 + RFC 7518
117118
) as jose.ProtectedHeaderParameters;
118119
const fakeJwk = await crypto.subtle.exportKey(
119120
'jwk',
120-
await jose.importJWK(
121-
(await proofHeaderJwkFor(kp2, alg)) as jose.JWK,
122-
alg
123-
) as CryptoKey
121+
(await jose.importJWK((await proofHeaderJwkFor(kp2, alg)) as jose.JWK, alg)) as CryptoKey
124122
);
125123
delete (fakeJwk as Record<string, unknown>).d;
126124
delete (fakeJwk as Record<string, unknown>).key_ops;
@@ -147,10 +145,7 @@ describe('DPoP proof — JWS conformance vs jose.jwtVerify (RFC 9449 + RFC 7518
147145
* Round-tripping through `dpopFn` ensures the JWK shape matches what the
148146
* SDK emits in real proofs.
149147
*/
150-
async function proofHeaderJwkFor(
151-
kp: KeyPair,
152-
alg: 'ES256' | 'ES384' | 'ES512'
153-
): Promise<unknown> {
148+
async function proofHeaderJwkFor(kp: KeyPair, alg: 'ES256' | 'ES384' | 'ES512'): Promise<unknown> {
154149
const proof = await dpopFn(kp, DefaultCryptoService, HTU, HTM);
155150
const header = jose.decodeProtectedHeader(proof);
156151
void alg; // alg unused; kept in signature for caller clarity

‎lib/tests/server.ts‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,7 @@ async function verifyDpopProof(
9797
};
9898
}
9999
const alg = protectedHeader.alg;
100-
if (
101-
!alg ||
102-
alg === 'none' ||
103-
alg.startsWith('HS') ||
104-
!/^(ES|RS|PS|EdDSA)/.test(alg)
105-
) {
100+
if (!alg || alg === 'none' || alg.startsWith('HS') || !/^(ES|RS|PS|EdDSA)/.test(alg)) {
106101
return {
107102
ok: false,
108103
status: 400,
@@ -757,9 +752,7 @@ const kas: RequestListener = async (req, res) => {
757752
const headers: Record<string, string> = { 'Content-Type': 'application/json' };
758753
if (check.challengeNonce) headers['DPoP-Nonce'] = check.challengeNonce;
759754
res.writeHead(status, headers);
760-
res.end(
761-
JSON.stringify({ error: check.error, error_description: check.error_description })
762-
);
755+
res.end(JSON.stringify({ error: check.error, error_description: check.error_description }));
763756
return;
764757
}
765758

@@ -770,9 +763,7 @@ const kas: RequestListener = async (req, res) => {
770763

771764
res.statusCode = 200;
772765
res.setHeader('Content-Type', 'application/json');
773-
res.end(
774-
JSON.stringify({ access_token: accessToken, token_type: 'DPoP', expires_in: 3600 })
775-
);
766+
res.end(JSON.stringify({ access_token: accessToken, token_type: 'DPoP', expires_in: 3600 }));
776767
return;
777768
} else {
778769
console.log(`[DEBUG] invalid path [${url.pathname}]`);

‎lib/tests/web/access/access-fetch.test.ts‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,15 @@ describe('access-fetch.js', () => {
274274
fetchStub
275275
.onCall(0)
276276
.returns(responseWithNonce({ error: 'use_dpop_nonce' }, false, 401, challengeNonce));
277-
fetchStub.onCall(1).returns(
278-
responseWithNonce(
279-
{ keyAccessServers: [{ uri: 'https://kas1.example.com' }], pagination: {} },
280-
true,
281-
200
282-
)
283-
);
277+
fetchStub
278+
.onCall(1)
279+
.returns(
280+
responseWithNonce(
281+
{ keyAccessServers: [{ uri: 'https://kas1.example.com' }], pagination: {} },
282+
true,
283+
200
284+
)
285+
);
284286

285287
const result = await fetchKeyAccessServers(platformUrl, dpopAuthProvider);
286288

0 commit comments

Comments
 (0)