diff --git a/README.md b/README.md index 14e37e3..8dadb5c 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ # Cistern Cistern is an attempt at implementing a private, personal quick-capture system -on AT Protocol. Cistern "items" are encrypted, so that they are only readable -by the holder of the correct secret key—stored off-protocol. These items are +on AT Protocol. Cistern "items" are encrypted, so that they are only readable by +the holder of the correct secret key—stored off-protocol. These items are intended to be ephemeral, and to be deleted after they've been read. The intention is for Cistern to bridge the gap between where ideas are had and where they can be stored long-term. For example, let's say you have an idea -while at a restaurant. You create an item using your phone, and once you're -back at your desk and you open Obsidian, that item is automatically pulled from -your PDS, decrypted, and deleted from your PDS. If your notebook was open at -the time you created your item, the Cistern Obsidian plugin would have been -notified of the new item via the Jetstream, and so you would find your memo -waiting for you once you got home. +while at a restaurant. You create an item using your phone, and once you're back +at your desk and you open Obsidian, that item is automatically pulled from your +PDS, decrypted, and deleted from your PDS. If your notebook was open at the time +you created your item, the Cistern Obsidian plugin would have been notified of +the new item via the Jetstream, and so you would find your memo waiting for you +once you got home. diff --git a/packages/crypto/deno.jsonc b/packages/crypto/deno.jsonc index 2158ff9..348c448 100644 --- a/packages/crypto/deno.jsonc +++ b/packages/crypto/deno.jsonc @@ -1,7 +1,7 @@ { "name": "@cistern/crypto", "exports": { - ".": "mod.ts" + ".": "./mod.ts" }, "imports": { "@noble/ciphers": "jsr:@noble/ciphers@^2.0.1", diff --git a/packages/crypto/src/keys.ts b/packages/crypto/src/keys.ts index e783375..c319244 100644 --- a/packages/crypto/src/keys.ts +++ b/packages/crypto/src/keys.ts @@ -1,13 +1,14 @@ import { XWing } from "@noble/post-quantum/hybrid.js"; +import type { KeyPair } from "./types.ts"; -export function generateKeys() { +export function generateKeys(): KeyPair { return XWing.keygen(); } -export function serializeKey(key: Uint8Array) { +export function serializeKey(key: Uint8Array): string { return key.toBase64(); } -export function deserializeKey(key: string) { +export function deserializeKey(key: string): Uint8Array { return Uint8Array.fromBase64(key); } diff --git a/packages/crypto/src/types.ts b/packages/crypto/src/types.ts index 5515d9f..67783ac 100644 --- a/packages/crypto/src/types.ts +++ b/packages/crypto/src/types.ts @@ -1,3 +1,8 @@ +export type KeyPair = { + secretKey: Uint8Array; + publicKey: Uint8Array; +}; + export interface EncryptedPayload { cipherText: string; content: string; diff --git a/packages/lexicon/deno.jsonc b/packages/lexicon/deno.jsonc index 262151d..cb88406 100644 --- a/packages/lexicon/deno.jsonc +++ b/packages/lexicon/deno.jsonc @@ -1,7 +1,7 @@ { "name": "@cistern/lexicon", "exports": { - ".": "mod.ts" + ".": "./mod.ts" }, "imports": { "@atproto/lexicon": "npm:@atproto/lexicon@^0.5.1" diff --git a/packages/lexicon/mod.ts b/packages/lexicon/mod.ts index bad3151..a44bb04 100644 --- a/packages/lexicon/mod.ts +++ b/packages/lexicon/mod.ts @@ -1,11 +1,11 @@ import item from "./schemas/item.json" with { type: "json" }; import pubkey from "./schemas/pubkey.json" with { type: "json" }; -import { Lexicons } from "@atproto/lexicon"; +import { type LexiconDoc, Lexicons } from "@atproto/lexicon"; -const lexicons = new Lexicons(); +const lexicons: Lexicons = new Lexicons(); -lexicons.add(item); -lexicons.add(pubkey); +lexicons.add(item as LexiconDoc); +lexicons.add(pubkey as LexiconDoc); export { item, lexicons, pubkey }; diff --git a/packages/lexicon/schemas/item.json b/packages/lexicon/schemas/item.json index ea057f9..bf2f60c 100644 --- a/packages/lexicon/schemas/item.json +++ b/packages/lexicon/schemas/item.json @@ -1,5 +1,5 @@ { - "version": 1, + "lexicon": 1, "id": "app.cistern.lexicon.item", "description": "An encrypted memo intended to be accessed and deleted later.", "defs": { @@ -23,7 +23,7 @@ "type": "string", "description": "TID representing when this item was created", "format": "tid" - } + }, "ciphertext": { "type": "string", "description": "Encapsulated shared ciphertext", @@ -32,7 +32,7 @@ "nonce": { "type": "string", "description": "Base64-encoded nonce used for content encryption", - "maxLength": 32, + "maxLength": 32 }, "algorithm": { "type": "string", @@ -50,7 +50,7 @@ }, "contentLength": { "type": "integer", - "description": "Original content length in bytes", + "description": "Original content length in bytes" }, "contentHash": { "type": "string", diff --git a/packages/lexicon/schemas/pubkey.json b/packages/lexicon/schemas/pubkey.json index e5014b2..3dd9bae 100644 --- a/packages/lexicon/schemas/pubkey.json +++ b/packages/lexicon/schemas/pubkey.json @@ -1,5 +1,5 @@ { - "version": 1, + "lexicon": 1, "id": "app.cistern.lexicon.pubkey", "description": "A public key used to encrypt Cistern items", "defs": {