Session Messenger messages schemas, TypeScript definitions and enums used by @session.js/client
To build your own Storage adapter, use:
importtype{Storage}from'@session.js/types'exportclassMyInMemoryStorageimplementsStorage{storage: Map<string,string>=newMap()get(key: string){returnthis.storage.get(key)??null}set(key: string,value: string){this.storage.set(key,value)}delete(key: string){this.storage.delete(key)}has(key: string){returnthis.storage.has(key)}}To build your own Network connecter, use:
importtype{Network}from'@session.js/types'import{RequestType,typeRequestGetSwarmsBody,typeRequestPollBody,typeRequestStoreBody,typeRequestUploadAttachment}from'@session.js/types/network/request'exportclassMyNetworkimplementsNetwork{onRequest(type: RequestType,body: object): Promise<object>{switch(type){caseRequestType.Store:
return// typeof ResponseStorecaseRequestType.GetSnodes:
return// typeof ResponseGetSnodescaseRequestType.GetSwarms:
return// typeof ResponseGetSwarmscaseRequestType.Poll:
return// typeof ResponsePollcaseRequestType.UploadAttachment:
return// typeof ResponseUploadAttachmentdefault:
thrownewError('Invalid request type')}}}Use Session messenger programmatically with Session.js: Session bots, custom Session clients, and more.
hloth.dev/donate · Tor: hlothdevzkti6suoksy7lcy7hmpxnr3msu5waokzaslsi2mnx5ouu4qd.onion/donate