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 expect(producer.did).toEqual("did:plc:test123"); 51 expect(producer.publicKey).toBeUndefined(); 52 expect(producer.rpc).toBeDefined(); 53 - expect(producer.manager).toBeDefined(); 54 }, 55 }); 56
··· 50 expect(producer.did).toEqual("did:plc:test123"); 51 expect(producer.publicKey).toBeUndefined(); 52 expect(producer.rpc).toBeDefined(); 53 }, 54 }); 55
+19 -4
packages/producer/mod.ts
··· 10 import { now } from "@atcute/tid"; 11 import { type AppCisternMemo, AppCisternPubkey } from "@cistern/lexicon"; 12 13 export async function createProducer( 14 { publicKey: rkey, ...opts }: ProducerOptions, 15 ): Promise<Producer> { ··· 46 }); 47 } 48 49 export class Producer { 50 did: Did; 51 rpc: Client; 52 - manager: CredentialManager; 53 publicKey?: PublicKeyOption; 54 55 constructor(params: ProducerParams) { 56 this.did = params.miniDoc.did; 57 this.rpc = params.rpc; 58 - this.manager = params.manager; 59 this.publicKey = params.publicKey; 60 } 61 62 /** 63 - * Creates a memo and saves it as a record in the user's PDS 64 */ 65 async createMemo(text: string): Promise<ResourceUri> { 66 if (!this.publicKey) { ··· 144 } 145 146 /** 147 - * Sets a public key as the main encryption key 148 */ 149 selectPublicKey(key: PublicKeyOption) { 150 this.publicKey = key;
··· 10 import { now } from "@atcute/tid"; 11 import { type AppCisternMemo, AppCisternPubkey } from "@cistern/lexicon"; 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 + */ 20 export async function createProducer( 21 { publicKey: rkey, ...opts }: ProducerOptions, 22 ): Promise<Producer> { ··· 53 }); 54 } 55 56 + /** 57 + * A client for encrypting and creating Cistern memos. 58 + */ 59 export class Producer { 60 + /** DID of the user this producer acts on behalf of */ 61 did: Did; 62 + 63 + /** `@atcute/client` instance with credential manager */ 64 rpc: Client; 65 + 66 + /** Partial public key record, used for encrypting items */ 67 publicKey?: PublicKeyOption; 68 69 constructor(params: ProducerParams) { 70 this.did = params.miniDoc.did; 71 this.rpc = params.rpc; 72 this.publicKey = params.publicKey; 73 } 74 75 /** 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 78 */ 79 async createMemo(text: string): Promise<ResourceUri> { 80 if (!this.publicKey) { ··· 158 } 159 160 /** 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 163 */ 164 selectPublicKey(key: PublicKeyOption) { 165 this.publicKey = key;