diff --git a/app/sdk/src/account.ts b/app/sdk/src/account.ts index 8f80ce6e..8f740f0d 100644 --- a/app/sdk/src/account.ts +++ b/app/sdk/src/account.ts @@ -1,6 +1,6 @@ import { EventEmitter } from 'events'; import { type Account } from './api'; -import type { Seal, SealKey, AccountStatus } from './types'; +import type { AccountStatus } from './types'; export class AccountModule implements Account { @@ -36,19 +36,23 @@ export class AccountModule implements Account { public async setSearchable(flag: boolean): Promise { } - public async enableMFA(): Promise { + public async enableMFA(): Promise<{ secretImage: string, secretText: string }> { + return { secretImage: '', secretText: '' }; } public async disableMFA(): Promise { } - public async confirmMFA(): Promise { + public async confirmMFA(code: string): Promise { } - public async setAccountSeal(seal: Seal, key: SealKey): Promise { + public async setAccountSeal(password: string): Promise { } - public async unlockAccountSeal(key: SealKey): Promise { + public async clearAccountSeal(): Promise { + } + + public async unlockAccountSeal(password: string): Promise { } public async setLogin(username: string, password: string): Promise { diff --git a/app/sdk/src/api.ts b/app/sdk/src/api.ts index 1e14eca8..6a2249be 100644 --- a/app/sdk/src/api.ts +++ b/app/sdk/src/api.ts @@ -5,7 +5,6 @@ // articles share by cards now 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 { set(stmt: string, params: (string | number)[]): Promise; @@ -28,29 +27,21 @@ export interface Session { getContent(): Content; resync(): void; + addStatusListener(ev: (status: string) => void): void; removeStatusListener(ev: (status: string) => void): void; } -export interface Node { - getAccounts(): Promise; - createAccountAccess(): Promise; - resetAccountAccess(): Promise; - blockAccount(flag: boolean): Promise; - removeAccount(accountId: number): Promise; - getConfig(): Promise; - setConfig(config: NodeConfig): Promise; -} - export interface Account { + setLogin(username: string, password: string): Promise; setNotifications(flag: boolean): Promise; setSearchable(flag: boolean): Promise; - enableMFA(): Promise; + enableMFA(): Promise<{ secretImage: string, secretText: string }>; disableMFA(): Promise; - confirmMFA(): Promise; - setAccountSeal(seal: Seal, key: SealKey): Promise - unlockAccountSeal(key: SealKey): Promise - setLogin(username: string, password: string): Promise + confirmMFA(code: string): Promise; + setAccountSeal(password: string): Promise; + clearAccountSeal(): Promise; + unlockAccountSeal(password: string): Promise; addStatusListener(ev: (status: AccountStatus) => void): void; removeStatusListener(ev: (status: AccountStatus) => void): void; @@ -66,24 +57,46 @@ export interface Identity { } export interface Contact { - addCard(message: SignedMessage): Promise; + addCard(server: string, guid: string): Promise; removeCard(cardId: string): Promise; - setCardConnecting(cardId: string): Promise; - setCardConnected(cardId: string, token: string, rev: number): Promise; - setCardConfirmed(cardId: string): Promise; - getCardOpenMessage(cardId: string): Promise; - setCardOpenMessage(server: string, message: SignedMessage): Promise; - getCardCloseMessage(cardId: string): Promise; - setCardCloseMessage(server: string, message: SignedMessage): Promise; + confirmCard(cardId: string): Promise; + connectCard(cardId: string): Promise; + disconnectCard(cardId: string): Promise; + rejectCard(cardId: string): Promise; + ignoreCard(cardId: string): Promise; + + resyncCard(cardId: string): Promise; + flagCard(cardId: string): Promise; + flagArticle(cardId: string, articleId: string): Promise; + flagChannel(cardId: string, channelId: string): Promise; + flagTopic(cardId: string, channelId: string, topicId: string): Promise; + flagTag(cardId: string, channelId: string, topicId: string, tagId: string): Promise; + setBlockCard(cardId: string): Promise; + setBlockArticle(cardId: string, articleId: string): Promise; + setBlockChannel(cardId: string, channelId: string): Promise; + setBlockTopic(cardId: string, channelId: string, topicId: string): Promise; + setBlockTag(cardId: string, channelId: string, topicId: string, tagId: string): Promise; + clearBlockCard(cardId: string): Promise; + clearBlockArticle(cardId: string, articleId: string): Promise; + clearBlockChannel(cardId: string, channelId: string): Promise; + clearBlockTopic(cardId: string, channelId: string, topicId: string): Promise; + clearBlockTag(cardId: string, channelId: string, topicId: string, tagId: string): Promise; + 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; removeChannel(cardId: string, channelId: string): Promise; addTopic(cardId: string, channelId: string, type: string, message: string, assets: Asset[]): Promise; removeTopic(cardId: string, channelId: string, topicId: string): Promise; + setTopicSubject(cardId: string, channelId: string, topicId: string, type: string, value: string): Promise; addTag(cardId: string, channelId: string, topicId: string, type: string, value: string): Promise; removeTag(cardId: string, tagId: string): Promise; - setTopicSubject(cardId: string, channelId: string, topicId: string, type: string, subject: string): Promise; - resyncCard(cardId: string): Promise; - getTopicAssetUrl(cardId: string, channelId: string, topicId: string, assetId: string): string; + getCardImageUrl(cardId: string): string; + getTopicAssetUrl(cardId: string, channelId: string, topicId: string, assetId: string): string; addRepeaterAccess(cardId: string, channelId: string, name: string): Promise; removeRepeaterAccess(cardId: string, channelId: string, repeaterId: string): Promise; @@ -132,6 +145,15 @@ export interface Content { removeTag(channelId: string, topicId: string, tagId: string): Promise; getTopicAssetUrl(channelId: string, topicId: string, assetId: string): string; + flagTopic(channelId: string, topicId: string): Promise; + flagTag(channelId: string, topicId: string, tagId: string): Promise; + setBlockTopic(channelId: string, topicId: string): Promise; + setBlockTag(channelId: string, topicId: string, tagId: string): Promise; + clearBlockTopic(channelId: string, topicId: string): Promise; + clearBlockTag(channelId: string, topicId: string, tagId: string): Promise; + getBlockedTopics(): Promise<{ channelId: string, topicId: string }[]>; + getBlockedTags(): Promise<{ channelId: string, topicId: string, tagId: string }[]>; + addRepeaterAccess(channelId: string, name: string): Promise; removeRepeaterAccess(channelId: string, repeaterId: string): Promise; @@ -139,6 +161,16 @@ export interface Content { removeChannelListener(ev: (channels: Channel[]) => void): void; } +export interface Node { + getAccounts(): Promise; + createAccountAccess(): Promise; + resetAccountAccess(): Promise; + blockAccount(flag: boolean): Promise; + removeAccount(accountId: number): Promise; + getConfig(): Promise; + setConfig(config: NodeConfig): Promise; +} + export interface Bot { addTopic(server: string, token: string, type: string, message: string, assets: Asset[]): Promise; removeTopic(server: string, token: string, topicId: string): Promise; diff --git a/app/sdk/src/contact.ts b/app/sdk/src/contact.ts index 21024732..a47c2ec4 100644 --- a/app/sdk/src/contact.ts +++ b/app/sdk/src/contact.ts @@ -1,6 +1,6 @@ import { EventEmitter } from 'events'; 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 { @@ -30,35 +30,97 @@ export class ContactModule implements Contact { public async resync(): Promise { } - public async addCard(message: SignedMessage): Promise { + public async addCard(server: string, guid: string): Promise { return ''; } public async removeCard(cardId: string): Promise { } - public async setCardConnecting(cardId: string): Promise { + public async confirmCard(cardId: string): Promise { } - public async setCardConnected(cardId: string, token: string, rev: number): Promise { + public async connectCard(cardId: string): Promise { } - public async setCardConfirmed(cardId: string): Promise { + public async disconnectCard(cardId: string): Promise { } - public async getCardOpenMessage(cardId: string): Promise { - return { message: '', keyType: '', publicKey: '', signature: '', signatureType: '' }; + public async rejectCard(cardId: string): Promise { } - public async setCardOpenMessage(server: string, message: SignedMessage): Promise { - return { token: '', profileRevision: 0, articleRevision: 0, channelRevision: 0, viewRevision: 0, status: '' }; - } - - public async getCardCloseMessage(cardId: string): Promise { - return { message: '', keyType: '', publicKey: '', signature: '', signatureType: '' }; + public async ignoreCard(cardId: string): Promise { } - public async setCardCloseMessage(server: string, message: SignedMessage): Promise { + public async resyncCard(cardId: string): Promise { + } + + public async flagCard(cardId: string): Promise { + } + + public async flagArticle(cardId: string, articleId: string): Promise { + } + + public async flagChannel(cardId: string, channelId: string): Promise { + } + + public async flagTopic(cardId: string, channelId: string, topicId: string): Promise { + } + + public async flagTag(cardId: string, channelId: string, topicId: string, tagId: string): Promise { + } + + public async setBlockCard(cardId: string): Promise { + } + + public async setBlockArticle(cardId: string, articleId: string): Promise { + } + + public async setBlockChannel(cardId: string, channelId: string): Promise { + } + + public async setBlockTopic(cardId: string, channelId: string, topicId: string): Promise { + } + + public async setBlockTag(cardId: string, channelId: string, topicId: string, tagId: string): Promise { + } + + public async clearBlockCard(cardId: string): Promise { + } + + public async clearBlockArticle(cardId: string, articleId: string): Promise { + } + + public async clearBlockChannel(cardId: string, channelId: string): Promise { + } + + public async clearBlockTopic(cardId: string, channelId: string, topicId: string): Promise { + } + + public async clearBlockTag(cardId: string, channelId: string, topicId: string, tagId: string): Promise { + } + + 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 { } public async removeChannel(cardId: string, channelId: string): Promise { @@ -82,9 +144,6 @@ export class ContactModule implements Contact { return; } - public async resyncCard(cardId: string): Promise { - } - public getTopicAssetUrl(cardId: string, channelId: string, topicId: string, assetId: string): string { return ''; } diff --git a/app/sdk/src/content.ts b/app/sdk/src/content.ts index a4ae4b1d..4235f671 100644 --- a/app/sdk/src/content.ts +++ b/app/sdk/src/content.ts @@ -59,9 +59,11 @@ export class ContentModule implements Content { public async removeTopic(channelId: string, topicId: string): Promise { } - public async setTopicSubject(channelId: string, topicId: string, type: string, subject: string): Promise { + public async flagTopic(channelId: string, topicId: string): Promise { } + public async setTopicSubject(channelId: string, topicId: string, type: string, subject: string): Promise { + } public async addTag(channelId: string, topicId: string, type: string, value: string): Promise { return ''; @@ -70,6 +72,29 @@ export class ContentModule implements Content { public async removeTag(channelId: string, topicId: string, tagId: string): Promise { } + public async flagTag(channelId: string, topicId: string, tagId: string): Promise { + } + + public async setBlockTopic(channelId: string, topicId: string): Promise { + } + + public async setBlockTag(channelId: string, topicId: string, tagId: string): Promise { + } + + public async clearBlockTopic(channelId: string, topicId: string): Promise { + } + + public async clearBlockTag(channelId: string, topicId: string, tagId: string): Promise { + } + + 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 { return ''; } diff --git a/app/sdk/src/types.ts b/app/sdk/src/types.ts index 50b6a4cc..5d6d9179 100644 --- a/app/sdk/src/types.ts +++ b/app/sdk/src/types.ts @@ -158,32 +158,4 @@ export type NodeConfig = { 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, -}