Encrypted, ephemeral, private memos on atproto

feat(lexicon): use lex-cli to gen types

graham.systems 270231c9 698fdf1f

verified
Changed files
+176 -11
packages
lexicon
lexicons
app
cistern
src
types
app
cistern
lexicon
+55
deno.lock
··· 14 14 "jsr:@std/expect@^1.0.17": "1.0.17", 15 15 "jsr:@std/internal@^1.0.10": "1.0.12", 16 16 "jsr:@std/internal@^1.0.12": "1.0.12", 17 + "npm:@atcute/lex-cli@*": "2.3.1", 18 + "npm:@atcute/lex-cli@^2.3.1": "2.3.1", 19 + "npm:@atcute/lexicons@^1.2.2": "1.2.2", 17 20 "npm:@atproto/lexicon@~0.5.1": "0.5.1" 18 21 }, 19 22 "jsr": { ··· 54 57 } 55 58 }, 56 59 "npm": { 60 + "@atcute/lex-cli@2.3.1": { 61 + "integrity": "sha512-HrHD91CFSFd/p0UFe3akFA1HXiboQwd5LbYiU0srKdLxGX+NLTX/EdCdhbLV6M7LsXdmxk7PB6BMcprsX4rbvg==", 62 + "dependencies": [ 63 + "@atcute/lexicon-doc", 64 + "@badrap/valita", 65 + "@optique/core", 66 + "@optique/run", 67 + "picocolors", 68 + "prettier" 69 + ], 70 + "bin": true 71 + }, 72 + "@atcute/lexicon-doc@1.1.4": { 73 + "integrity": "sha512-OL0fsXtbnN/KwCq/L3nWGvOCdSHV0NWTatgLUIPt+T9AhcziFNaXAbbjvVHdflr3ZaLh3ksleHK0J789UBhlWQ==", 74 + "dependencies": [ 75 + "@badrap/valita" 76 + ] 77 + }, 78 + "@atcute/lexicons@1.2.2": { 79 + "integrity": "sha512-bgEhJq5Z70/0TbK5sx+tAkrR8FsCODNiL2gUEvS5PuJfPxmFmRYNWaMGehxSPaXWpU2+Oa9ckceHiYbrItDTkA==", 80 + "dependencies": [ 81 + "@standard-schema/spec", 82 + "esm-env" 83 + ] 84 + }, 57 85 "@atproto/common-web@0.4.3": { 58 86 "integrity": "sha512-nRDINmSe4VycJzPo6fP/hEltBcULFxt9Kw7fQk6405FyAWZiTluYHlXOnU7GkQfeUK44OENG1qFTBcmCJ7e8pg==", 59 87 "dependencies": [ ··· 76 104 "@atproto/syntax@0.4.1": { 77 105 "integrity": "sha512-CJdImtLAiFO+0z3BWTtxwk6aY5w4t8orHTMVJgkf++QRJWTxPbIFko/0hrkADB7n2EruDxDSeAgfUGehpH6ngw==" 78 106 }, 107 + "@badrap/valita@0.4.6": { 108 + "integrity": "sha512-4kdqcjyxo/8RQ8ayjms47HCWZIF5981oE5nIenbfThKDxWXtEHKipAOWlflpPJzZx9y/JWYQkp18Awr7VuepFg==" 109 + }, 110 + "@optique/core@0.6.2": { 111 + "integrity": "sha512-HTxIHJ8xLOSZotiU6Zc5BCJv+SJ8DMYmuiQM+7tjF7RolJn/pdZNe7M78G3+DgXL9lIf82l8aGcilmgVYRQnGQ==" 112 + }, 113 + "@optique/run@0.6.2": { 114 + "integrity": "sha512-ERksB5bHozwEUVlTPToIc8UjZZBOgLeBhFZYh2lgldUbNDt7LItzgcErsPq5au5i5IBmmyCti4+2A3x+MRI4Xw==", 115 + "dependencies": [ 116 + "@optique/core" 117 + ] 118 + }, 119 + "@standard-schema/spec@1.0.0": { 120 + "integrity": "sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==" 121 + }, 122 + "esm-env@1.2.2": { 123 + "integrity": "sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==" 124 + }, 79 125 "graphemer@1.4.0": { 80 126 "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==" 81 127 }, ··· 84 130 }, 85 131 "multiformats@9.9.0": { 86 132 "integrity": "sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg==" 133 + }, 134 + "picocolors@1.1.1": { 135 + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==" 136 + }, 137 + "prettier@3.6.2": { 138 + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", 139 + "bin": true 87 140 }, 88 141 "uint8arrays@3.0.0": { 89 142 "integrity": "sha512-HRCx0q6O9Bfbp+HHSfQQKD7wU70+lydKVt4EghkdOvlK/NlrF90z+eXV34mUd48rNvVJXwkrMSPpCATkct8fJA==", ··· 107 160 }, 108 161 "packages/lexicon": { 109 162 "dependencies": [ 163 + "npm:@atcute/lex-cli@^2.3.1", 164 + "npm:@atcute/lexicons@^1.2.2", 110 165 "npm:@atproto/lexicon@~0.5.1" 111 166 ] 112 167 }
+5
packages/lexicon/deno.jsonc
··· 3 3 "exports": { 4 4 ".": "./mod.ts" 5 5 }, 6 + "tasks": { 7 + "generate": "deno run --allow-env --allow-sys --allow-read --allow-write npm:@atcute/lex-cli generate -c lex.config.ts" 8 + }, 6 9 "imports": { 10 + "@atcute/lex-cli": "npm:@atcute/lex-cli@^2.3.1", 11 + "@atcute/lexicons": "npm:@atcute/lexicons@^1.2.2", 7 12 "@atproto/lexicon": "npm:@atproto/lexicon@^0.5.1" 8 13 } 9 14 }
+9
packages/lexicon/lex.config.ts
··· 1 + import { defineLexiconConfig } from "@atcute/lex-cli"; 2 + 3 + export default defineLexiconConfig({ 4 + files: ["lexicons/**/*.json"], 5 + outdir: "./src", 6 + modules: { 7 + importSuffix: ".ts", 8 + }, 9 + });
+1 -11
packages/lexicon/mod.ts
··· 1 - import item from "./schemas/item.json" with { type: "json" }; 2 - import pubkey from "./schemas/pubkey.json" with { type: "json" }; 3 - 4 - import { type LexiconDoc, Lexicons } from "@atproto/lexicon"; 5 - 6 - const lexicons: Lexicons = new Lexicons(); 7 - 8 - lexicons.add(item as LexiconDoc); 9 - lexicons.add(pubkey as LexiconDoc); 10 - 11 - export { item, lexicons, pubkey }; 1 + export * from "./src/index.ts";
packages/lexicon/schemas/item.json packages/lexicon/lexicons/app/cistern/lexicon/item.json
packages/lexicon/schemas/pubkey.json packages/lexicon/lexicons/app/cistern/lexicon/pubkey.json
+2
packages/lexicon/src/index.ts
··· 1 + export * as AppCisternLexiconItem from "./types/app/cistern/lexicon/item.ts"; 2 + export * as AppCisternLexiconPubkey from "./types/app/cistern/lexicon/pubkey.ts";
+64
packages/lexicon/src/types/app/cistern/lexicon/item.ts
··· 1 + import type {} from "@atcute/lexicons"; 2 + import * as v from "@atcute/lexicons/validations"; 3 + import type {} from "@atcute/lexicons/ambient"; 4 + 5 + const _mainSchema = /*#__PURE__*/ v.record( 6 + /*#__PURE__*/ v.string(), 7 + /*#__PURE__*/ v.object({ 8 + $type: /*#__PURE__*/ v.literal("app.cistern.lexicon.item"), 9 + /** 10 + * Algorithm used for encryption, in <kem>-<cipher>-<hash> format. 11 + */ 12 + algorithm: /*#__PURE__*/ v.string< 13 + "x_wing-xchacha20_poly1305-sha3_512" | (string & {}) 14 + >(), 15 + /** 16 + * Encapsulated shared ciphertext 17 + * @maxLength 2000 18 + */ 19 + ciphertext: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 20 + /*#__PURE__*/ v.stringLength(0, 2000), 21 + ]), 22 + /** 23 + * Base64-encoded hash of the decrypted contents. Verify this before accepting the decrypted message. The algorithm is identified under `algorithm` 24 + */ 25 + contentHash: /*#__PURE__*/ v.string(), 26 + /** 27 + * Original content length in bytes 28 + */ 29 + contentLength: /*#__PURE__*/ v.integer(), 30 + /** 31 + * Base64-encoded nonce used for content encryption 32 + * @maxLength 32 33 + */ 34 + nonce: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 35 + /*#__PURE__*/ v.stringLength(0, 32), 36 + ]), 37 + /** 38 + * Base64-encoded encrypted item contents 39 + */ 40 + payload: /*#__PURE__*/ v.string(), 41 + /** 42 + * URI to the public key used to encrypt this item 43 + */ 44 + pubkey: /*#__PURE__*/ v.resourceUriString(), 45 + /** 46 + * TID representing when this item was created 47 + */ 48 + tid: /*#__PURE__*/ v.tidString(), 49 + }), 50 + ); 51 + 52 + type main$schematype = typeof _mainSchema; 53 + 54 + export interface mainSchema extends main$schematype {} 55 + 56 + export const mainSchema = _mainSchema as mainSchema; 57 + 58 + export interface Main extends v.InferInput<typeof mainSchema> {} 59 + 60 + declare module "@atcute/lexicons/ambient" { 61 + interface Records { 62 + "app.cistern.lexicon.item": mainSchema; 63 + } 64 + }
+40
packages/lexicon/src/types/app/cistern/lexicon/pubkey.ts
··· 1 + import type {} from "@atcute/lexicons"; 2 + import * as v from "@atcute/lexicons/validations"; 3 + import type {} from "@atcute/lexicons/ambient"; 4 + 5 + const _mainSchema = /*#__PURE__*/ v.record( 6 + /*#__PURE__*/ v.string(), 7 + /*#__PURE__*/ v.object({ 8 + $type: /*#__PURE__*/ v.literal("app.cistern.lexicon.pubkey"), 9 + /** 10 + * KEM algorithm used to generate this key 11 + */ 12 + algorithm: /*#__PURE__*/ v.string<"x_wing" | (string & {})>(), 13 + /** 14 + * Contents of the public key, encoded in base64 15 + */ 16 + content: /*#__PURE__*/ v.string(), 17 + createdAt: /*#__PURE__*/ v.datetimeString(), 18 + /** 19 + * A memorable name for this public key. Avoid using revealing names, such as "Graham's Macbook" 20 + * @minGraphemes 1 21 + */ 22 + name: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 23 + /*#__PURE__*/ v.stringGraphemes(1), 24 + ]), 25 + }), 26 + ); 27 + 28 + type main$schematype = typeof _mainSchema; 29 + 30 + export interface mainSchema extends main$schematype {} 31 + 32 + export const mainSchema = _mainSchema as mainSchema; 33 + 34 + export interface Main extends v.InferInput<typeof mainSchema> {} 35 + 36 + declare module "@atcute/lexicons/ambient" { 37 + interface Records { 38 + "app.cistern.lexicon.pubkey": mainSchema; 39 + } 40 + }