adding block interface methods

This commit is contained in:
Roland Osborne 2024-07-01 13:13:17 -07:00
parent 29ddcbe88f
commit 47a0aa9756
5 changed files with 170 additions and 78 deletions

View File

@ -1,6 +1,6 @@
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { type Account } from './api'; import { type Account } from './api';
import type { Seal, SealKey, AccountStatus } from './types'; import type { AccountStatus } from './types';
export class AccountModule implements Account { export class AccountModule implements Account {
@ -36,19 +36,23 @@ export class AccountModule implements Account {
public async setSearchable(flag: boolean): Promise<void> { public async setSearchable(flag: boolean): Promise<void> {
} }
public async enableMFA(): Promise<void> { public async enableMFA(): Promise<{ secretImage: string, secretText: string }> {
return { secretImage: '', secretText: '' };
} }
public async disableMFA(): Promise<void> { public async disableMFA(): Promise<void> {
} }
public async confirmMFA(): Promise<void> { public async confirmMFA(code: string): Promise<void> {
} }
public async setAccountSeal(seal: Seal, key: SealKey): Promise<void> { public async setAccountSeal(password: string): Promise<void> {
} }
public async unlockAccountSeal(key: SealKey): Promise<void> { public async clearAccountSeal(): Promise<void> {
}
public async unlockAccountSeal(password: string): Promise<void> {
} }
public async setLogin(username: string, password: string): Promise<void> { public async setLogin(username: string, password: string): Promise<void> {

View File

@ -5,7 +5,6 @@
// articles share by cards now // articles share by cards now
import type { Channel, Topic, Asset, Tag, Article, Group, Card, Profile, AccountStatus, NodeConfig, NodeAccount, Repeater } from './types'; import type { Channel, Topic, Asset, Tag, Article, Group, Card, Profile, AccountStatus, NodeConfig, NodeAccount, Repeater } from './types';
import type { Seal, SealKey, SignedMessage, ContactStatus } from './types';
export interface SqlStore { export interface SqlStore {
set(stmt: string, params: (string | number)[]): Promise<void>; set(stmt: string, params: (string | number)[]): Promise<void>;
@ -28,29 +27,21 @@ export interface Session {
getContent(): Content; getContent(): Content;
resync(): void; resync(): void;
addStatusListener(ev: (status: string) => void): void; addStatusListener(ev: (status: string) => void): void;
removeStatusListener(ev: (status: string) => void): void; removeStatusListener(ev: (status: string) => void): void;
} }
export interface Node {
getAccounts(): Promise<NodeAccount[]>;
createAccountAccess(): Promise<string>;
resetAccountAccess(): Promise<string>;
blockAccount(flag: boolean): Promise<void>;
removeAccount(accountId: number): Promise<void>;
getConfig(): Promise<NodeConfig>;
setConfig(config: NodeConfig): Promise<void>;
}
export interface Account { export interface Account {
setLogin(username: string, password: string): Promise<void>;
setNotifications(flag: boolean): Promise<void>; setNotifications(flag: boolean): Promise<void>;
setSearchable(flag: boolean): Promise<void>; setSearchable(flag: boolean): Promise<void>;
enableMFA(): Promise<void>; enableMFA(): Promise<{ secretImage: string, secretText: string }>;
disableMFA(): Promise<void>; disableMFA(): Promise<void>;
confirmMFA(): Promise<void>; confirmMFA(code: string): Promise<void>;
setAccountSeal(seal: Seal, key: SealKey): Promise<void> setAccountSeal(password: string): Promise<void>;
unlockAccountSeal(key: SealKey): Promise<void> clearAccountSeal(): Promise<void>;
setLogin(username: string, password: string): Promise<void> unlockAccountSeal(password: string): Promise<void>;
addStatusListener(ev: (status: AccountStatus) => void): void; addStatusListener(ev: (status: AccountStatus) => void): void;
removeStatusListener(ev: (status: AccountStatus) => void): void; removeStatusListener(ev: (status: AccountStatus) => void): void;
@ -66,24 +57,46 @@ export interface Identity {
} }
export interface Contact { export interface Contact {
addCard(message: SignedMessage): Promise<string>; addCard(server: string, guid: string): Promise<string>;
removeCard(cardId: string): Promise<void>; removeCard(cardId: string): Promise<void>;
setCardConnecting(cardId: string): Promise<void>; confirmCard(cardId: string): Promise<void>;
setCardConnected(cardId: string, token: string, rev: number): Promise<void>; connectCard(cardId: string): Promise<void>;
setCardConfirmed(cardId: string): Promise<void>; disconnectCard(cardId: string): Promise<void>;
getCardOpenMessage(cardId: string): Promise<SignedMessage>; rejectCard(cardId: string): Promise<void>;
setCardOpenMessage(server: string, message: SignedMessage): Promise<ContactStatus>; ignoreCard(cardId: string): Promise<void>;
getCardCloseMessage(cardId: string): Promise<SignedMessage>;
setCardCloseMessage(server: string, message: SignedMessage): Promise<void>; resyncCard(cardId: string): Promise<void>;
flagCard(cardId: string): Promise<void>;
flagArticle(cardId: string, articleId: string): Promise<void>;
flagChannel(cardId: string, channelId: string): Promise<void>;
flagTopic(cardId: string, channelId: string, topicId: string): Promise<void>;
flagTag(cardId: string, channelId: string, topicId: string, tagId: string): Promise<void>;
setBlockCard(cardId: string): Promise<void>;
setBlockArticle(cardId: string, articleId: string): Promise<void>;
setBlockChannel(cardId: string, channelId: string): Promise<void>;
setBlockTopic(cardId: string, channelId: string, topicId: string): Promise<void>;
setBlockTag(cardId: string, channelId: string, topicId: string, tagId: string): Promise<void>;
clearBlockCard(cardId: string): Promise<void>;
clearBlockArticle(cardId: string, articleId: string): Promise<void>;
clearBlockChannel(cardId: string, channelId: string): Promise<void>;
clearBlockTopic(cardId: string, channelId: string, topicId: string): Promise<void>;
clearBlockTag(cardId: string, channelId: string, topicId: string, tagId: string): Promise<void>;
getBlockedCards(): Promise<{ cardId: string }[]>;
getBlockedChannels(): Promise<{ cardId: string, channelId: string }[]>;
getBlockedTopics(): Promise<{ cardId: string, channelId: string, topicId: string }[]>;
getBlockedTags(): Promise<{ cardId: string, channelId: string, topicId: string, tagId: string }[]>;
getBlockedArticles(): Promise<{ cardId: string, articleId: string }[]>;
removeArticle(cardId: string, articleId: string): Promise<void>;
removeChannel(cardId: string, channelId: string): Promise<void>; removeChannel(cardId: string, channelId: string): Promise<void>;
addTopic(cardId: string, channelId: string, type: string, message: string, assets: Asset[]): Promise<string>; addTopic(cardId: string, channelId: string, type: string, message: string, assets: Asset[]): Promise<string>;
removeTopic(cardId: string, channelId: string, topicId: string): Promise<void>; removeTopic(cardId: string, channelId: string, topicId: string): Promise<void>;
setTopicSubject(cardId: string, channelId: string, topicId: string, type: string, value: string): Promise<void>;
addTag(cardId: string, channelId: string, topicId: string, type: string, value: string): Promise<string>; addTag(cardId: string, channelId: string, topicId: string, type: string, value: string): Promise<string>;
removeTag(cardId: string, tagId: string): Promise<void>; removeTag(cardId: string, tagId: string): Promise<void>;
setTopicSubject(cardId: string, channelId: string, topicId: string, type: string, subject: string): Promise<void>;
resyncCard(cardId: string): Promise<void>;
getTopicAssetUrl(cardId: string, channelId: string, topicId: string, assetId: string): string;
getCardImageUrl(cardId: string): string; getCardImageUrl(cardId: string): string;
getTopicAssetUrl(cardId: string, channelId: string, topicId: string, assetId: string): string;
addRepeaterAccess(cardId: string, channelId: string, name: string): Promise<Repeater>; addRepeaterAccess(cardId: string, channelId: string, name: string): Promise<Repeater>;
removeRepeaterAccess(cardId: string, channelId: string, repeaterId: string): Promise<void>; removeRepeaterAccess(cardId: string, channelId: string, repeaterId: string): Promise<void>;
@ -132,6 +145,15 @@ export interface Content {
removeTag(channelId: string, topicId: string, tagId: string): Promise<void>; removeTag(channelId: string, topicId: string, tagId: string): Promise<void>;
getTopicAssetUrl(channelId: string, topicId: string, assetId: string): string; getTopicAssetUrl(channelId: string, topicId: string, assetId: string): string;
flagTopic(channelId: string, topicId: string): Promise<void>;
flagTag(channelId: string, topicId: string, tagId: string): Promise<void>;
setBlockTopic(channelId: string, topicId: string): Promise<void>;
setBlockTag(channelId: string, topicId: string, tagId: string): Promise<void>;
clearBlockTopic(channelId: string, topicId: string): Promise<void>;
clearBlockTag(channelId: string, topicId: string, tagId: string): Promise<void>;
getBlockedTopics(): Promise<{ channelId: string, topicId: string }[]>;
getBlockedTags(): Promise<{ channelId: string, topicId: string, tagId: string }[]>;
addRepeaterAccess(channelId: string, name: string): Promise<Repeater>; addRepeaterAccess(channelId: string, name: string): Promise<Repeater>;
removeRepeaterAccess(channelId: string, repeaterId: string): Promise<void>; removeRepeaterAccess(channelId: string, repeaterId: string): Promise<void>;
@ -139,6 +161,16 @@ export interface Content {
removeChannelListener(ev: (channels: Channel[]) => void): void; removeChannelListener(ev: (channels: Channel[]) => void): void;
} }
export interface Node {
getAccounts(): Promise<NodeAccount[]>;
createAccountAccess(): Promise<string>;
resetAccountAccess(): Promise<string>;
blockAccount(flag: boolean): Promise<void>;
removeAccount(accountId: number): Promise<void>;
getConfig(): Promise<NodeConfig>;
setConfig(config: NodeConfig): Promise<void>;
}
export interface Bot { export interface Bot {
addTopic(server: string, token: string, type: string, message: string, assets: Asset[]): Promise<string>; addTopic(server: string, token: string, type: string, message: string, assets: Asset[]): Promise<string>;
removeTopic(server: string, token: string, topicId: string): Promise<void>; removeTopic(server: string, token: string, topicId: string): Promise<void>;

View File

@ -1,6 +1,6 @@
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { type Contact } from './api'; import { type Contact } from './api';
import { type Card, type Topic, type SignedMessage, type ContactStatus, type Asset, type Repeater} from './types'; import { type Card, type Topic, type Asset, type Repeater} from './types';
export class ContactModule implements Contact { export class ContactModule implements Contact {
@ -30,35 +30,97 @@ export class ContactModule implements Contact {
public async resync(): Promise<void> { public async resync(): Promise<void> {
} }
public async addCard(message: SignedMessage): Promise<string> { public async addCard(server: string, guid: string): Promise<string> {
return ''; return '';
} }
public async removeCard(cardId: string): Promise<void> { public async removeCard(cardId: string): Promise<void> {
} }
public async setCardConnecting(cardId: string): Promise<void> { public async confirmCard(cardId: string): Promise<void> {
} }
public async setCardConnected(cardId: string, token: string, rev: number): Promise<void> { public async connectCard(cardId: string): Promise<void> {
} }
public async setCardConfirmed(cardId: string): Promise<void> { public async disconnectCard(cardId: string): Promise<void> {
} }
public async getCardOpenMessage(cardId: string): Promise<SignedMessage> { public async rejectCard(cardId: string): Promise<void> {
return { message: '', keyType: '', publicKey: '', signature: '', signatureType: '' };
} }
public async setCardOpenMessage(server: string, message: SignedMessage): Promise<ContactStatus> { public async ignoreCard(cardId: string): Promise<void> {
return { token: '', profileRevision: 0, articleRevision: 0, channelRevision: 0, viewRevision: 0, status: '' };
}
public async getCardCloseMessage(cardId: string): Promise<SignedMessage> {
return { message: '', keyType: '', publicKey: '', signature: '', signatureType: '' };
} }
public async setCardCloseMessage(server: string, message: SignedMessage): Promise<void> { public async resyncCard(cardId: string): Promise<void> {
}
public async flagCard(cardId: string): Promise<void> {
}
public async flagArticle(cardId: string, articleId: string): Promise<void> {
}
public async flagChannel(cardId: string, channelId: string): Promise<void> {
}
public async flagTopic(cardId: string, channelId: string, topicId: string): Promise<void> {
}
public async flagTag(cardId: string, channelId: string, topicId: string, tagId: string): Promise<void> {
}
public async setBlockCard(cardId: string): Promise<void> {
}
public async setBlockArticle(cardId: string, articleId: string): Promise<void> {
}
public async setBlockChannel(cardId: string, channelId: string): Promise<void> {
}
public async setBlockTopic(cardId: string, channelId: string, topicId: string): Promise<void> {
}
public async setBlockTag(cardId: string, channelId: string, topicId: string, tagId: string): Promise<void> {
}
public async clearBlockCard(cardId: string): Promise<void> {
}
public async clearBlockArticle(cardId: string, articleId: string): Promise<void> {
}
public async clearBlockChannel(cardId: string, channelId: string): Promise<void> {
}
public async clearBlockTopic(cardId: string, channelId: string, topicId: string): Promise<void> {
}
public async clearBlockTag(cardId: string, channelId: string, topicId: string, tagId: string): Promise<void> {
}
public async getBlockedCards(): Promise<{ cardId: string }[]> {
return [];
}
public async getBlockedChannels(): Promise<{ cardId: string, channelId: string }[]> {
return [];
}
public async getBlockedTopics(): Promise<{ cardId: string, channelId: string, topicId: string }[]> {
return [];
}
public async getBlockedTags(): Promise<{ cardId: string, channelId: string, topicId: string, tagId: string }[]> {
return [];
}
public async getBlockedArticles(): Promise<{ cardId: string, articleId: string }[]> {
return [];
}
public async removeArticle(cardId: string, articleId: string): Promise<void> {
} }
public async removeChannel(cardId: string, channelId: string): Promise<void> { public async removeChannel(cardId: string, channelId: string): Promise<void> {
@ -82,9 +144,6 @@ export class ContactModule implements Contact {
return; return;
} }
public async resyncCard(cardId: string): Promise<void> {
}
public getTopicAssetUrl(cardId: string, channelId: string, topicId: string, assetId: string): string { public getTopicAssetUrl(cardId: string, channelId: string, topicId: string, assetId: string): string {
return ''; return '';
} }

View File

@ -59,9 +59,11 @@ export class ContentModule implements Content {
public async removeTopic(channelId: string, topicId: string): Promise<void> { public async removeTopic(channelId: string, topicId: string): Promise<void> {
} }
public async setTopicSubject(channelId: string, topicId: string, type: string, subject: string): Promise<void> { public async flagTopic(channelId: string, topicId: string): Promise<void> {
} }
public async setTopicSubject(channelId: string, topicId: string, type: string, subject: string): Promise<void> {
}
public async addTag(channelId: string, topicId: string, type: string, value: string): Promise<string> { public async addTag(channelId: string, topicId: string, type: string, value: string): Promise<string> {
return ''; return '';
@ -70,6 +72,29 @@ export class ContentModule implements Content {
public async removeTag(channelId: string, topicId: string, tagId: string): Promise<void> { public async removeTag(channelId: string, topicId: string, tagId: string): Promise<void> {
} }
public async flagTag(channelId: string, topicId: string, tagId: string): Promise<void> {
}
public async setBlockTopic(channelId: string, topicId: string): Promise<void> {
}
public async setBlockTag(channelId: string, topicId: string, tagId: string): Promise<void> {
}
public async clearBlockTopic(channelId: string, topicId: string): Promise<void> {
}
public async clearBlockTag(channelId: string, topicId: string, tagId: string): Promise<void> {
}
public async getBlockedTopics(): Promise<{ channelId: string, topicId: string }[]> {
return [];
}
public async getBlockedTags(): Promise<{ channelId: string, topicId: string, tagId: string }[]> {
return [];
}
public getTopicAssetUrl(channelId: string, topicId: string, assetId: string): string { public getTopicAssetUrl(channelId: string, topicId: string, assetId: string): string {
return ''; return '';
} }

View File

@ -158,32 +158,4 @@ export type NodeConfig = {
openAccessLimit: number, openAccessLimit: number,
} }
export type SealKey = {
publicKey: string,
privateKey: string,
}
export type Seal = {
passwordSalt: string,
privateKeyIv: string,
privateKeyEncrypted: string,
publicKey: string,
}
export type SignedMessage = {
message: string,
keyType: string,
publicKey: string,
signature: string,
signatureType: string,
}
export type ContactStatus = {
token: string,
profileRevision: number,
articleRevision: number,
channelRevision: number,
viewRevision: number,
status: string,
}