Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/charm/deno.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@commontools/charm",
"tasks": {
"test": "deno test --allow-env --allow-ffi --allow-read"
"test": "deno test --allow-env --allow-ffi --allow-read --allow-write"
},
"exports": {
".": "./src/index.ts",
Expand Down
12 changes: 6 additions & 6 deletions packages/identity/src/ed25519/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class NativeEd25519Signer<ID extends DIDKey> implements Signer<ID> {
await globalThis.crypto.subtle.sign(
ED25519_ALG,
this.#keypair.privateKey,
payload,
payload as BufferSource,
),
);

Expand All @@ -76,15 +76,15 @@ export class NativeEd25519Signer<ID extends DIDKey> implements Signer<ID> {
const rawPublic = await ed25519.getPublicKeyAsync(rawPrivateKey);
const privateKey = await globalThis.crypto.subtle.importKey(
"pkcs8",
pkcs8Private,
pkcs8Private as BufferSource,
ED25519_ALG,
false,
["sign"],
);
// Set the public key to be extractable for DID generation.
const publicKey = await globalThis.crypto.subtle.importKey(
"raw",
rawPublic,
rawPublic as BufferSource,
ED25519_ALG,
true,
[
Expand Down Expand Up @@ -135,8 +135,8 @@ export class NativeEd25519Verifier<ID extends DIDKey> implements Verifier<ID> {
await globalThis.crypto.subtle.verify(
ED25519_ALG,
this.#publicKey,
signature,
payload,
signature as BufferSource,
payload as BufferSource,
)
) {
return { ok: {} };
Expand All @@ -159,7 +159,7 @@ export class NativeEd25519Verifier<ID extends DIDKey> implements Verifier<ID> {
// Set the public key to be extractable for DID generation.
const publicKey = await globalThis.crypto.subtle.importKey(
"raw",
rawPublicKey,
rawPublicKey as BufferSource,
ED25519_ALG,
true,
[
Expand Down
10 changes: 7 additions & 3 deletions packages/identity/src/pass-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ export class PassKey {
};

const publicKey: PublicKeyCredentialCreationOptions = {
challenge,
challenge: challenge as BufferSource,
rp: { id: RP_ID(), name: RP },
user,
user: {
id: userId as BufferSource,
name,
displayName,
},
attestation: "none", // default
authenticatorSelection: {
// "Resident Keys" have been renamed to "Discoverable Keys",
Expand Down Expand Up @@ -130,7 +134,7 @@ export class PassKey {
const credential = (await navigator.credentials.get({
publicKey: {
allowCredentials,
challenge: random(32),
challenge: random(32) as BufferSource,
rpId: RP_ID(),
userVerification: userVerification ?? "preferred",
extensions: { prf: { eval: { first: PRF_SALT } } },
Expand Down
4 changes: 3 additions & 1 deletion packages/identity/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ export function once(
const HASH_ALG = "SHA-256";
// Hash input via SHA-256.
export async function hash(input: Uint8Array): Promise<Uint8Array> {
return new Uint8Array(await globalThis.crypto.subtle.digest(HASH_ALG, input));
return new Uint8Array(
await globalThis.crypto.subtle.digest(HASH_ALG, input as BufferSource),
);
}
2 changes: 1 addition & 1 deletion packages/static/etag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Returns a base64-encoded hash in quotes.
*/
export async function generateETag(content: Uint8Array): Promise<string> {
const hash = await crypto.subtle.digest("SHA-256", content);
const hash = await crypto.subtle.digest("SHA-256", content as BufferSource);
const base64 = btoa(String.fromCharCode(...new Uint8Array(hash)))
.replace(/\+/g, "-")
.replace(/\//g, "_")
Expand Down
2 changes: 1 addition & 1 deletion packages/toolshed/routes/static/static.index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ router.get("/static/*", async (c) => {
// Simple caching: always validate with ETag
const cacheHeaders = createCacheHeaders(etag);

return new Response(buffer, {
return new Response(buffer as BodyInit, {
status: 200,
headers: {
"Content-Type": mimeType,
Expand Down
6 changes: 3 additions & 3 deletions tasks/check.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env bash
set -e

DENO_VERSION_REQUIRED="2.4.5"
DENO_VERSIONS_ALLOWED=("2.5.2" "2.4.5")
# This is more portable than parsing `deno --version`
DENO_VERSION=$(echo "console.log(Deno.version.deno)" | deno run -)
if [ "$DENO_VERSION" != "$DENO_VERSION_REQUIRED" ]; then
echo "ERROR: Deno version is $DENO_VERSION, expected $DENO_VERSION_REQUIRED."
if [[ ! " ${DENO_VERSIONS_ALLOWED[@]} " =~ " ${DENO_VERSION} " ]]; then
echo "ERROR: Deno version is $DENO_VERSION, expected one of: ${DENO_VERSIONS_ALLOWED[*]}."
exit 1
fi

Expand Down