Skip to content

Commit bed4afd

Browse files
committed
fix: failing test
1 parent ae869d0 commit bed4afd

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

typescript/packages/common-charm/src/storage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class StorageImpl implements Storage {
239239
// TODO(seefeld,gozala): Should just be one again.
240240
private _getStorageProviderForSpace(space: Space): StorageProvider {
241241
if (!space) throw new Error("No space set");
242+
if (!this.signer) throw new Error("No signer set");
242243

243244
let provider = this.storageProviders.get(space);
244245

typescript/packages/common-charm/src/storage/remote.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { log } from "../storage.ts";
33
import { type StorageProvider, type StorageValue } from "./base.ts";
44
import type { Entity, JSONValue, MemorySpace, Protocol } from "@commontools/memory/interface";
55
import * as Memory from "@commontools/memory/consumer";
6-
import { Identity } from "@commontools/identity";
76
import { assert } from "@commontools/memory/fact";
87
import * as Changes from "@commontools/memory/changes";
98
export * from "@commontools/memory/interface";

typescript/packages/common-charm/test/storage.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import { storage } from "../src/storage.ts";
44
import { StorageProvider } from "../src/storage/base.ts";
55
import { InMemoryStorageProvider } from "../src/storage/memory.ts";
66
import { createRef, DocImpl, getDoc, getSpace } from "@commontools/runner";
7+
import { Identity } from "@commontools/identity";
78

89
storage.setRemoteStorage(new URL("memory://"));
10+
storage.setSigner(await Identity.fromPassphrase("test operator"));
911

1012
describe("Storage", () => {
1113
let storage2: StorageProvider;

typescript/packages/common-identity/src/pass-key.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { Identity } from "./identity.ts";
22
import { bufferSourceToArrayBuffer, random } from "./utils.ts";
33

44
const RP = "Common Tools";
5-
const RP_ID = new URL(window.location.href).host;
65
const PRF_SALT = new TextEncoder().encode("PRF_SALT");
76
const TIMEOUT = 60_000;
7+
const RP_ID = () => new URL(window.location.href).host;
88

99
// These are algorithms to use, in order of preference.
1010
// We prefer ED25519 for security and size, though support
@@ -85,7 +85,7 @@ export class PassKey {
8585

8686
let publicKey: PublicKeyCredentialCreationOptions = {
8787
challenge,
88-
rp: { id: RP_ID, name: RP },
88+
rp: { id: RP_ID(), name: RP },
8989
user,
9090
attestation: "none", // default
9191
authenticatorSelection: {
@@ -131,7 +131,7 @@ export class PassKey {
131131
publicKey: {
132132
allowCredentials,
133133
challenge: random(32),
134-
rpId: RP_ID,
134+
rpId: RP_ID(),
135135
userVerification: userVerification ?? "preferred",
136136
extensions: { prf: { eval: { first: PRF_SALT } } },
137137
timeout: TIMEOUT,

typescript/packages/common-identity/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function once(
2626
const HASH_ALG = "SHA-256";
2727
// Hash input via SHA-256.
2828
export async function hash(input: Uint8Array): Promise<Uint8Array> {
29-
return new Uint8Array(await window.crypto.subtle.digest(HASH_ALG, input));
29+
return new Uint8Array(await globalThis.crypto.subtle.digest(HASH_ALG, input));
3030
}
3131

3232
// Clones object using Structured Clone Algorithm.

0 commit comments

Comments
 (0)