Skip to content

Commit 9e660c7

Browse files
committed
Update blindrsa-ts to 0.4.5
1 parent 6b4d9c9 commit 9e660c7

4 files changed

Lines changed: 22 additions & 14 deletions

File tree

package-lock.json

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"clean": "tsc -b --clean && rimraf lib coverage dist"
3838
},
3939
"dependencies": {
40-
"@cloudflare/blindrsa-ts": "0.4.3",
40+
"@cloudflare/blindrsa-ts": "0.4.5",
4141
"@cloudflare/voprf-ts": "1.0.0",
4242
"asn1-parser": "1.1.8",
4343
"asn1js": "3.0.5",

test/vitest.setup-file.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const parentSign = webcrypto.subtle.sign;
1313
async function mockSign(
1414
algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams,
1515
key: CryptoKey,
16-
data: Uint8Array,
16+
data: ArrayBuffer,
1717
): Promise<ArrayBuffer> {
1818
if (
1919
algorithm === 'RSA-RAW' ||
@@ -25,7 +25,11 @@ async function mockSign(
2525
}
2626
key.algorithm.name = 'RSA-PSS';
2727
try {
28-
return await RSABSSA.SHA384.PSSZero.Deterministic().blindSign(key, data);
28+
const blindSig = await RSABSSA.SHA384.PSSZero.Deterministic().blindSign(
29+
key,
30+
new Uint8Array(data),
31+
);
32+
return blindSig.slice().buffer;
2933
} finally {
3034
key.algorithm.name = algorithmName;
3135
}
@@ -34,7 +38,9 @@ async function mockSign(
3438
// webcrypto calls crypto, which is mocked. We need to restore the original implementation.
3539
crypto.subtle.sign = parentSign;
3640
const res = webcrypto.subtle.sign(algorithm, key, data);
37-
crypto.subtle.sign = mockSign;
41+
await res.finally(() => {
42+
crypto.subtle.sign = mockSign;
43+
});
3844
return res;
3945
}
4046

vitest.config.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { defineConfig } from 'vitest/config'
1+
import { defineConfig } from 'vitest/config';
22

33
export default defineConfig({
44
test: {
5-
setupFiles: ["./test/vitest.setup-file.ts"],
5+
exclude: ['lib/**', 'node_modules/**'],
6+
setupFiles: ['./test/vitest.setup-file.ts'],
67
coverage: { enabled: true },
7-
testTimeout: 10_000
8-
}
9-
})
8+
testTimeout: 10_000,
9+
},
10+
});

0 commit comments

Comments
 (0)