Skip to content

Commit e2f4478

Browse files
committed
fix: post-merge regressions
1 parent a77fdea commit e2f4478

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ 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 * as Principal from "@commontools/memory/principal";
6+
import { Identity } from "@commontools/identity";
77
import { assert } from "@commontools/memory/fact";
88
import * as Changes from "@commontools/memory/changes";
99
export * from "@commontools/memory/interface";
@@ -37,10 +37,7 @@ const HOME = "did:key:z6Mko2qR9b8mbdPnaEKXvcYwdK7iDnRkh8mEcEP2719aCu6P";
3737
/**
3838
* ed25519 key derived from the sha256 of the "common operator".
3939
*/
40-
const AS =
41-
Principal.ED25519Signer.fromString<"did:key:z6Mkge3xkXc4ksLsf8CtRxunUxcX6dByT4QdWCVEHbUJ8YVn">(
42-
"MgCZHlm5ODrbwDGXGIgBhqp2HmKj3dcxxyaqkopec6vK7xO0BIHsZlqE1qjfTHd7TN9Xcw59xgzDElFlwH2OmKQOO0Gk=",
43-
);
40+
const defaultProfile = await Identity.fromPassphrase("common operator");
4441

4542
export class RemoteStorageProvider implements StorageProvider {
4643
connection: WebSocket | null = null;
@@ -62,7 +59,7 @@ export class RemoteStorageProvider implements StorageProvider {
6259

6360
constructor({
6461
address,
65-
as = AS,
62+
as = defaultProfile,
6663
space = HOME,
6764
the = "application/json",
6865
}: {

typescript/packages/common-identity/src/ed25519/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export class Ed25519Signer<ID extends DIDKey> implements Signer<ID> {
7676
throw new Error("common-identity: Could not deserialize key.");
7777
}
7878
}
79-
}
8079
}
8180

8281
export class Ed25519Verifier<ID extends DIDKey> implements Verifier<ID> {
@@ -109,4 +108,3 @@ export class Ed25519Verifier<ID extends DIDKey> implements Verifier<ID> {
109108
);
110109
}
111110
}
112-

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ export class Identity<ID extends DIDKey = DIDKey> implements Signer<ID> {
6767
return new Identity(signer);
6868
}
6969

70+
static async fromPassphrase<ID extends DIDKey>(passphrase: string): Promise<Identity<ID>> {
71+
const rawPrivateKey = await hash(new TextEncoder().encode(passphrase));
72+
return new Identity(await Ed25519Signer.fromRaw<ID>(rawPrivateKey));
73+
}
74+
7075
// Deserialize `input` from storage into an `Identity`.
7176
static async deserialize<ID extends DIDKey>(input: any): Promise<Identity<ID>> {
7277
return new Identity(await Ed25519Signer.deserialize(input));

typescript/packages/common-memory/deno.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"./interface": "./interface.ts",
1515
"./fact": "./fact.ts",
1616
"./changes": "./changes.ts",
17-
"./consumer": "./consumer.ts"
17+
"./consumer": "./consumer.ts",
18+
"./principal": "./principal.ts"
1819
},
1920
"imports": {
2021
"@db/sqlite": "jsr:@db/sqlite@^0.12.0",

0 commit comments

Comments
 (0)