this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Clean up SDK contracts: checkSession to WASM, dead schemas, typed members

Move checkSession business logic to WASM export. Remove unused Zod
schemas. Fix MemoryStorage.removeAccount to update config. Type
listWorkspaceMembers return as WorkspaceMember[].

+40 -28
+15
crates/opake-wasm/src/opake_wasm.rs
··· 539 539 })) 540 540 } 541 541 542 + /// Verify the session is usable by touching the account config record. 543 + /// 544 + /// Reads the config, stamps `modifiedAt`, and writes it back. Throws on 545 + /// auth failure — the SDK uses this during boot to detect dead sessions. 546 + #[wasm_bindgen(js_name = checkSession)] 547 + pub async fn check_session(&mut self) -> Result<(), JsError> { 548 + let mut opake = self.opake()?; 549 + let config = opake.get_account_config().await.map_err(wasm_err)?; 550 + let mut record = config 551 + .unwrap_or_else(|| opake_core::records::AccountConfigRecord::new(&crate::now_iso())); 552 + record.modified_at = crate::now_iso(); 553 + opake.set_account_config(&record).await.map_err(wasm_err)?; 554 + Ok(()) 555 + } 556 + 542 557 /// Fetch the account config record, if it exists. 543 558 #[wasm_bindgen(js_name = getAccountConfig)] 544 559 pub async fn get_account_config(&mut self) -> Result<JsValue, JsError> {
+1
packages/opake-sdk/src/index.ts
··· 43 43 type DocumentMetadata, 44 44 type DeleteRecursiveResult, 45 45 type WorkspaceRole, 46 + type WorkspaceMember, 46 47 type WorkspaceEntry, 47 48 type ResolvedWorkspace, 48 49 type ResolvedIdentity,
-28
packages/opake-sdk/src/schemas.ts
··· 99 99 }) 100 100 .transform((r) => r.workspaces); 101 101 102 - export const retryPendingSharesResultSchema = z.object({ 103 - checked: z.number(), 104 - completed: z.number(), 105 - expired: z.number(), 106 - still_pending: z.number(), 107 - failed: z.number(), 108 - }); 109 - 110 - export type RetryPendingSharesResult = z.output<typeof retryPendingSharesResultSchema>; 111 - 112 - // --------------------------------------------------------------------------- 113 - // Mutations 114 - // --------------------------------------------------------------------------- 115 - 116 - export const mutationResultSchema = z.object({ 117 - uri: z.string().nullable(), 118 - proposed: z.boolean(), 119 - }); 120 - 121 - export type MutationResult = z.output<typeof mutationResultSchema>; 122 - 123 - export const uploadResultSchema = z.object({ 124 - uri: z.string(), 125 - proposed: z.boolean(), 126 - }); 127 - 128 - export type UploadResult = z.output<typeof uploadResultSchema>; 129 - 130 102 // --------------------------------------------------------------------------- 131 103 // File operations 132 104 // ---------------------------------------------------------------------------
+14
packages/opake-sdk/src/storage/memory.ts
··· 73 73 } 74 74 75 75 async removeAccount(did: string): Promise<void> { 76 + const remainingAccounts = Object.fromEntries( 77 + Object.entries(this.config.accounts).filter(([key]) => key !== did), 78 + ); 79 + const remaining = Object.keys(remainingAccounts); 80 + this.config = { 81 + ...this.config, 82 + accounts: remainingAccounts, 83 + default_did: 84 + this.config.default_did === did 85 + ? remaining.length > 0 86 + ? remaining[0] 87 + : undefined 88 + : this.config.default_did, 89 + }; 76 90 this.identities.delete(did); 77 91 this.sessions.delete(did); 78 92 await this.cacheClear(did);
+10
packages/opake-sdk/src/types.ts
··· 71 71 /** Workspace member role — matches the Rust `Role` enum. */ 72 72 export type WorkspaceRole = "manager" | "editor" | "viewer"; 73 73 74 + /** A workspace member as stored in the keyring record. */ 75 + export interface WorkspaceMember { 76 + readonly wrappedKey: { 77 + readonly did: string; 78 + readonly ciphertext: { readonly $bytes: string }; 79 + readonly algo: string; 80 + }; 81 + readonly role: WorkspaceRole; 82 + } 83 + 74 84 /** Workspace (keyring) entry as returned by listWorkspaces. */ 75 85 export interface WorkspaceEntry { 76 86 readonly uri: string;