Encrypted, ephemeral, private memos on atproto

docs(producer): add typedocs

graham.systems ee990e7a 4e4d4e46

verified
Changed files
+19 -5
packages
producer
-1
packages/producer/mod.test.ts
··· 50 50 expect(producer.did).toEqual("did:plc:test123"); 51 51 expect(producer.publicKey).toBeUndefined(); 52 52 expect(producer.rpc).toBeDefined(); 53 - expect(producer.manager).toBeDefined(); 54 53 }, 55 54 }); 56 55
+19 -4
packages/producer/mod.ts
··· 10 10 import { now } from "@atcute/tid"; 11 11 import { type AppCisternMemo, AppCisternPubkey } from "@cistern/lexicon"; 12 12 13 + /** 14 + * Creates a `Producer` instance with all necessary requirements. This is the recommended way to construct a `Producer`. 15 + * 16 + * @description Resolves the user's DID using Slingshot, instantiates an `@atcute/client` instance, creates an initial session, and returns a new `Producer`. If a pubkey record key is provided, it will be resolved and set as the active key. 17 + * @param {ProducerOptions} options - Information for constructing the underlying XRPC client 18 + * @returns {Promise<Producer>} A Cistern producer client with an authorized session 19 + */ 13 20 export async function createProducer( 14 21 { publicKey: rkey, ...opts }: ProducerOptions, 15 22 ): Promise<Producer> { ··· 46 53 }); 47 54 } 48 55 56 + /** 57 + * A client for encrypting and creating Cistern memos. 58 + */ 49 59 export class Producer { 60 + /** DID of the user this producer acts on behalf of */ 50 61 did: Did; 62 + 63 + /** `@atcute/client` instance with credential manager */ 51 64 rpc: Client; 52 - manager: CredentialManager; 65 + 66 + /** Partial public key record, used for encrypting items */ 53 67 publicKey?: PublicKeyOption; 54 68 55 69 constructor(params: ProducerParams) { 56 70 this.did = params.miniDoc.did; 57 71 this.rpc = params.rpc; 58 - this.manager = params.manager; 59 72 this.publicKey = params.publicKey; 60 73 } 61 74 62 75 /** 63 - * Creates a memo and saves it as a record in the user's PDS 76 + * Creates a memo and saves it as a record in the user's PDS. 77 + * @param {string} text - The contents of the memo you wish to create 64 78 */ 65 79 async createMemo(text: string): Promise<ResourceUri> { 66 80 if (!this.publicKey) { ··· 144 158 } 145 159 146 160 /** 147 - * Sets a public key as the main encryption key 161 + * Sets a public key as the main encryption key. This is not necessary to use if you instantiated the client with a public key. 162 + * @param {PublicKeyOption} key - The key you want to use for encryption 148 163 */ 149 164 selectPublicKey(key: PublicKeyOption) { 150 165 this.publicKey = key;