From 753231d622ab404f5841afc09e36a239aa1b6bfb Mon Sep 17 00:00:00 2001 From: balzack Date: Sat, 26 Oct 2024 17:14:14 -0700 Subject: [PATCH] formatting code --- app/sdk/package.json | 2 +- app/sdk/src/alias.ts | 16 ++-- app/sdk/src/api.ts | 2 +- app/sdk/src/attribute.ts | 16 ++-- app/sdk/src/connection.ts | 38 ++++---- app/sdk/src/contact.ts | 75 ++++----------- app/sdk/src/content.ts | 29 +++--- app/sdk/src/contributor.ts | 12 +-- app/sdk/src/entities.ts | 32 +++---- app/sdk/src/focus.ts | 25 +++-- app/sdk/src/identity.ts | 30 +++--- app/sdk/src/index.ts | 46 ++++----- app/sdk/src/items.ts | 32 +++---- app/sdk/src/logging.ts | 6 +- app/sdk/src/net/addAccount.ts | 12 +-- app/sdk/src/net/addAccountMFAuth.ts | 6 +- app/sdk/src/net/addCard.ts | 6 +- app/sdk/src/net/addFlag.ts | 7 +- app/sdk/src/net/base64.ts | 8 +- app/sdk/src/net/clearAccountSeal.ts | 6 +- app/sdk/src/net/clearLogin.ts | 8 +- app/sdk/src/net/fetchUtil.ts | 4 +- app/sdk/src/net/getAccountStatus.ts | 8 +- app/sdk/src/net/getAvailable.ts | 6 +- app/sdk/src/net/getCardCloseMessage.ts | 6 +- app/sdk/src/net/getCardDetail.ts | 8 +- app/sdk/src/net/getCardImageUrl.ts | 3 +- app/sdk/src/net/getCardOpenMessage.ts | 8 +- app/sdk/src/net/getCardProfile.ts | 8 +- app/sdk/src/net/getCards.ts | 10 +- app/sdk/src/net/getContactChannelDetail.ts | 8 +- .../src/net/getContactChannelNotifications.ts | 7 +- app/sdk/src/net/getContactChannelSummary.ts | 8 +- app/sdk/src/net/getContactChannels.ts | 8 +- app/sdk/src/net/getContactListing.ts | 8 +- app/sdk/src/net/getContactProfile.ts | 8 +- app/sdk/src/net/getProfile.ts | 8 +- app/sdk/src/net/getProfileImageUrl.ts | 2 +- app/sdk/src/net/getRegistryImageUrl.ts | 3 +- app/sdk/src/net/getRegistryListing.ts | 6 +- app/sdk/src/net/getUsername.ts | 8 +- app/sdk/src/net/removeAccount.ts | 6 +- app/sdk/src/net/removeAccountMFAuth.ts | 6 +- app/sdk/src/net/removeCard.ts | 6 +- app/sdk/src/net/removeContactChannel.ts | 1 - app/sdk/src/net/setAccess.ts | 6 +- app/sdk/src/net/setAccountLogin.ts | 10 +- app/sdk/src/net/setAccountMFAuth.ts | 6 +- app/sdk/src/net/setAccountNotifications.ts | 6 +- app/sdk/src/net/setAccountSeal.ts | 8 +- app/sdk/src/net/setAccountSearchable.ts | 6 +- app/sdk/src/net/setAdmin.ts | 8 +- app/sdk/src/net/setCardCloseMessage.ts | 6 +- app/sdk/src/net/setCardConfirmed.ts | 8 +- app/sdk/src/net/setCardConnected.ts | 8 +- app/sdk/src/net/setCardConnecting.ts | 8 +- app/sdk/src/net/setCardOpenMessage.ts | 8 +- app/sdk/src/net/setCardProfile.ts | 8 +- .../src/net/setContactChannelNotifications.ts | 5 +- app/sdk/src/net/setLogin.ts | 12 +-- app/sdk/src/net/setProfileData.ts | 6 +- app/sdk/src/net/setProfileImage.ts | 6 +- app/sdk/src/node.ts | 24 ++--- app/sdk/src/ring.ts | 14 +-- app/sdk/src/session.ts | 44 ++++----- app/sdk/src/settings.ts | 78 +++++++-------- app/sdk/src/store.ts | 96 ++++++++++--------- app/sdk/src/stream.ts | 14 +-- 68 files changed, 465 insertions(+), 498 deletions(-) diff --git a/app/sdk/package.json b/app/sdk/package.json index b8db5624..5c49a53d 100644 --- a/app/sdk/package.json +++ b/app/sdk/package.json @@ -10,7 +10,7 @@ ], "scripts": { "build": "tsup", - "format": "prettier --print-width 200 --write src", + "format": "prettier --single-quote true --print-width 200 --write src", "test": "jest" }, "repository": { diff --git a/app/sdk/src/alias.ts b/app/sdk/src/alias.ts index 683213ad..4a72d2a1 100644 --- a/app/sdk/src/alias.ts +++ b/app/sdk/src/alias.ts @@ -1,7 +1,7 @@ -import { EventEmitter } from "eventemitter3"; -import type { Alias, Settings, Logging } from "./api"; -import type { Group } from "./types"; -import { Store } from "./store"; +import { EventEmitter } from 'eventemitter3'; +import type { Alias, Settings, Logging } from './api'; +import type { Group } from './types'; +import { Store } from './store'; export class AliasModule implements Alias { private log: Logging; @@ -23,21 +23,21 @@ export class AliasModule implements Alias { } public addGroupListener(ev: (groups: Group[]) => void): void { - this.emitter.on("group", ev); + this.emitter.on('group', ev); } public removeGroupListener(ev: (groups: Group[]) => void): void { - this.emitter.off("group", ev); + this.emitter.off('group', ev); } public async close(): void {} public async setRevision(rev: number): Promise { - console.log("set alias revision:", rev); + console.log('set alias revision:', rev); } public async addGroup(sealed: boolean, dataType: string, subject: string, cardIds: string[]): Promise { - return ""; + return ''; } public async removeGroup(groupId: string): Promise {} diff --git a/app/sdk/src/api.ts b/app/sdk/src/api.ts index 30d01c78..2ca7bcbe 100644 --- a/app/sdk/src/api.ts +++ b/app/sdk/src/api.ts @@ -1,4 +1,4 @@ -import type { Channel, Topic, Asset, Tag, Article, Group, Card, Profile, Call, Config, NodeConfig, NodeAccount, Participant } from "./types"; +import type { Channel, Topic, Asset, Tag, Article, Group, Card, Profile, Call, Config, NodeConfig, NodeAccount, Participant } from './types'; export interface Session { getSettings(): Settings; diff --git a/app/sdk/src/attribute.ts b/app/sdk/src/attribute.ts index 3eb038d5..e8a5a855 100644 --- a/app/sdk/src/attribute.ts +++ b/app/sdk/src/attribute.ts @@ -1,7 +1,7 @@ -import { EventEmitter } from "eventemitter3"; -import type { Attribute, Settings, Logging } from "./api"; -import type { Article } from "./types"; -import { Store } from "./store"; +import { EventEmitter } from 'eventemitter3'; +import type { Attribute, Settings, Logging } from './api'; +import type { Article } from './types'; +import { Store } from './store'; export class AttributeModule implements Attribute { private log: Logging; @@ -23,21 +23,21 @@ export class AttributeModule implements Attribute { } public addCardListener(ev: (articles: Article[]) => void): void { - this.emitter.on("artcile", ev); + this.emitter.on('artcile', ev); } public removeCardListener(ev: (articles: Article[]) => void): void { - this.emitter.off("article", ev); + this.emitter.off('article', ev); } public async close(): void {} public async setRevision(rev: number): Promise { - console.log("set attribute revision:", rev); + console.log('set attribute revision:', rev); } public async addArticle(sealed: boolean, type: string, subject: string, cardIds: string[], groupIds: string[]): Promise { - return ""; + return ''; } public async removeArticle(articleId: string): Promise {} diff --git a/app/sdk/src/connection.ts b/app/sdk/src/connection.ts index 188b82c0..d1f3611c 100644 --- a/app/sdk/src/connection.ts +++ b/app/sdk/src/connection.ts @@ -1,7 +1,7 @@ -import { EventEmitter } from "eventemitter3"; -import { Logging } from "./api"; -import { Revision } from "./entities"; -import { Call } from "./types"; +import { EventEmitter } from 'eventemitter3'; +import { Logging } from './api'; +import { Revision } from './entities'; +import { Call } from './types'; export class Connection { private log: Logging; @@ -24,47 +24,47 @@ export class Connection { } public addRevisionListener(ev: (revision: Revision) => void): void { - this.emitter.on("revision", ev); + this.emitter.on('revision', ev); } public removeRevisionListener(ev: (revision: Revision) => void): void { - this.emitter.off("revision", ev); + this.emitter.off('revision', ev); } public addRingListener(ev: (call: Call) => void): void { - this.emitter.on("call", ev); + this.emitter.on('call', ev); } public removeRingListener(ev: (call: Call) => void): void { - this.emitter.off("call", ev); + this.emitter.off('call', ev); } public addStatusListener(ev: (status: string) => void): void { - this.emitter.on("status", ev); + this.emitter.on('status', ev); } public removeStatusListener(ev: (status: string) => void): void { - this.emitter.off("status", ev); + this.emitter.off('status', ev); } private setWebSocket(token: string, node: string, secure: boolean): WebSocket { if (this.closed) { - this.emitter.emit("status", "closed"); + this.emitter.emit('status', 'closed'); return this.websocket; } - this.emitter.emit("status", "connecting"); - const wsUrl = `ws${secure ? "s" : ""}://${node}/status?mode=ring`; + this.emitter.emit('status', 'connecting'); + const wsUrl = `ws${secure ? 's' : ''}://${node}/status?mode=ring`; const ws = new WebSocket(wsUrl); ws.onmessage = (e) => { try { - if (e.data === "") { + if (e.data === '') { this.close(); } const activity = JSON.parse(e.data); - this.emitter.emit("status", "connected"); + this.emitter.emit('status', 'connected'); if (activity.revision) { - this.emitter.emit("revision", activity.revision as Revision); + this.emitter.emit('revision', activity.revision as Revision); } else if (activity.ring) { const { cardId, callId, calleeToken, ice, iceUrl, iceUsername, icePassword } = activity.ring; const call: Call = { @@ -81,9 +81,9 @@ export class Connection { }, ], }; - this.emitter.emit("call", call); + this.emitter.emit('call', call); } else { - this.emitter.emit("revision", activity as Revision); + this.emitter.emit('revision', activity as Revision); } } catch (err) { console.log(err); @@ -92,7 +92,7 @@ export class Connection { }; ws.onclose = (e) => { console.log(e); - this.emitter.emit("status", "disconnected"); + this.emitter.emit('status', 'disconnected'); setTimeout(() => { if (ws != null) { ws.onmessage = () => {}; diff --git a/app/sdk/src/contact.ts b/app/sdk/src/contact.ts index 16085cc0..368c0613 100644 --- a/app/sdk/src/contact.ts +++ b/app/sdk/src/contact.ts @@ -4,16 +4,7 @@ import { Logging } from './logging'; import { FocusModule } from './focus'; import type { Card, Channel, Article, Topic, Asset, Tag, Profile, Participant } from './types'; import { type CardEntity, avatar } from './entities'; -import type { - ArticleDetail, - ChannelSummary, - ChannelDetail, - CardProfile, - CardDetail, - CardItem, - ChannelItem, - ArticleItem, -} from './items'; +import type { ArticleDetail, ChannelSummary, ChannelDetail, CardProfile, CardDetail, CardItem, ChannelItem, ArticleItem } from './items'; import { defaultCardItem, defaultChannelItem } from './items'; import { Store } from './store'; import { Crypto } from './crypto'; @@ -112,9 +103,9 @@ export class ContactModule implements Contact { private async init() { const { guid } = this; this.revision = await this.store.getContactRevision(guid); - + const values = await this.store.getMarkers(guid); - values.forEach(value => { + values.forEach((value) => { this.markers.add(value); }); @@ -124,11 +115,10 @@ export class ContactModule implements Contact { const articles = this.articleEntries.get(cardId); const article = this.setArticle(cardId, articleId, item); if (!articles) { - const entries = new Map(); + const entries = new Map(); this.articleEntries.set(cardId, entries); entries.set(articleId, { item, article }); - } - else { + } else { articles.set(articleId, { item, article }); } }); @@ -137,13 +127,12 @@ export class ContactModule implements Contact { const channels = await this.store.getContactCardChannels(guid); channels.forEach(({ cardId, channelId, item }) => { const channels = this.channelEntries.get(cardId); - const channel = this.setChannel(cardId, channelId, item) + const channel = this.setChannel(cardId, channelId, item); if (!channels) { - const entries = new Map(); + const entries = new Map(); this.channelEntries.set(cardId, entries); entries.set(channelId, { item, channel }); - } - else { + } else { channels.set(channelId, { item, channel }); } }); @@ -176,20 +165,20 @@ export class ContactModule implements Contact { } private isMarked(marker: string, cardId: string | null, channelId: string | null, topicId: string | null, tagId: string | null): boolean { - const value = `${marker}::${cardId}::${channelId}::${topicId}::${tagId}` + const value = `${marker}::${cardId}::${channelId}::${topicId}::${tagId}`; return this.markers.has(value); } private async setMarker(marker: string, cardId: string | null, channelId: string | null, topicId: string | null, tagId: string | null) { - const value = `${marker}::${cardId}::${channelId}::${topicId}::${tagId}` + const value = `${marker}::${cardId}::${channelId}::${topicId}::${tagId}`; this.markers.add(value); await this.store.setMarker(this.guid, value); } private async clearMarker(marker: string, cardId: string | null, channelId: string | null, topicId: string | null, tagId: string | null) { - const value = `${marker}::${cardId}::${channelId}::${topicId}::${tagId}` + const value = `${marker}::${cardId}::${channelId}::${topicId}::${tagId}`; this.markers.delete(value); - await this.store.clearMarker(this.guid, value); + await this.store.clearMarker(this.guid, value); } private isCardBlocked(cardId: string): boolean { @@ -214,7 +203,7 @@ export class ContactModule implements Contact { private async clearChannelBlocked(cardId: string, channelId: string) { await this.clearMarker('blocked', cardId, channelId, null, null); - } + } private isArticleBlocked(cardId: string, articleId: string): boolean { return this.isMarked('blocked', cardId, articleId, null, null); @@ -468,7 +457,7 @@ export class ContactModule implements Contact { const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server); } - private async syncChannels(cardId: string, card: { guid: string, node: string, token: string }, revision: number): Promise { + private async syncChannels(cardId: string, card: { guid: string; node: string; token: string }, revision: number): Promise { const { guid, node, secure, token, channelTypes } = this; const server = card.node ? card.node : node; const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server); @@ -537,8 +526,6 @@ export class ContactModule implements Contact { } } - - public addCardListener(ev: (cards: Card[]) => void): void { this.emitter.on('card', ev); const cards = Array.from(this.cardEntries, ([cardId, entry]) => entry.card); @@ -618,8 +605,6 @@ export class ContactModule implements Contact { this.emitter.emit(`channel::${cardId}`, { cardId, channels }); } - - public async setFocus(cardId: string, channelId: string): Promise { if (this.focus) { await this.focus.close(); @@ -644,8 +629,6 @@ export class ContactModule implements Contact { this.focus = null; } - - public async addCard(server: string | null, guid: string): Promise { const { node, secure, token } = this; const insecure = server ? /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server) : false; @@ -731,7 +714,6 @@ export class ContactModule implements Contact { } } - public async removeArticle(cardId: string, articleId: string): Promise {} public async removeChannel(cardId: string, channelId: string): Promise { @@ -743,8 +725,6 @@ export class ContactModule implements Contact { } } - - public async getBlockedCards(): Promise { return Array.from(this.cardEntries.entries()) .filter(([key, value]) => this.isCardBlocked(key)) @@ -757,7 +737,7 @@ export class ContactModule implements Contact { const cardChannels = Array.from(card.entries()) .filter(([key, value]) => this.isChannelBlocked(cardId, key)) .map(([key, value]) => value.channel); - cardChannels.forEach(channel => { + cardChannels.forEach((channel) => { channels.push(channel); }); }); @@ -802,8 +782,6 @@ export class ContactModule implements Contact { } } - - public async flagCard(cardId: string): Promise { const entry = this.cardEntries.get(cardId); if (entry) { @@ -831,8 +809,6 @@ export class ContactModule implements Contact { } } - - public async setUnreadChannel(cardId: string, channelId: string, unread: boolean): Promise { const entries = this.channelEntries.get(cardId); if (entries) { @@ -840,8 +816,7 @@ export class ContactModule implements Contact { if (entry) { if (unread) { await this.setChannelUnread(cardId, channelId); - } - else { + } else { await this.clearChannelUnread(cardId, channelId); } entry.channel = this.setChannel(cardId, channelId, entry.item); @@ -850,8 +825,6 @@ export class ContactModule implements Contact { } } - - public async getChannelNotifications(cardId: string, channelId: string): Promise { const entry = this.cardEntries.get(cardId); if (entry) { @@ -871,13 +844,10 @@ export class ContactModule implements Contact { } } - - - public async getRegistry(handle: string | null, server: string | null): Promise { const { node, secure } = this; const insecure = server ? /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server) : false; - const listing = server ? await getRegistryListing(handle, server, !insecure) : await getRegistryListing(handle, node, secure) + const listing = server ? await getRegistryListing(handle, server, !insecure) : await getRegistryListing(handle, node, secure); return listing.map((entity) => { return { guid: entity.guid, @@ -888,13 +858,12 @@ export class ContactModule implements Contact { node: entity.node, version: entity.version, sealSet: Boolean(entity.seal), - imageUrl: entity.imageSet ? server ? getRegistryImageUrl(server, true, entity.guid) : getRegistryImageUrl(node, secure, entity.guid) : avatar, + imageUrl: entity.imageSet ? (server ? getRegistryImageUrl(server, true, entity.guid) : getRegistryImageUrl(node, secure, entity.guid)) : avatar, imageSet: entity.imageSet, }; }); } - private setCard(cardId: string, item: CardItem): Card { const { node, secure, token } = this; const { profile, detail } = item; @@ -960,12 +929,10 @@ export class ContactModule implements Contact { enableAudio: detail.enableAudio, enableVideo: detail.enableVideo, enableBinary: detail.enableBinary, - members: detail.members.map(guid => ({ guid })), + members: detail.members.map((guid) => ({ guid })), }; } - - public async setSeal(seal: { privateKey: string; publicKey: string } | null) { this.seal = seal; this.unsealAll = true; @@ -973,7 +940,7 @@ export class ContactModule implements Contact { } private async getChannelKey(seals: [{ publicKey: string; sealedKey: string }]): Promise { - const seal = seals.find(({ publicKey }) => (this.seal && publicKey === this.seal.publicKey)); + const seal = seals.find(({ publicKey }) => this.seal && publicKey === this.seal.publicKey); if (seal && this.crypto && this.seal) { const key = await this.crypto.rsaDecrypt(seal.sealedKey, this.seal.privateKey); return key.data; @@ -1022,8 +989,6 @@ export class ContactModule implements Contact { return false; } - - private async getCardEntry(cardId: string) { const { guid } = this; const entry = this.cardEntries.get(cardId); diff --git a/app/sdk/src/content.ts b/app/sdk/src/content.ts index 61fc471f..d4ff90a6 100644 --- a/app/sdk/src/content.ts +++ b/app/sdk/src/content.ts @@ -1,9 +1,9 @@ -import { EventEmitter } from "eventemitter3"; -import type { Content, Settings, Logging, Focus } from "./api"; +import { EventEmitter } from 'eventemitter3'; +import type { Content, Settings, Logging, Focus } from './api'; import { FocusModule } from './focus'; -import type { Channel, Topic, Asset, Tag, Participant } from "./types"; -import { Store } from "./store"; -import { Crypto } from "./crypto"; +import type { Channel, Topic, Asset, Tag, Participant } from './types'; +import { Store } from './store'; +import { Crypto } from './crypto'; export class ContentModule implements Content { private log: Logging; @@ -31,21 +31,21 @@ export class ContentModule implements Content { } public addChannelListener(ev: (channels: Channel[]) => void): void { - this.emitter.on("channel", ev); + this.emitter.on('channel', ev); } public removeChannelListener(ev: (channels: Channel[]) => void): void { - this.emitter.off("channel", ev); + this.emitter.off('channel', ev); } public async close(): void {} public async setRevision(rev: number): Promise { - console.log("set content revision:", rev); + console.log('set content revision:', rev); } public async addChannel(sealed: boolean, type: string, subject: string, cardIds: string[], groupIds: string[]): Promise { - return ""; + return ''; } public async removeChannel(channelId: string): Promise {} @@ -61,7 +61,7 @@ export class ContentModule implements Content { public async clearChannelGroup(channelId: string, groupId: string): Promise {} public async addTopic(channelId: string, type: string, subject: string, assets: Asset[]): Promise { - return ""; + return ''; } public async removeTopic(channelId: string, topicId: string): Promise {} @@ -73,7 +73,7 @@ export class ContentModule implements Content { public async setTopicSort(channelId: string, topicId: string, sort: number): Promise {} public async addTag(channelId: string, topicId: string, type: string, value: string): Promise { - return ""; + return ''; } public async removeTag(channelId: string, topicId: string, tagId: string): Promise {} @@ -129,7 +129,7 @@ export class ContentModule implements Content { public async disableAddParticipant(channelId: string, memberId: string): Promise {} public getTopicAssetUrl(channelId: string, topicId: string, assetId: string): string { - return ""; + return ''; } public async getTopics(channelId: string): Promise { @@ -166,8 +166,9 @@ export class ContentModule implements Content { } public async addParticipantAccess(channelId: string, name: string): Promise { - return { id: "", guid: "", name: "", server: "", token: "" }; + return { id: '', guid: '', name: '', server: '', token: '' }; } public async removeParticipantAccess(channelId: string, repeaterId: string): Promise {} -i} + i; +} diff --git a/app/sdk/src/contributor.ts b/app/sdk/src/contributor.ts index e0d3b25b..95009c71 100644 --- a/app/sdk/src/contributor.ts +++ b/app/sdk/src/contributor.ts @@ -1,7 +1,7 @@ -import type { Contributor } from "./api"; -import type { Asset } from "./types"; -import type { Crypto } from "./crypto"; -import type { Logging } from "./logging"; +import type { Contributor } from './api'; +import type { Asset } from './types'; +import type { Crypto } from './crypto'; +import type { Logging } from './logging'; export class ContributorModule implements Contributor { private log: Logging; @@ -19,13 +19,13 @@ export class ContributorModule implements Contributor { } public async addTopic(type: string, message: string, assets: Asset[]): Promise { - return ""; + return ''; } public async removeTopic(topicId: string): Promise {} public async addTag(topicId: string, type: string, value: string): Promise { - return ""; + return ''; } public async removeTag(topicId: string, tagId: string): Promise {} diff --git a/app/sdk/src/entities.ts b/app/sdk/src/entities.ts index e71217cf..62a611aa 100644 --- a/app/sdk/src/entities.ts +++ b/app/sdk/src/entities.ts @@ -1,4 +1,4 @@ -import type { Profile } from "./types"; +import type { Profile } from './types'; export type ContactStatus = { token: string; @@ -193,20 +193,20 @@ export const defaultConfigEntity = { disabled: false, storageUsed: 0, storageAvailable: 0, - forwardingAddress: "", + forwardingAddress: '', searchable: false, allowUnsealed: false, pushEnabled: false, seal: { - passwordSalt: "", - privateKeyIv: "", - privateKeyEncrypted: "", - publicKey: "", + passwordSalt: '', + privateKeyIv: '', + privateKeyEncrypted: '', + publicKey: '', }, sealable: false, enableIce: false, mfaEnabled: false, - webPushKey: "", + webPushKey: '', }; export type ProfileEntity = { @@ -215,7 +215,7 @@ export type ProfileEntity = { name: string; description: string; location: string; - image: string, + image: string; revision: number; seal?: string; version: string; @@ -236,15 +236,15 @@ export type AccountEntity = { }; export const defaultProfileEntity = { - guid: "", - handle: "", - name: "", - description: "", - location: "", + guid: '', + handle: '', + name: '', + description: '', + location: '', image: '', revision: 0, - version: "", - node: "", + version: '', + node: '', }; export type Ringing = { @@ -273,4 +273,4 @@ export type Login = { }; export const avatar = - "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAAACXBIWXMAACxLAAAsSwGlPZapAAAP4UlEQVR42u2d63MTZ5aHz2ndZcs3jA0emFSRAEPIJBPLu0U2s7OVmUzV/MVbs1vMzE6S2Ww2koBwx7AEjO+SLal17+737AcwAQIGSy2pT/fv+eCiXMZWd5+nz3nvvLq6SgBEFQu3AEAAACAAABAAAAgAAAQAAAIAAAEAgAAAQAAAIAAAEAAACAAABAAAAgAAAQCAAABAAAAgAAAQAAAIAAAEiDb8wtdDfuD5v/l13wf+E8ctGAnywlciIiPkmYOXEFPMkp/98LMfhAMQQGW8d13qOqbjcNelnksNp/XE3H6X/7vI788lZxIxSSasTIJTcUkn4AAECGJVIy+GfNshu0Otntxp33Sp0/fv3ZYH291Xv5mh6TPpDybTPJGSbPLpn2YmlpfSBTj6U8TOcIPcvbZjam2x23S3VxrlHz6XzE9naCrNmST/rGoCEGB4b3oiIu46UmnKbft+m2rjzuDpX09ePJ6jZJx/VoWhcIIAvuJ6tGtT0S4E8+Mt55YXpqy4RQehj7QAAXzC7tBO3dzuloL/Uc8n8yenaSLFzEgCEGAwPEPVFn27X9D44f9lbmU6SzFmpAIIcCSEiF1DFVu+rxe1X8zKVH5+kuIxCxpAgHe9J7u2+a5aDNMlXZrJH8sx6iEI8BZqbfq6XAjr1f322MpM9qcsh8dNmAv0HNfQzU0nxNFPRN9UCne3jOMSoh8Z4CU2aqZUL0XnevNT+RPTFqNVAAHaDl3Z3t6TtahdeIamPz9xNp14mg2iO+UusgIwiWzWpGgXo+z/ytTy4pTFEe4qjWgboOfK3e2oRz8RFeqlu1vietGthSKYAdjumL/vRj30X+GLhZWJFDJABNiuI/pfw992Cls1EQgQ3pKfRehRRb6vIfrfVA4VH5XFCAQII56YW1vu9Rai/zButIur2+b5Wk0IEJomL/2w0XroX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ZRv0DNPHuEft2AUQIh9gBXdxol+TdDqh/uwA2jjICCml02B8Bhr09LwDDYL9t/BHgThejv0AfPzRLPgjQc3EngVa67sACVFuof4BWai0ZVIDdhof7CJSy23AHEoCJsekV0MtB9HKfAvQMxr+AbjxDh0+LsAYsoQAIMs3eAAI0OhAA6Kb17KDVvgToYNdnoJz628aDDxPgvoshMKCbe06x7xII9Q8IB32VQDLMQ+QBCLoAjosMAMJAz+urBOpCABAKOocukj9EANw6EAYct68SyMUkIBAOAbzDmgFvFMDDNFAQCjxz2M7p6OoBoaffkWAAQg8EABAAAAgAAAQAAAIAEBn+H/Hv+XmfWBrVAAAAAElFTkSuQmCC'; diff --git a/app/sdk/src/focus.ts b/app/sdk/src/focus.ts index aa090985..e927398a 100644 --- a/app/sdk/src/focus.ts +++ b/app/sdk/src/focus.ts @@ -1,8 +1,8 @@ -import { EventEmitter } from "eventemitter3"; -import type { Focus } from "./api"; -import type { Topic, Asset, Participant } from "./types"; -import type { Logging } from "./logging"; -import { Store } from "./store"; +import { EventEmitter } from 'eventemitter3'; +import type { Focus } from './api'; +import type { Topic, Asset, Participant } from './types'; +import type { Logging } from './logging'; +import { Store } from './store'; import { Crypto } from './crypto'; export class FocusModule implements Focus { @@ -13,9 +13,9 @@ export class FocusModule implements Focus { private crypto: Crypto | null; private store: Store; private guid: string; - private connection: { node: string, secure: boolean, token: string} | null; + private connection: { node: string; secure: boolean; token: string } | null; - constructor(log: Logging, store: Store, crypto: Crypto | null, cardId: string | null, channelId: string, guid: string, connection: { node: string, secure: boolean, token: string } | null) { + constructor(log: Logging, store: Store, crypto: Crypto | null, cardId: string | null, channelId: string, guid: string, connection: { node: string; secure: boolean; token: string } | null) { this.cardId = cardId; this.channelId = channelId; this.log = log; @@ -38,11 +38,10 @@ export class FocusModule implements Focus { } } - public async close() { - } + public async close() {} public async addTopic(type: string, message: string, assets: Asset[]): Promise { - return ""; + return ''; } public async removeTopic(topicId: string): Promise {} @@ -52,7 +51,7 @@ export class FocusModule implements Focus { public async setTopicSort(topicId: string, sort: number): Promise {} public async addTag(topicId: string, type: string, subject: string): Promise { - return ""; + return ''; } public async removeTag(cardId: string, tagId: string): Promise {} @@ -70,11 +69,11 @@ export class FocusModule implements Focus { public async clearUnreadChannel(cardId: string, channelId: string): Promise {} public getTopicAssetUrl(topicId: string, assetId: string): string { - return ""; + return ''; } public async addParticipantAccess(name: string): Promise { - return { id: "", name: "", node: "", secure: false, token: "" }; + return { id: '', name: '', node: '', secure: false, token: '' }; } public async removeParticipantAccess(repeaterId: string): Promise {} diff --git a/app/sdk/src/identity.ts b/app/sdk/src/identity.ts index 93fb520d..a2b94091 100644 --- a/app/sdk/src/identity.ts +++ b/app/sdk/src/identity.ts @@ -1,13 +1,13 @@ -import { EventEmitter } from "eventemitter3"; -import type { Identity } from "./api"; -import type { Logging } from "./logging"; -import type { Profile } from "./types"; -import { Store } from "./store"; -import { getProfile } from "./net/getProfile"; -import { getProfileImageUrl } from "./net/getProfileImageUrl"; -import { setProfileData } from "./net/setProfileData"; -import { setProfileImage } from "./net/setProfileImage"; -import { ProfileEntity, defaultProfileEntity, avatar } from "./entities"; +import { EventEmitter } from 'eventemitter3'; +import type { Identity } from './api'; +import type { Logging } from './logging'; +import type { Profile } from './types'; +import { Store } from './store'; +import { getProfile } from './net/getProfile'; +import { getProfileImageUrl } from './net/getProfileImageUrl'; +import { setProfileData } from './net/setProfileData'; +import { setProfileImage } from './net/setProfileImage'; +import { ProfileEntity, defaultProfileEntity, avatar } from './entities'; const CLOSE_POLL_MS = 100; const RETRY_POLL_MS = 2000; @@ -51,7 +51,7 @@ export class IdentityModule implements Identity { } else { this.imageUrl = avatar; } - this.emitter.emit("profile", this.setProfile()); + this.emitter.emit('profile', this.setProfile()); this.syncing = false; await this.sync(); } @@ -75,7 +75,7 @@ export class IdentityModule implements Identity { } else { this.imageUrl = avatar; } - this.emitter.emit("profile", this.setProfile()); + this.emitter.emit('profile', this.setProfile()); this.revision = nextRev; if (this.nextRevision === nextRev) { this.nextRevision = null; @@ -107,12 +107,12 @@ export class IdentityModule implements Identity { } public addProfileListener(ev: (profile: Profile) => void): void { - this.emitter.on("profile", ev); - this.emitter.emit("profile", this.setProfile()); + this.emitter.on('profile', ev); + this.emitter.emit('profile', this.setProfile()); } public removeProfileListener(ev: (profile: Profile) => void): void { - this.emitter.off("profile", ev); + this.emitter.off('profile', ev); } public async close(): Promise { diff --git a/app/sdk/src/index.ts b/app/sdk/src/index.ts index f185d2c9..4f89146a 100644 --- a/app/sdk/src/index.ts +++ b/app/sdk/src/index.ts @@ -1,26 +1,26 @@ -import { SessionModule } from "./session"; -import { NodeModule } from "./node"; -import { ContributorModule } from "./contributor"; -import { type Logging, ConsoleLogging } from "./logging"; -import { type Store, OfflineStore, OnlineStore, NoStore } from "./store"; -import { setLogin } from "./net/setLogin"; -import { clearLogin } from "./net/clearLogin"; -import { removeAccount } from "./net/removeAccount"; -import { setAccess } from "./net/setAccess"; -import { addAccount } from "./net/addAccount"; -import { setAdmin } from "./net/setAdmin"; -import { getAvailable } from "./net/getAvailable"; -import { getUsername } from "./net/getUsername"; -import type { Session, Node, Contributor } from "./api"; -import type { Params, SessionParams } from "./types"; -import type { Login } from "./entities"; -import type { Crypto } from "./crypto"; -import type { WebStore, SqlStore } from "./store"; +import { SessionModule } from './session'; +import { NodeModule } from './node'; +import { ContributorModule } from './contributor'; +import { type Logging, ConsoleLogging } from './logging'; +import { type Store, OfflineStore, OnlineStore, NoStore } from './store'; +import { setLogin } from './net/setLogin'; +import { clearLogin } from './net/clearLogin'; +import { removeAccount } from './net/removeAccount'; +import { setAccess } from './net/setAccess'; +import { addAccount } from './net/addAccount'; +import { setAdmin } from './net/setAdmin'; +import { getAvailable } from './net/getAvailable'; +import { getUsername } from './net/getUsername'; +import type { Session, Node, Contributor } from './api'; +import type { Params, SessionParams } from './types'; +import type { Login } from './entities'; +import type { Crypto } from './crypto'; +import type { WebStore, SqlStore } from './store'; -export * from "./api"; -export * from "./types"; -export { WebStore, SqlStore } from "./store"; -export { Crypto } from "./crypto"; +export * from './api'; +export * from './types'; +export { WebStore, SqlStore } from './store'; +export { Crypto } from './crypto'; export class DatabagSDK { private log: Logging; @@ -33,7 +33,7 @@ export class DatabagSDK { this.params = params; this.crypto = crypto ? crypto : null; this.log = log ? log : new ConsoleLogging(); - this.log.info("databag sdk"); + this.log.info('databag sdk'); } public async initOfflineStore(sql: SqlStore): Promise { diff --git a/app/sdk/src/items.ts b/app/sdk/src/items.ts index eda492c9..bd2aba44 100644 --- a/app/sdk/src/items.ts +++ b/app/sdk/src/items.ts @@ -81,19 +81,19 @@ export const defaultCardItem = { revision: 0, profile: { revision: 0, - handle: "", - guid: "", - name: "", - description: "", - location: "", + handle: '', + guid: '', + name: '', + description: '', + location: '', imageSet: false, - node: "", - version: "", - seal: "", + node: '', + version: '', + seal: '', }, detail: { revision: 0, - status: "", + status: '', statusUpdated: 0, token: 0, }, @@ -119,19 +119,19 @@ export const defaultChannelItem = { summary: { revision: 0, sealed: false, - guid: "", - dataType: "", - data: "", + guid: '', + dataType: '', + data: '', created: 0, updated: 0, - status: "", - transform: "", + status: '', + transform: '', }, detail: { revision: 0, sealed: false, - dataType: "", - data: "", + dataType: '', + data: '', created: 0, updated: 0, enableImage: false, diff --git a/app/sdk/src/logging.ts b/app/sdk/src/logging.ts index 1aaf65d5..08f97e6b 100644 --- a/app/sdk/src/logging.ts +++ b/app/sdk/src/logging.ts @@ -6,12 +6,12 @@ export interface Logging { export class ConsoleLogging implements Logging { public error(m: any): void { - console.log("error:", m); + console.log('error:', m); } public warn(m: any): void { - console.log("warn:", m); + console.log('warn:', m); } public info(m: any): void { - console.log("info:", m); + console.log('info:', m); } } diff --git a/app/sdk/src/net/addAccount.ts b/app/sdk/src/net/addAccount.ts index 48b3e460..3f45817e 100644 --- a/app/sdk/src/net/addAccount.ts +++ b/app/sdk/src/net/addAccount.ts @@ -1,12 +1,12 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { encode } from "./base64"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { encode } from './base64'; export async function addAccount(node: string, secure: boolean, username: string, password: string, token: string | null): Promise { - const access = token ? `?token=${token}` : ""; - const endpoint = `http${secure ? "s" : ""}://${node}/account/profile${access}`; + const access = token ? `?token=${token}` : ''; + const endpoint = `http${secure ? 's' : ''}://${node}/account/profile${access}`; const auth = encode(`${username}:${password}`); const headers = new Headers(); - headers.append("Credentials", `Basic ${auth}`); - const { status } = await fetchWithTimeout(endpoint, { method: "POST", headers }, 60000); + headers.append('Credentials', `Basic ${auth}`); + const { status } = await fetchWithTimeout(endpoint, { method: 'POST', headers }, 60000); checkResponse(status); } diff --git a/app/sdk/src/net/addAccountMFAuth.ts b/app/sdk/src/net/addAccountMFAuth.ts index 6dc34150..383cfcf6 100644 --- a/app/sdk/src/net/addAccountMFAuth.ts +++ b/app/sdk/src/net/addAccountMFAuth.ts @@ -1,8 +1,8 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function addAccountMFAuth(node: string, secure: boolean, token: string): Promise<{ secretText: string; secretImage: string }> { - const endpoint = `http${secure ? "s" : ""}://${node}/account/mfauth?agent=${token}`; - const auth = await fetchWithTimeout(endpoint, { method: "POST" }); + const endpoint = `http${secure ? 's' : ''}://${node}/account/mfauth?agent=${token}`; + const auth = await fetchWithTimeout(endpoint, { method: 'POST' }); checkResponse(auth.status); return await auth.json(); } diff --git a/app/sdk/src/net/addCard.ts b/app/sdk/src/net/addCard.ts index af961dda..ac1425bd 100644 --- a/app/sdk/src/net/addCard.ts +++ b/app/sdk/src/net/addCard.ts @@ -1,10 +1,10 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; import { DataMessage } from '../entities'; export async function addCard(node: string, secure: boolean, token: string, message: DataMessage) { - const endpoint = `http${secure ? "s" : ""}://${node}/contact/cards?agent=${token}`; + const endpoint = `http${secure ? 's' : ''}://${node}/contact/cards?agent=${token}`; const card = await fetchWithTimeout(endpoint, { - method: "POST", + method: 'POST', body: JSON.stringify(message), }); checkResponse(card.status); diff --git a/app/sdk/src/net/addFlag.ts b/app/sdk/src/net/addFlag.ts index 2d4e70c9..f7f5da0e 100644 --- a/app/sdk/src/net/addFlag.ts +++ b/app/sdk/src/net/addFlag.ts @@ -1,8 +1,7 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil'; -export async function addFlag(node: string, secure: boolean, guid: string, data: { channelId?: string, articleId?: string }) { - const endpoint = `http${secure ? 's' : ''}://${node}/account/flag/${guid}` - const response = await fetchWithTimeout(endpoint, { method: 'POST', body: JSON.stringify(data) } ); +export async function addFlag(node: string, secure: boolean, guid: string, data: { channelId?: string; articleId?: string }) { + const endpoint = `http${secure ? 's' : ''}://${node}/account/flag/${guid}`; + const response = await fetchWithTimeout(endpoint, { method: 'POST', body: JSON.stringify(data) }); checkResponse(response.status); } - diff --git a/app/sdk/src/net/base64.ts b/app/sdk/src/net/base64.ts index f5c920f6..6260d796 100644 --- a/app/sdk/src/net/base64.ts +++ b/app/sdk/src/net/base64.ts @@ -1,9 +1,9 @@ export function encode(input: string) { - let output = ""; + let output = ''; let chr1, chr2, chr3, enc1, enc2, enc3, enc4; let i = 0; - const _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + const _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; input = _utf8_encode(input); @@ -30,8 +30,8 @@ export function encode(input: string) { } function _utf8_encode(value: string) { - value = value.replace(/\r\n/g, "\n"); - let utftext = ""; + value = value.replace(/\r\n/g, '\n'); + let utftext = ''; for (let n = 0; n < value.length; n++) { let c = value.charCodeAt(n); diff --git a/app/sdk/src/net/clearAccountSeal.ts b/app/sdk/src/net/clearAccountSeal.ts index ceb0664c..5b9a1d06 100644 --- a/app/sdk/src/net/clearAccountSeal.ts +++ b/app/sdk/src/net/clearAccountSeal.ts @@ -1,7 +1,7 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function clearAccountSeal(node: string, secure: boolean, token: string) { - const endpoint = `http${secure ? "s" : ""}://${node}/account/seal?agent=${token}`; - const seal = await fetchWithTimeout(endpoint, { method: "DELETE" }); + const endpoint = `http${secure ? 's' : ''}://${node}/account/seal?agent=${token}`; + const seal = await fetchWithTimeout(endpoint, { method: 'DELETE' }); checkResponse(seal.status); } diff --git a/app/sdk/src/net/clearLogin.ts b/app/sdk/src/net/clearLogin.ts index 4f0c156d..59ac9395 100644 --- a/app/sdk/src/net/clearLogin.ts +++ b/app/sdk/src/net/clearLogin.ts @@ -1,8 +1,8 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function clearLogin(node: string, secure: boolean, token: string, all: boolean): Promise { - const param = all ? "&all=true" : ""; - const endpoint = `http${secure ? "s" : ""}://${node}/account/apps?agent=${token}${param}`; - const { status } = await fetchWithTimeout(endpoint, { method: "DELETE" }); + const param = all ? '&all=true' : ''; + const endpoint = `http${secure ? 's' : ''}://${node}/account/apps?agent=${token}${param}`; + const { status } = await fetchWithTimeout(endpoint, { method: 'DELETE' }); checkResponse(status); } diff --git a/app/sdk/src/net/fetchUtil.ts b/app/sdk/src/net/fetchUtil.ts index 9b9557b1..48df0cea 100644 --- a/app/sdk/src/net/fetchUtil.ts +++ b/app/sdk/src/net/fetchUtil.ts @@ -11,8 +11,8 @@ export function checkResponse(code: number) { export async function fetchWithTimeout(url: string, options: RequestInit, timeout: number = TIMEOUT): Promise { return Promise.race([ fetch(url, options).catch((err) => { - throw new Error(url + " failed"); + throw new Error(url + ' failed'); }), - new Promise((_, reject) => setTimeout(() => reject(new Error(url + " timeout")), TIMEOUT)), + new Promise((_, reject) => setTimeout(() => reject(new Error(url + ' timeout')), TIMEOUT)), ]); } diff --git a/app/sdk/src/net/getAccountStatus.ts b/app/sdk/src/net/getAccountStatus.ts index 3f6ee221..8ba37537 100644 --- a/app/sdk/src/net/getAccountStatus.ts +++ b/app/sdk/src/net/getAccountStatus.ts @@ -1,9 +1,9 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { ConfigEntity } from "../entities"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { ConfigEntity } from '../entities'; export async function getAccountStatus(node: string, secure: boolean, token: string): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/account/status?agent=${token}`; - const status = await fetchWithTimeout(endpoint, { method: "GET" }); + const endpoint = `http${secure ? 's' : ''}://${node}/account/status?agent=${token}`; + const status = await fetchWithTimeout(endpoint, { method: 'GET' }); checkResponse(status.status); return await status.json(); } diff --git a/app/sdk/src/net/getAvailable.ts b/app/sdk/src/net/getAvailable.ts index 122cb3ef..04783b18 100644 --- a/app/sdk/src/net/getAvailable.ts +++ b/app/sdk/src/net/getAvailable.ts @@ -1,8 +1,8 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function getAvailable(node: string, secure: boolean): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/account/available`; - const available = await fetchWithTimeout(endpoint, { method: "GET" }); + const endpoint = `http${secure ? 's' : ''}://${node}/account/available`; + const available = await fetchWithTimeout(endpoint, { method: 'GET' }); checkResponse(available.status); return await available.json(); } diff --git a/app/sdk/src/net/getCardCloseMessage.ts b/app/sdk/src/net/getCardCloseMessage.ts index 903946d7..e98a22b5 100644 --- a/app/sdk/src/net/getCardCloseMessage.ts +++ b/app/sdk/src/net/getCardCloseMessage.ts @@ -1,9 +1,9 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; import { DataMessage } from '../entities'; export async function getCardCloseMessage(node: string, secure: boolean, token: string, cardId: string): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/contact/cards/${cardId}/closeMessage?agent=${token}`; - const close = await fetchWithTimeout(endpoint, { method: "GET" }); + const endpoint = `http${secure ? 's' : ''}://${node}/contact/cards/${cardId}/closeMessage?agent=${token}`; + const close = await fetchWithTimeout(endpoint, { method: 'GET' }); checkResponse(close.status); return await close.json(); } diff --git a/app/sdk/src/net/getCardDetail.ts b/app/sdk/src/net/getCardDetail.ts index e9adb032..200196bc 100644 --- a/app/sdk/src/net/getCardDetail.ts +++ b/app/sdk/src/net/getCardDetail.ts @@ -1,9 +1,9 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { CardDetailEntity } from "../entities"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { CardDetailEntity } from '../entities'; export async function getCardDetail(node: string, secure: boolean, token: string, cardId: string): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/contact/cards/${cardId}/detail?agent=${token}`; - const detail = await fetchWithTimeout(endpoint, { method: "GET" }); + const endpoint = `http${secure ? 's' : ''}://${node}/contact/cards/${cardId}/detail?agent=${token}`; + const detail = await fetchWithTimeout(endpoint, { method: 'GET' }); checkResponse(detail.status); return await detail.json(); } diff --git a/app/sdk/src/net/getCardImageUrl.ts b/app/sdk/src/net/getCardImageUrl.ts index 6dd5d211..b14deb02 100644 --- a/app/sdk/src/net/getCardImageUrl.ts +++ b/app/sdk/src/net/getCardImageUrl.ts @@ -1,4 +1,3 @@ export function getCardImageUrl(node: string, secure: boolean, token: string, cardId: string, revision: number): string { - return `http${secure ? 's' : ''}://${node}/contact/cards/${cardId}/profile/image?agent=${token}&revision=${revision}` + return `http${secure ? 's' : ''}://${node}/contact/cards/${cardId}/profile/image?agent=${token}&revision=${revision}`; } - diff --git a/app/sdk/src/net/getCardOpenMessage.ts b/app/sdk/src/net/getCardOpenMessage.ts index d53fc28b..c0dcfd3b 100644 --- a/app/sdk/src/net/getCardOpenMessage.ts +++ b/app/sdk/src/net/getCardOpenMessage.ts @@ -1,9 +1,9 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { DataMessage } from "../entities"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { DataMessage } from '../entities'; export async function getCardOpenMessage(node: string, secure: boolean, token: string, cardId: string): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/contact/cards/${cardId}/openMessage?agent=${token}`; - const open = await fetchWithTimeout(endpoint, { method: "GET" }); + const endpoint = `http${secure ? 's' : ''}://${node}/contact/cards/${cardId}/openMessage?agent=${token}`; + const open = await fetchWithTimeout(endpoint, { method: 'GET' }); checkResponse(open.status); return await open.json(); } diff --git a/app/sdk/src/net/getCardProfile.ts b/app/sdk/src/net/getCardProfile.ts index 2144b22c..0aee094e 100644 --- a/app/sdk/src/net/getCardProfile.ts +++ b/app/sdk/src/net/getCardProfile.ts @@ -1,9 +1,9 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { CardProfileEntity } from "../entities"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { CardProfileEntity } from '../entities'; export async function getCardProfile(node: string, secure: boolean, token: string, cardId: string): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/contact/cards/${cardId}/profile?agent=${token}`; - const profile = await fetchWithTimeout(endpoint, { method: "GET" }); + const endpoint = `http${secure ? 's' : ''}://${node}/contact/cards/${cardId}/profile?agent=${token}`; + const profile = await fetchWithTimeout(endpoint, { method: 'GET' }); checkResponse(profile.status); return await profile.json(); } diff --git a/app/sdk/src/net/getCards.ts b/app/sdk/src/net/getCards.ts index 984db2c8..ae3e32ba 100644 --- a/app/sdk/src/net/getCards.ts +++ b/app/sdk/src/net/getCards.ts @@ -1,10 +1,10 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { CardEntity } from "../entities"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { CardEntity } from '../entities'; export async function getCards(node: string, secure: boolean, token: string, revision: number): Promise { - const param = revision ? `&revision=${revision}` : ""; - const endpoint = `http${secure ? "s" : ""}://${node}/contact/cards?agent=${token}${param}`; - const cards = await fetchWithTimeout(endpoint, { method: "GET" }); + const param = revision ? `&revision=${revision}` : ''; + const endpoint = `http${secure ? 's' : ''}://${node}/contact/cards?agent=${token}${param}`; + const cards = await fetchWithTimeout(endpoint, { method: 'GET' }); checkResponse(cards.status); return await cards.json(); } diff --git a/app/sdk/src/net/getContactChannelDetail.ts b/app/sdk/src/net/getContactChannelDetail.ts index 9cdb57f9..b85c6b3a 100644 --- a/app/sdk/src/net/getContactChannelDetail.ts +++ b/app/sdk/src/net/getContactChannelDetail.ts @@ -1,9 +1,9 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { ChannelDetailEntity } from "../entities"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { ChannelDetailEntity } from '../entities'; export async function getContactChannelDetail(server: string, secure: boolean, guid: string, token: string, channelId: string): Promise { - const endpoint = `http${secure ? "s" : ""}://${secure}/content/channels/${channelId}/detail?contact=${guid}.${token}`; - const detail = await fetchWithTimeout(endpoint, { method: "GET" }); + const endpoint = `http${secure ? 's' : ''}://${secure}/content/channels/${channelId}/detail?contact=${guid}.${token}`; + const detail = await fetchWithTimeout(endpoint, { method: 'GET' }); checkResponse(detail.status); return await detail.json(); } diff --git a/app/sdk/src/net/getContactChannelNotifications.ts b/app/sdk/src/net/getContactChannelNotifications.ts index bcad35cd..f42c8caf 100644 --- a/app/sdk/src/net/getContactChannelNotifications.ts +++ b/app/sdk/src/net/getContactChannelNotifications.ts @@ -1,9 +1,8 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function getContactChannelNotifications(node: string, secure: boolean, guid: string, token: string, channelId: string): Promise { - const endpoint = `http${secure ? 's' : ''}://${node}/content/channels/${channelId}/notification?contact=${guid}.${token}` + const endpoint = `http${secure ? 's' : ''}://${node}/content/channels/${channelId}/notification?contact=${guid}.${token}`; const notify = await fetchWithTimeout(endpoint, { method: 'GET' }); - checkResponse(notify.status) - return await notify.json() + checkResponse(notify.status); + return await notify.json(); } - diff --git a/app/sdk/src/net/getContactChannelSummary.ts b/app/sdk/src/net/getContactChannelSummary.ts index 2de39219..179dc4d2 100644 --- a/app/sdk/src/net/getContactChannelSummary.ts +++ b/app/sdk/src/net/getContactChannelSummary.ts @@ -1,9 +1,9 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { ChannelSummaryEntity } from "../entities"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { ChannelSummaryEntity } from '../entities'; export async function getContactChannelSummary(server: string, secure: boolean, guid: string, token: string, channelId: string): Promise { - const endpoint = `http${secure ? "s" : ""}://${server}/content/channels/${channelId}/summary?contact=${guid}.${token}`; - const summary = await fetchWithTimeout(endpoint, { method: "GET" }); + const endpoint = `http${secure ? 's' : ''}://${server}/content/channels/${channelId}/summary?contact=${guid}.${token}`; + const summary = await fetchWithTimeout(endpoint, { method: 'GET' }); checkResponse(summary.status); return await summary.json(); } diff --git a/app/sdk/src/net/getContactChannels.ts b/app/sdk/src/net/getContactChannels.ts index 9e241373..c5c14b85 100644 --- a/app/sdk/src/net/getContactChannels.ts +++ b/app/sdk/src/net/getContactChannels.ts @@ -1,11 +1,11 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { ChannelEntity } from "../entities"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { ChannelEntity } from '../entities'; export async function getContactChannels(node: string, secure: boolean, guid: string, token: string, revision: number, types: string[]): Promise { const type = `types=${encodeURIComponent(JSON.stringify(types))}`; const param = revision ? `viewRevision=1&channelRevision=${revision}` : `viewRevision=1`; - const endpoint = `http${secure ? "s" : ""}://${node}/content/channels?contact=${guid}.${token}&${param}&${type}`; - const channels = await fetchWithTimeout(endpoint, { method: "GET" }); + const endpoint = `http${secure ? 's' : ''}://${node}/content/channels?contact=${guid}.${token}&${param}&${type}`; + const channels = await fetchWithTimeout(endpoint, { method: 'GET' }); checkResponse(channels.status); return await channels.json(); } diff --git a/app/sdk/src/net/getContactListing.ts b/app/sdk/src/net/getContactListing.ts index 69ba7e47..97825a85 100644 --- a/app/sdk/src/net/getContactListing.ts +++ b/app/sdk/src/net/getContactListing.ts @@ -1,9 +1,9 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { DataMessage } from "../entities"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { DataMessage } from '../entities'; export async function getContactListing(node: string, secure: boolean, guid: string): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/account/listing/${guid}/message`; - const listing = await fetchWithTimeout(endpoint, { method: "GET" }); + const endpoint = `http${secure ? 's' : ''}://${node}/account/listing/${guid}/message`; + const listing = await fetchWithTimeout(endpoint, { method: 'GET' }); checkResponse(listing.status); return await listing.json(); } diff --git a/app/sdk/src/net/getContactProfile.ts b/app/sdk/src/net/getContactProfile.ts index e6245d44..89de7e1d 100644 --- a/app/sdk/src/net/getContactProfile.ts +++ b/app/sdk/src/net/getContactProfile.ts @@ -1,9 +1,9 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { DataMessage } from "../entities"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { DataMessage } from '../entities'; export async function getContactProfile(node: string, secure: boolean, guid: string, token: string): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/profile/message?contact=${guid}.${token}`; - const profile = await fetchWithTimeout(endpoint, { method: "GET" }); + const endpoint = `http${secure ? 's' : ''}://${node}/profile/message?contact=${guid}.${token}`; + const profile = await fetchWithTimeout(endpoint, { method: 'GET' }); checkResponse(profile.status); return await profile.json(); } diff --git a/app/sdk/src/net/getProfile.ts b/app/sdk/src/net/getProfile.ts index 8d660458..e05316ec 100644 --- a/app/sdk/src/net/getProfile.ts +++ b/app/sdk/src/net/getProfile.ts @@ -1,9 +1,9 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { ProfileEntity } from "../entities"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { ProfileEntity } from '../entities'; export async function getProfile(node: string, secure: boolean, token: string): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/profile?agent=${token}`; - const profile = await fetchWithTimeout(endpoint, { method: "GET" }); + const endpoint = `http${secure ? 's' : ''}://${node}/profile?agent=${token}`; + const profile = await fetchWithTimeout(endpoint, { method: 'GET' }); checkResponse(profile.status); return await profile.json(); } diff --git a/app/sdk/src/net/getProfileImageUrl.ts b/app/sdk/src/net/getProfileImageUrl.ts index fb37f507..df017a46 100644 --- a/app/sdk/src/net/getProfileImageUrl.ts +++ b/app/sdk/src/net/getProfileImageUrl.ts @@ -1,3 +1,3 @@ export function getProfileImageUrl(node: string, secure: boolean, token: string, revision: number) { - return `http${secure ? "s" : ""}://${node}/profile/image?agent=${token}&revision=${revision}`; + return `http${secure ? 's' : ''}://${node}/profile/image?agent=${token}&revision=${revision}`; } diff --git a/app/sdk/src/net/getRegistryImageUrl.ts b/app/sdk/src/net/getRegistryImageUrl.ts index 013eccda..2458446b 100644 --- a/app/sdk/src/net/getRegistryImageUrl.ts +++ b/app/sdk/src/net/getRegistryImageUrl.ts @@ -1,4 +1,3 @@ export function getRegistryImageUrl(node: string, secure: boolean, guid: string): string { - return `http${secure ? 's' : ''}://${node}/account/listing/${guid}/image` + return `http${secure ? 's' : ''}://${node}/account/listing/${guid}/image`; } - diff --git a/app/sdk/src/net/getRegistryListing.ts b/app/sdk/src/net/getRegistryListing.ts index 3279b6be..803a8f32 100644 --- a/app/sdk/src/net/getRegistryListing.ts +++ b/app/sdk/src/net/getRegistryListing.ts @@ -1,12 +1,10 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil'; -import { AccountEntity } from "../entities"; +import { AccountEntity } from '../entities'; export async function getRegistryListing(handle: string | null, server: string, secure: boolean): Promise { const param = handle ? `?filter=${handle}` : ''; - const endpoint = `http${secure ? 's' : ''}://${server}/account/listing${param}` + const endpoint = `http${secure ? 's' : ''}://${server}/account/listing${param}`; const listing = await fetchWithTimeout(endpoint, { method: 'GET' }); checkResponse(listing.status); return await listing.json(); } - - diff --git a/app/sdk/src/net/getUsername.ts b/app/sdk/src/net/getUsername.ts index ba1eca9e..db7a5573 100644 --- a/app/sdk/src/net/getUsername.ts +++ b/app/sdk/src/net/getUsername.ts @@ -1,10 +1,10 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function getUsername(name: string, token: string | null, agent: string | null, node: string, secure: boolean): Promise { - const param = token ? `&token=${token}` : agent ? `&agent=${agent}` : ""; + const param = token ? `&token=${token}` : agent ? `&agent=${agent}` : ''; const username = encodeURIComponent(name); - const endpoint = `http${secure ? "s" : ""}://${node}/account/username?name=${username}${param}`; - const taken = await fetchWithTimeout(endpoint, { method: "GET" }); + const endpoint = `http${secure ? 's' : ''}://${node}/account/username?name=${username}${param}`; + const taken = await fetchWithTimeout(endpoint, { method: 'GET' }); checkResponse(taken.status); return await taken.json(); } diff --git a/app/sdk/src/net/removeAccount.ts b/app/sdk/src/net/removeAccount.ts index 209da9d3..3026f781 100644 --- a/app/sdk/src/net/removeAccount.ts +++ b/app/sdk/src/net/removeAccount.ts @@ -1,7 +1,7 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function removeAccount(node: string, secure: boolean, token: string): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/profile?agent=${token}`; - const { status } = await fetchWithTimeout(endpoint, { method: "DELETE" }); + const endpoint = `http${secure ? 's' : ''}://${node}/profile?agent=${token}`; + const { status } = await fetchWithTimeout(endpoint, { method: 'DELETE' }); checkResponse(status); } diff --git a/app/sdk/src/net/removeAccountMFAuth.ts b/app/sdk/src/net/removeAccountMFAuth.ts index 19c1ae8d..2a783169 100644 --- a/app/sdk/src/net/removeAccountMFAuth.ts +++ b/app/sdk/src/net/removeAccountMFAuth.ts @@ -1,7 +1,7 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function removeAccountMFAuth(node: string, secure: boolean, token: string) { - const endpoint = `http${secure ? "s" : ""}://${node}/account/mfauth?agent=${token}`; - const { status } = await fetchWithTimeout(endpoint, { method: "DELETE" }); + const endpoint = `http${secure ? 's' : ''}://${node}/account/mfauth?agent=${token}`; + const { status } = await fetchWithTimeout(endpoint, { method: 'DELETE' }); checkResponse(status); } diff --git a/app/sdk/src/net/removeCard.ts b/app/sdk/src/net/removeCard.ts index 0e284ff1..6eabd44a 100644 --- a/app/sdk/src/net/removeCard.ts +++ b/app/sdk/src/net/removeCard.ts @@ -1,7 +1,7 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function removeCard(node: string, secure: boolean, token: string, cardId: string): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/contact/cards/${cardId}?agent=${token}`; - const { status } = await fetchWithTimeout(endpoint, { method: "DELETE" }); + const endpoint = `http${secure ? 's' : ''}://${node}/contact/cards/${cardId}?agent=${token}`; + const { status } = await fetchWithTimeout(endpoint, { method: 'DELETE' }); checkResponse(status); } diff --git a/app/sdk/src/net/removeContactChannel.ts b/app/sdk/src/net/removeContactChannel.ts index 39fb7dfa..9daddb30 100644 --- a/app/sdk/src/net/removeContactChannel.ts +++ b/app/sdk/src/net/removeContactChannel.ts @@ -5,4 +5,3 @@ export async function removeContactChannel(node: string, secure: boolean, guid: const response = await fetchWithTimeout(endpoint, { method: 'DELETE' }); checkResponse(response.status); } - diff --git a/app/sdk/src/net/setAccess.ts b/app/sdk/src/net/setAccess.ts index bb305eb0..3c797bef 100644 --- a/app/sdk/src/net/setAccess.ts +++ b/app/sdk/src/net/setAccess.ts @@ -1,4 +1,4 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function setAccess( node: string, @@ -16,9 +16,9 @@ export async function setAccess( created: number; pushSupported: boolean; }> { - const endpoint = `http${secure ? "s" : ""}://${node}/account/access?token=${token}&appName=${appName}&appVersion=${appVersion}&platform=${platform}&deviceToken=${deviceToken}&pushType=${pushType}`; + const endpoint = `http${secure ? 's' : ''}://${node}/account/access?token=${token}&appName=${appName}&appVersion=${appVersion}&platform=${platform}&deviceToken=${deviceToken}&pushType=${pushType}`; const access = await fetchWithTimeout(endpoint, { - method: "PUT", + method: 'PUT', body: JSON.stringify(notifications), }); checkResponse(access.status); diff --git a/app/sdk/src/net/setAccountLogin.ts b/app/sdk/src/net/setAccountLogin.ts index a25b44e8..c32314dc 100644 --- a/app/sdk/src/net/setAccountLogin.ts +++ b/app/sdk/src/net/setAccountLogin.ts @@ -1,13 +1,13 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { encode } from "./base64"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { encode } from './base64'; export async function setAccountLogin(node: string, secure: boolean, token: string, username: string, password: string) { - const endpoint = `http${secure ? "s" : ""}://${node}/account/login?agent=${token}`; + const endpoint = `http${secure ? 's' : ''}://${node}/account/login?agent=${token}`; const auth = encode(`${username}:${password}`); const headers = new Headers(); - headers.append("Credentials", `Basic ${auth}`); + headers.append('Credentials', `Basic ${auth}`); const { status } = await fetchWithTimeout(endpoint, { - method: "PUT", + method: 'PUT', headers, }); checkResponse(status); diff --git a/app/sdk/src/net/setAccountMFAuth.ts b/app/sdk/src/net/setAccountMFAuth.ts index 61eb393e..51244339 100644 --- a/app/sdk/src/net/setAccountMFAuth.ts +++ b/app/sdk/src/net/setAccountMFAuth.ts @@ -1,7 +1,7 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function setAccountMFAuth(node: string, secure: boolean, token: string, code: string) { - const endpoint = `http${secure ? "s" : ""}://${node}/account/mfauth?agent=${token}&code=${code}`; - const { status } = await fetchWithTimeout(endpoint, { method: "PUT" }); + const endpoint = `http${secure ? 's' : ''}://${node}/account/mfauth?agent=${token}&code=${code}`; + const { status } = await fetchWithTimeout(endpoint, { method: 'PUT' }); checkResponse(status); } diff --git a/app/sdk/src/net/setAccountNotifications.ts b/app/sdk/src/net/setAccountNotifications.ts index 785e9f55..fe42536b 100644 --- a/app/sdk/src/net/setAccountNotifications.ts +++ b/app/sdk/src/net/setAccountNotifications.ts @@ -1,9 +1,9 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function setAccountNotifications(node: string, secure: boolean, token: string, flag: boolean) { - const endpoint = `http${secure ? "s" : ""}://${node}/account/notification?agent=${token}`; + const endpoint = `http${secure ? 's' : ''}://${node}/account/notification?agent=${token}`; const { status } = await fetchWithTimeout(endpoint, { - method: "PUT", + method: 'PUT', body: JSON.stringify(flag), }); checkResponse(status); diff --git a/app/sdk/src/net/setAccountSeal.ts b/app/sdk/src/net/setAccountSeal.ts index 4ff60b4a..4721c3e5 100644 --- a/app/sdk/src/net/setAccountSeal.ts +++ b/app/sdk/src/net/setAccountSeal.ts @@ -1,10 +1,10 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { SealEntity } from "../entities"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { SealEntity } from '../entities'; export async function setAccountSeal(node: string, secure: boolean, token: string, seal: SealEntity) { - const endpoint = `http${secure ? "s" : ""}://${node}/account/seal?agent=${token}`; + const endpoint = `http${secure ? 's' : ''}://${node}/account/seal?agent=${token}`; const { status } = await fetchWithTimeout(endpoint, { - method: "PUT", + method: 'PUT', body: JSON.stringify(seal), }); checkResponse(status); diff --git a/app/sdk/src/net/setAccountSearchable.ts b/app/sdk/src/net/setAccountSearchable.ts index 2d21e91b..00693c50 100644 --- a/app/sdk/src/net/setAccountSearchable.ts +++ b/app/sdk/src/net/setAccountSearchable.ts @@ -1,9 +1,9 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function setAccountSearchable(node: string, secure: boolean, token: string, flag: boolean) { - const endpoint = `http${secure ? "s" : ""}://${node}/account/searchable?agent=${token}`; + const endpoint = `http${secure ? 's' : ''}://${node}/account/searchable?agent=${token}`; const { status } = await fetchWithTimeout(endpoint, { - method: "PUT", + method: 'PUT', body: JSON.stringify(flag), }); checkResponse(status); diff --git a/app/sdk/src/net/setAdmin.ts b/app/sdk/src/net/setAdmin.ts index 4b879591..5538b409 100644 --- a/app/sdk/src/net/setAdmin.ts +++ b/app/sdk/src/net/setAdmin.ts @@ -1,9 +1,9 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function setAdmin(node: string, secure: boolean, token: string, mfaCode: string | null): Promise { - const mfa = mfaCode ? `&code=${mfaCode}` : ""; - const endpoint = `http${secure ? "s" : ""}://${node}/admin/access?token=${encodeURIComponent(token)}${mfa}`; - const admin = await fetchWithTimeout(endpoint, { method: "PUT" }); + const mfa = mfaCode ? `&code=${mfaCode}` : ''; + const endpoint = `http${secure ? 's' : ''}://${node}/admin/access?token=${encodeURIComponent(token)}${mfa}`; + const admin = await fetchWithTimeout(endpoint, { method: 'PUT' }); checkResponse(admin.status); return await admin.json(); } diff --git a/app/sdk/src/net/setCardCloseMessage.ts b/app/sdk/src/net/setCardCloseMessage.ts index c0879e6b..293fc841 100644 --- a/app/sdk/src/net/setCardCloseMessage.ts +++ b/app/sdk/src/net/setCardCloseMessage.ts @@ -1,8 +1,8 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; import { DataMessage } from '../entities'; export async function setCardCloseMessage(node: string, secure: boolean, message: DataMessage): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/contact/closeMessage`; - const close = await fetchWithTimeout(endpoint, { method: "PUT", body: JSON.stringify(message) }); + const endpoint = `http${secure ? 's' : ''}://${node}/contact/closeMessage`; + const close = await fetchWithTimeout(endpoint, { method: 'PUT', body: JSON.stringify(message) }); checkResponse(close.status); } diff --git a/app/sdk/src/net/setCardConfirmed.ts b/app/sdk/src/net/setCardConfirmed.ts index 4b2b7029..c465f67b 100644 --- a/app/sdk/src/net/setCardConfirmed.ts +++ b/app/sdk/src/net/setCardConfirmed.ts @@ -1,10 +1,10 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function setCardConfirmed(node: string, secure: boolean, token: string, cardId: string): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/contact/cards/${cardId}/status?agent=${token}`; + const endpoint = `http${secure ? 's' : ''}://${node}/contact/cards/${cardId}/status?agent=${token}`; const { status } = await fetchWithTimeout(endpoint, { - method: "PUT", - body: JSON.stringify("confirmed"), + method: 'PUT', + body: JSON.stringify('confirmed'), }); checkResponse(status); } diff --git a/app/sdk/src/net/setCardConnected.ts b/app/sdk/src/net/setCardConnected.ts index a75fd0cd..fcfd2a7a 100644 --- a/app/sdk/src/net/setCardConnected.ts +++ b/app/sdk/src/net/setCardConnected.ts @@ -1,10 +1,10 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function setCardConnected(node: string, secure: boolean, token: string, cardId: string, access: string, article: number, channel: number, profile: number): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/contact/cards/${cardId}/status?agent=${token}&token=${access}&viewRevision=1&articleRevision=${article}&channelRevision=${channel}&profileRevision=${profile}`; + const endpoint = `http${secure ? 's' : ''}://${node}/contact/cards/${cardId}/status?agent=${token}&token=${access}&viewRevision=1&articleRevision=${article}&channelRevision=${channel}&profileRevision=${profile}`; const { status } = await fetchWithTimeout(endpoint, { - method: "PUT", - body: JSON.stringify("connected"), + method: 'PUT', + body: JSON.stringify('connected'), }); checkResponse(status); } diff --git a/app/sdk/src/net/setCardConnecting.ts b/app/sdk/src/net/setCardConnecting.ts index 85b5133a..41549d59 100644 --- a/app/sdk/src/net/setCardConnecting.ts +++ b/app/sdk/src/net/setCardConnecting.ts @@ -1,10 +1,10 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function setCardConnecting(node: string, secure: boolean, token: string, cardId: string): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/contact/cards/${cardId}/status?agent=${token}`; + const endpoint = `http${secure ? 's' : ''}://${node}/contact/cards/${cardId}/status?agent=${token}`; const { status } = await fetchWithTimeout(endpoint, { - method: "PUT", - body: JSON.stringify("connecting"), + method: 'PUT', + body: JSON.stringify('connecting'), }); checkResponse(status); } diff --git a/app/sdk/src/net/setCardOpenMessage.ts b/app/sdk/src/net/setCardOpenMessage.ts index ebd19b4d..c24bc8cb 100644 --- a/app/sdk/src/net/setCardOpenMessage.ts +++ b/app/sdk/src/net/setCardOpenMessage.ts @@ -1,9 +1,9 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { DataMessage, ContactStatus } from "../entities"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { DataMessage, ContactStatus } from '../entities'; export async function setCardOpenMessage(node: string, secure: boolean, message: DataMessage): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/contact/openMessage`; - const open = await fetchWithTimeout(endpoint, { method: "PUT", body: JSON.stringify(message) }); + const endpoint = `http${secure ? 's' : ''}://${node}/contact/openMessage`; + const open = await fetchWithTimeout(endpoint, { method: 'PUT', body: JSON.stringify(message) }); checkResponse(open.status); return await open.json(); } diff --git a/app/sdk/src/net/setCardProfile.ts b/app/sdk/src/net/setCardProfile.ts index 0ca51c2c..8a97819f 100644 --- a/app/sdk/src/net/setCardProfile.ts +++ b/app/sdk/src/net/setCardProfile.ts @@ -1,10 +1,10 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { DataMessage } from "../entities"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { DataMessage } from '../entities'; export async function setCardProfile(node: string, secure: boolean, token: string, cardId: string, data: DataMessage): Promise { - const endpoint = `http${secure ? "s" : ""}://${node}/contact/cards/${cardId}/profile?agent=${token}`; + const endpoint = `http${secure ? 's' : ''}://${node}/contact/cards/${cardId}/profile?agent=${token}`; const { status } = await fetchWithTimeout(endpoint, { - method: "PUT", + method: 'PUT', body: JSON.stringify(data), }); checkResponse(status); diff --git a/app/sdk/src/net/setContactChannelNotifications.ts b/app/sdk/src/net/setContactChannelNotifications.ts index 564cf9dc..e81680ba 100644 --- a/app/sdk/src/net/setContactChannelNotifications.ts +++ b/app/sdk/src/net/setContactChannelNotifications.ts @@ -1,8 +1,7 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function setContactChannelNotifications(node: string, secure: boolean, guid: string, token: string, channelId: string, enabled: boolean) { - const endpoint = `http${secure ? 's' : ''}://${node}/content/channels/${channelId}/notification?contact=${guid}.${token}` + const endpoint = `http${secure ? 's' : ''}://${node}/content/channels/${channelId}/notification?contact=${guid}.${token}`; const notify = await fetchWithTimeout(endpoint, { method: 'PUT', body: JSON.stringify(enabled) }); - checkResponse(notify.status) + checkResponse(notify.status); } - diff --git a/app/sdk/src/net/setLogin.ts b/app/sdk/src/net/setLogin.ts index 84ce49f4..15215727 100644 --- a/app/sdk/src/net/setLogin.ts +++ b/app/sdk/src/net/setLogin.ts @@ -1,5 +1,5 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; -import { encode } from "./base64"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; +import { encode } from './base64'; export async function setLogin( node: string, @@ -19,13 +19,13 @@ export async function setLogin( created: number; pushSupported: boolean; }> { - const mfa = code ? `&code=${code}` : ""; - const endpoint = `http${secure ? "s" : ""}://${node}/account/apps?appName=${appName}&appVersion=${appVersion}&platform=${platform}&deviceToken=${deviceToken}&pushType=${pushType}${mfa}`; + const mfa = code ? `&code=${code}` : ''; + const endpoint = `http${secure ? 's' : ''}://${node}/account/apps?appName=${appName}&appVersion=${appVersion}&platform=${platform}&deviceToken=${deviceToken}&pushType=${pushType}${mfa}`; const auth = encode(`${username}:${password}`); const headers = new Headers(); - headers.append("Authorization", "Basic " + auth); + headers.append('Authorization', 'Basic ' + auth); const login = await fetchWithTimeout(endpoint, { - method: "POST", + method: 'POST', headers, body: JSON.stringify(notifications), }); diff --git a/app/sdk/src/net/setProfileData.ts b/app/sdk/src/net/setProfileData.ts index 628438e7..0b156cda 100644 --- a/app/sdk/src/net/setProfileData.ts +++ b/app/sdk/src/net/setProfileData.ts @@ -1,8 +1,8 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function setProfileData(node: string, secure: boolean, token: string, name: string, location: string, description: string): Promise { const data = { name: name, location: location, description: description }; - const endpoint = `http${secure ? "s" : ""}://${node}/profile/data?agent=${token}`; - const { status } = await fetchWithTimeout(endpoint, { method: "PUT", body: JSON.stringify(data) }); + const endpoint = `http${secure ? 's' : ''}://${node}/profile/data?agent=${token}`; + const { status } = await fetchWithTimeout(endpoint, { method: 'PUT', body: JSON.stringify(data) }); checkResponse(status); } diff --git a/app/sdk/src/net/setProfileImage.ts b/app/sdk/src/net/setProfileImage.ts index b90c5756..7110d55d 100644 --- a/app/sdk/src/net/setProfileImage.ts +++ b/app/sdk/src/net/setProfileImage.ts @@ -1,9 +1,9 @@ -import { checkResponse, fetchWithTimeout } from "./fetchUtil"; +import { checkResponse, fetchWithTimeout } from './fetchUtil'; export async function setProfileImage(node: string, secure: boolean, token: string, image: string) { - const endpoint = `http${secure ? "s" : ""}://${node}/profile/image?agent=${token}`; + const endpoint = `http${secure ? 's' : ''}://${node}/profile/image?agent=${token}`; const { status } = await fetchWithTimeout(endpoint, { - method: "PUT", + method: 'PUT', body: JSON.stringify(image), }); checkResponse(status); diff --git a/app/sdk/src/node.ts b/app/sdk/src/node.ts index d2948d23..772f557d 100644 --- a/app/sdk/src/node.ts +++ b/app/sdk/src/node.ts @@ -1,6 +1,6 @@ -import type { Node } from "./api"; -import type { NodeAccount, NodeConfig } from "./types"; -import type { Logging } from "./logging"; +import type { Node } from './api'; +import type { NodeAccount, NodeConfig } from './types'; +import type { Logging } from './logging'; export class NodeModule implements Node { private log: Logging; @@ -16,11 +16,11 @@ export class NodeModule implements Node { } public async createAccountAccess(): Promise { - return ""; + return ''; } public async resetAccountAccess(): Promise { - return ""; + return ''; } public async blockAccount(flag: boolean): Promise {} @@ -33,21 +33,21 @@ export class NodeModule implements Node { public async getConfig(): Promise { return { - domain: "", - accountStorage: "", + domain: '', + accountStorage: '', enableImage: true, enableAudio: true, enableVideo: true, enableBinary: true, - keyType: "", + keyType: '', pushSupported: true, allowUnsealed: true, transformSupported: true, enableIce: true, - iceService: "", - iceUrl: "", - iceUsername: "", - icePassword: "", + iceService: '', + iceUrl: '', + iceUsername: '', + icePassword: '', enableOpenAccess: true, openAccessLimit: 0, }; diff --git a/app/sdk/src/ring.ts b/app/sdk/src/ring.ts index 517f3afc..14132c0a 100644 --- a/app/sdk/src/ring.ts +++ b/app/sdk/src/ring.ts @@ -1,6 +1,6 @@ -import { EventEmitter } from "eventemitter3"; -import type { Ring, Logging } from "./api"; -import type { Call } from "./types"; +import { EventEmitter } from 'eventemitter3'; +import type { Ring, Logging } from './api'; +import type { Call } from './types'; export class RingModule implements Ring { private log: Logging; @@ -12,19 +12,19 @@ export class RingModule implements Ring { } public addCallingListener(ev: (calls: Call[]) => void): void { - this.emitter.on("calling", ev); + this.emitter.on('calling', ev); } public removeCallingListener(ev: (calls: Call[]) => void): void { - this.emitter.off("calling", ev); + this.emitter.off('calling', ev); } public addCallListener(ev: (call: Call | null) => void): void { - this.emitter.on("call", ev); + this.emitter.on('call', ev); } public removeCallListener(ev: (call: Call | null) => void): void { - this.emitter.off("call", ev); + this.emitter.off('call', ev); } public ring(call: Call): void {} diff --git a/app/sdk/src/session.ts b/app/sdk/src/session.ts index 3a4a6818..8144795c 100644 --- a/app/sdk/src/session.ts +++ b/app/sdk/src/session.ts @@ -1,23 +1,23 @@ -import { EventEmitter } from "eventemitter3"; +import { EventEmitter } from 'eventemitter3'; -import { SettingsModule } from "./settings"; -import { IdentityModule } from "./identity"; -import { ContactModule } from "./contact"; -import { AliasModule } from "./alias"; -import { AttributeModule } from "./attribute"; -import { ContentModule } from "./content"; -import { StreamModule } from "./stream"; -import { FocusModule } from "./focus"; -import { RingModule } from "./ring"; +import { SettingsModule } from './settings'; +import { IdentityModule } from './identity'; +import { ContactModule } from './contact'; +import { AliasModule } from './alias'; +import { AttributeModule } from './attribute'; +import { ContentModule } from './content'; +import { StreamModule } from './stream'; +import { FocusModule } from './focus'; +import { RingModule } from './ring'; -import { Connection } from "./connection"; +import { Connection } from './connection'; -import type { Session, Settings, Identity, Contact, Ring, Alias, Attribute, Content, Stream, Focus } from "./api"; -import { Revision } from "./entities"; -import { Call } from "./types"; -import { Store } from "./store"; -import type { Logging } from "./logging"; -import type { Crypto } from "./crypto"; +import type { Session, Settings, Identity, Contact, Ring, Alias, Attribute, Content, Stream, Focus } from './api'; +import { Revision } from './entities'; +import { Call } from './types'; +import { Store } from './store'; +import type { Logging } from './logging'; +import type { Crypto } from './crypto'; export class SessionModule implements Session { private emitter: EventEmitter; @@ -43,7 +43,7 @@ export class SessionModule implements Session { private articleTypes: string[]; constructor(store: Store, crypto: Crypto | null, log: Logging, guid: string, token: string, node: string, secure: boolean, loginTimestamp: number, channelTypes: string[], articleTypes: string[]) { - log.info("new databag session"); + log.info('new databag session'); this.store = store; this.crypto = crypto; @@ -55,7 +55,7 @@ export class SessionModule implements Session { this.channelTypes = channelTypes; this.articleTypes = articleTypes; this.loginTimestamp = loginTimestamp; - this.status = "connecting"; + this.status = 'connecting'; this.emitter = new EventEmitter(); this.identity = new IdentityModule(log, this.store, guid, token, node, secure); @@ -70,7 +70,7 @@ export class SessionModule implements Session { const onStatus = (ev: string) => { this.status = ev; - this.emitter.emit("status", this.getStatus()); + this.emitter.emit('status', this.getStatus()); }; const onSeal = (seal: { privateKey: string; publicKey: string } | null) => { @@ -97,11 +97,11 @@ export class SessionModule implements Session { } public addStatusListener(ev: (status: string) => void): void { - this.emitter.on("status", ev); + this.emitter.on('status', ev); } public removeStatusListener(ev: (status: string) => void): void { - this.emitter.off("status", ev); + this.emitter.off('status', ev); } private getStatus(): string { diff --git a/app/sdk/src/settings.ts b/app/sdk/src/settings.ts index 21e5a576..f79132c7 100644 --- a/app/sdk/src/settings.ts +++ b/app/sdk/src/settings.ts @@ -1,20 +1,20 @@ -import { EventEmitter } from "eventemitter3"; -import type { Settings } from "./api"; -import type { Config } from "./types"; -import { Store } from "./store"; -import { Crypto } from "./crypto"; -import { Logging } from "./logging"; -import { defaultConfigEntity, ConfigEntity } from "./entities"; -import { getAccountStatus } from "./net/getAccountStatus"; -import { addAccountMFAuth } from "./net/addAccountMFAuth"; -import { setAccountMFAuth } from "./net/setAccountMFAuth"; -import { removeAccountMFAuth } from "./net/removeAccountMFAuth"; -import { setAccountLogin } from "./net/setAccountLogin"; -import { setAccountNotifications } from "./net/setAccountNotifications"; -import { setAccountSearchable } from "./net/setAccountSearchable"; -import { setAccountSeal } from "./net/setAccountSeal"; -import { clearAccountSeal } from "./net/clearAccountSeal"; -import { getUsername } from "./net/getUsername"; +import { EventEmitter } from 'eventemitter3'; +import type { Settings } from './api'; +import type { Config } from './types'; +import { Store } from './store'; +import { Crypto } from './crypto'; +import { Logging } from './logging'; +import { defaultConfigEntity, ConfigEntity } from './entities'; +import { getAccountStatus } from './net/getAccountStatus'; +import { addAccountMFAuth } from './net/addAccountMFAuth'; +import { setAccountMFAuth } from './net/setAccountMFAuth'; +import { removeAccountMFAuth } from './net/removeAccountMFAuth'; +import { setAccountLogin } from './net/setAccountLogin'; +import { setAccountNotifications } from './net/setAccountNotifications'; +import { setAccountSearchable } from './net/setAccountSearchable'; +import { setAccountSeal } from './net/setAccountSeal'; +import { clearAccountSeal } from './net/clearAccountSeal'; +import { getUsername } from './net/getUsername'; const CLOSE_POLL_MS = 100; const RETRY_POLL_MS = 2000; @@ -64,8 +64,8 @@ export class SettingsModule implements Settings { this.revision = await this.store.getSettingsRevision(this.guid); this.config = await this.store.getSettingsData(this.guid); this.seal = await this.store.getSeal(this.guid); - this.emitter.emit("seal", this.getSeal()); - this.emitter.emit("config", this.getConfig()); + this.emitter.emit('seal', this.getSeal()); + this.emitter.emit('config', this.getConfig()); this.syncing = false; await this.sync(); } @@ -84,8 +84,8 @@ export class SettingsModule implements Settings { await this.store.setSettingsData(guid, config); await this.store.setSettingsRevision(guid, nextRev); this.config = config; - this.emitter.emit("config", this.getConfig()); - this.emitter.emit("seal", this.getSeal()); + this.emitter.emit('config', this.getConfig()); + this.emitter.emit('seal', this.getSeal()); this.revision = nextRev; if (this.nextRevision === nextRev) { this.nextRevision = null; @@ -123,21 +123,21 @@ export class SettingsModule implements Settings { } public addConfigListener(ev: (config: Config) => void): void { - this.emitter.on("config", ev); - this.emitter.emit("config", this.getConfig()); + this.emitter.on('config', ev); + this.emitter.emit('config', this.getConfig()); } public removeConfigListener(ev: (config: Config) => void): void { - this.emitter.off("config", ev); + this.emitter.off('config', ev); } public addSealListener(ev: (seal: { privateKey: string; publicKey: string } | null) => void): void { - this.emitter.on("seal", ev); + this.emitter.on('seal', ev); ev(this.seal); } public removeSealListener(ev: (seal: { privateKey: string; publicKey: string } | null) => void): void { - this.emitter.off("seal", ev); + this.emitter.off('seal', ev); } public async close(): Promise { @@ -194,7 +194,7 @@ export class SettingsModule implements Settings { public async setSeal(password: string): Promise { const { crypto, guid, node, secure, token } = this; if (!crypto) { - throw new Error("crypto not enabled"); + throw new Error('crypto not enabled'); } const { saltHex } = await crypto.pbkdfSalt(); const { aesKeyHex } = await crypto.pbkdfKey(saltHex, password); @@ -210,17 +210,17 @@ export class SettingsModule implements Settings { await setAccountSeal(node, secure, token, seal); this.seal = { publicKey: publicKeyB64, privateKey: privateKeyB64 }; this.store.setSeal(guid, this.seal); - this.emitter.emit("config", this.getConfig()); - this.emitter.emit("seal", this.getSeal()); + this.emitter.emit('config', this.getConfig()); + this.emitter.emit('seal', this.getSeal()); } public async updateSeal(password: string): Promise { const { crypto, config, node, secure, token } = this; if (!crypto) { - throw new Error("crypto not enabled"); + throw new Error('crypto not enabled'); } if (!this.seal || this.seal.publicKey !== config.seal.publicKey) { - throw new Error("seal not unlocked"); + throw new Error('seal not unlocked'); } const { saltHex } = await crypto.pbkdfSalt(); const { aesKeyHex } = await crypto.pbkdfKey(saltHex, password); @@ -240,34 +240,34 @@ export class SettingsModule implements Settings { await clearAccountSeal(node, secure, token); await this.store.clearSeal(guid); this.seal = null; - this.emitter.emit("config", this.getConfig()); - this.emitter.emit("seal", this.getSeal()); + this.emitter.emit('config', this.getConfig()); + this.emitter.emit('seal', this.getSeal()); } public async unlockSeal(password: string): Promise { const { guid, config, crypto } = this; const { passwordSalt, privateKeyIv, privateKeyEncrypted, publicKey } = config.seal; if (!passwordSalt || !privateKeyIv || !privateKeyEncrypted || !publicKey) { - throw new Error("account seal not set"); + throw new Error('account seal not set'); } if (!crypto) { - throw new Error("crypto not set"); + throw new Error('crypto not set'); } const { aesKeyHex } = await crypto.pbkdfKey(passwordSalt, password); const { data } = await crypto.aesDecrypt(privateKeyEncrypted, privateKeyIv, aesKeyHex); const seal = { publicKey: publicKey, privateKey: data }; this.store.setSeal(guid, seal); this.seal = seal; - this.emitter.emit("config", this.getConfig()); - this.emitter.emit("seal", this.getSeal()); + this.emitter.emit('config', this.getConfig()); + this.emitter.emit('seal', this.getSeal()); } public async forgetSeal(): Promise { const { guid } = this; await this.store.clearSeal(guid); this.seal = null; - this.emitter.emit("config", this.getConfig()); - this.emitter.emit("seal", this.getSeal()); + this.emitter.emit('config', this.getConfig()); + this.emitter.emit('seal', this.getSeal()); } public async getUsernameStatus(username: string): Promise { diff --git a/app/sdk/src/store.ts b/app/sdk/src/store.ts index 2215d161..5c33d458 100644 --- a/app/sdk/src/store.ts +++ b/app/sdk/src/store.ts @@ -1,6 +1,6 @@ -import { Login, ProfileEntity, defaultProfileEntity, ConfigEntity, defaultConfigEntity } from "./entities"; -import type { ArticleDetail, ArticleItem, ChannelItem, CardItem, CardProfile, CardDetail, ChannelSummary, ChannelDetail } from "./items"; -import type { Logging } from "./logging"; +import { Login, ProfileEntity, defaultProfileEntity, ConfigEntity, defaultConfigEntity } from './entities'; +import type { ArticleDetail, ArticleItem, ChannelItem, CardItem, CardProfile, CardDetail, ChannelSummary, ChannelDetail } from './items'; +import type { Logging } from './logging'; export interface Store { init(): Promise; @@ -87,17 +87,16 @@ export class OfflineStore implements Store { this.log = log; } - private async getValues(guid: string, table: string, fields: string[]): Promise { - return await this.sql.get(`SELECT ${fields.join(', ')} FROM ${table}_${guid}`) + return await this.sql.get(`SELECT ${fields.join(', ')} FROM ${table}_${guid}`); } private async addValue(guid: string, table: string, fields: string[], value: (string | number | null)[]): Promise { - return await this.sql.set(`INSERT INTO ${table}_${guid} (${fields.join(', ')}) VALUES (${fields.map(field => '?').join(', ')})`, value); + return await this.sql.set(`INSERT INTO ${table}_${guid} (${fields.join(', ')}) VALUES (${fields.map((field) => '?').join(', ')})`, value); } private async setValue(guid: string, table: string, idField: string, fields: string[], idValue: string | number, value: (string | number | null)[]): Promise { - return await this.sql.set(`UPDATE ${table}_${guid} SET ${fields.map(field => `${field}=?`).join(',')} WHERE ${idField}=?`, [ ...value, idValue ]); + return await this.sql.set(`UPDATE ${table}_${guid} SET ${fields.map((field) => `${field}=?`).join(',')} WHERE ${idField}=?`, [...value, idValue]); } private async removeValue(guid: string, table: string, idField: string, idValue: string | number): Promise { @@ -107,8 +106,7 @@ export class OfflineStore implements Store { private parse(value: string): any { try { return JSON.parse(value); - } - catch (err) { + } catch (err) { console.log(err); } return {}; @@ -127,11 +125,11 @@ export class OfflineStore implements Store { } private async setAppValue(guid: string, id: string, value: any): Promise { - await this.sql.set("INSERT OR REPLACE INTO app (key, value) values (?, ?)", [`${guid}::${id}`, JSON.stringify(value)]); + await this.sql.set('INSERT OR REPLACE INTO app (key, value) values (?, ?)', [`${guid}::${id}`, JSON.stringify(value)]); } private async clearAppValue(guid: string, id: string): Promise { - await this.sql.set("INSERT OR REPLACE INTO app (key, value) values (?, null)", [`${guid}::${id}`]); + await this.sql.set('INSERT OR REPLACE INTO app (key, value) values (?, null)', [`${guid}::${id}`]); } private async initLogin(guid: string): Promise { @@ -150,14 +148,12 @@ export class OfflineStore implements Store { await this.sql.set( `CREATE TABLE IF NOT EXISTS card_channel_topic_${guid} (card_id text, channel_id text, topic_id text, revision integer, created integer, detail_revision integer, detail text, unsealed_detail text, unique(card_id, channel_id, topic_id))`, ); - await this.sql.set( - `CREATE TABLE IF NOT EXISTS marker_${guid} (value text)`, - ); + await this.sql.set(`CREATE TABLE IF NOT EXISTS marker_${guid} (value text)`); } public async init(): Promise { - await this.sql.set("CREATE TABLE IF NOT EXISTS app (key text, value text, unique(key));"); - return (await this.getAppValue("", "login", null)) as Login | null; + await this.sql.set('CREATE TABLE IF NOT EXISTS app (key text, value text, unique(key));'); + return (await this.getAppValue('', 'login', null)) as Login | null; } public async setMarker(guid: string, value: string) { @@ -169,76 +165,87 @@ export class OfflineStore implements Store { } public async getMarkers(guid: string): Promise { - return (await this.getValues(guid, 'marker', ['value'])).map(marker => marker.value); + return (await this.getValues(guid, 'marker', ['value'])).map((marker) => marker.value); } public async setLogin(login: Login): Promise { await this.initLogin(login.guid); - await this.setAppValue("", "login", login); + await this.setAppValue('', 'login', login); } public async clearLogin(): Promise { - await this.clearAppValue("", "login"); + await this.clearAppValue('', 'login'); } public async getSeal(guid: string): Promise<{ publicKey: string; privateKey: string } | null> { - return (await this.getAppValue(guid, "seal", null)) as { + return (await this.getAppValue(guid, 'seal', null)) as { publicKey: string; privateKey: string; } | null; } public async setSeal(guid: string, seal: { publicKey: string; privateKey: string }): Promise { - await this.setAppValue(guid, "seal", seal); + await this.setAppValue(guid, 'seal', seal); } public async clearSeal(guid: string): Promise { - await this.clearAppValue(guid, "seal"); + await this.clearAppValue(guid, 'seal'); } public async getProfileRevision(guid: string): Promise { - return (await this.getAppValue(guid, "profile_revision", 0)) as number; + return (await this.getAppValue(guid, 'profile_revision', 0)) as number; } public async setProfileRevision(guid: string, revision: number): Promise { - await this.setAppValue(guid, "profile_revision", revision); + await this.setAppValue(guid, 'profile_revision', revision); } public async getProfileData(guid: string): Promise { - return (await this.getAppValue(guid, "profile_data", defaultProfileEntity)) as ProfileEntity; + return (await this.getAppValue(guid, 'profile_data', defaultProfileEntity)) as ProfileEntity; } public async setProfileData(guid: string, data: ProfileEntity): Promise { - await this.setAppValue(guid, "profile_data", data); + await this.setAppValue(guid, 'profile_data', data); } public async getSettingsRevision(guid: string): Promise { - return (await this.getAppValue(guid, "account_revision", 0)) as number; + return (await this.getAppValue(guid, 'account_revision', 0)) as number; } public async setSettingsRevision(guid: string, revision: number): Promise { - await this.setAppValue(guid, "account_revision", revision); + await this.setAppValue(guid, 'account_revision', revision); } public async getSettingsData(guid: string): Promise { - return (await this.getAppValue(guid, "account_data", defaultConfigEntity)) as ConfigEntity; + return (await this.getAppValue(guid, 'account_data', defaultConfigEntity)) as ConfigEntity; } public async setSettingsData(guid: string, data: ConfigEntity): Promise { - await this.setAppValue(guid, "account_data", data); + await this.setAppValue(guid, 'account_data', data); } public async getContactRevision(guid: string): Promise { - return (await this.getAppValue(guid, "contact_revision", 0)) as number; + return (await this.getAppValue(guid, 'contact_revision', 0)) as number; } public async setContactRevision(guid: string, revision: number): Promise { - await this.setAppValue(guid, "contact_revision", revision); + await this.setAppValue(guid, 'contact_revision', revision); } public async getContacts(guid: string): Promise<{ cardId: string; item: CardItem }[]> { - const cards = await this.getValues(guid, 'card', ['offsync_profile', 'offsync_article', 'offsync_channel', 'revision', 'card_id', 'profile', 'detail', 'profile_revision', 'article_revision', 'channel_revision']); - return cards.map(card => ({ + const cards = await this.getValues(guid, 'card', [ + 'offsync_profile', + 'offsync_article', + 'offsync_channel', + 'revision', + 'card_id', + 'profile', + 'detail', + 'profile_revision', + 'article_revision', + 'channel_revision', + ]); + return cards.map((card) => ({ cardId: card.card_id, item: { offsyncProfile: card.offsync_profile, @@ -250,7 +257,7 @@ export class OfflineStore implements Store { profileRevision: card.profile_revision, articleRevision: card.article_revision, channelRevision: card.channel_revision, - } + }, })); } @@ -313,7 +320,6 @@ export class OfflineStore implements Store { await this.setValue(guid, 'card', 'card_id', ['channel_revision'], cardId, [revision]); } - public async getContactCardArticles(guid: string): Promise<{ cardId: string; articleId: string; item: ArticleItem }[]> { return []; } @@ -373,7 +379,7 @@ export class OnlineStore implements Store { } public async init(): Promise { - return (await this.getAppValue("", "login", null)) as Login | null; + return (await this.getAppValue('', 'login', null)) as Login | null; } public async setMarker(guid: string, value: string) { @@ -384,7 +390,11 @@ export class OnlineStore implements Store { public async clearMarker(guid: string, value: string) { const markers = (await this.getAppValue(guid, 'marker', [])) as string[]; - this.setAppValue(guid, 'marker', markers.filter(marker => (value != marker))); + this.setAppValue( + guid, + 'marker', + markers.filter((marker) => value != marker), + ); } public async getMarkers(guid: string): Promise { @@ -392,26 +402,26 @@ export class OnlineStore implements Store { } public async setLogin(login: Login): Promise { - await this.setAppValue("", "login", login); + await this.setAppValue('', 'login', login); } public async clearLogin(): Promise { - await this.clearAppValue("", "login"); + await this.clearAppValue('', 'login'); } public async getSeal(guid: string): Promise<{ publicKey: string; privateKey: string } | null> { - return (await this.getAppValue(guid, "seal", null)) as { + return (await this.getAppValue(guid, 'seal', null)) as { publicKey: string; privateKey: string; } | null; } public async setSeal(guid: string, seal: { publicKey: string; privateKey: string }): Promise { - await this.setAppValue(guid, "seal", seal); + await this.setAppValue(guid, 'seal', seal); } public async clearSeal(guid: string): Promise { - await this.clearAppValue(guid, "seal"); + await this.clearAppValue(guid, 'seal'); } public async getProfileRevision(guid: string): Promise { diff --git a/app/sdk/src/stream.ts b/app/sdk/src/stream.ts index 2fd0b478..2126b07d 100644 --- a/app/sdk/src/stream.ts +++ b/app/sdk/src/stream.ts @@ -1,8 +1,8 @@ -import { EventEmitter } from "eventemitter3"; -import type { Contact, Content, Stream } from "./api"; -import type { Channel } from "./types"; -import { Store } from "./store"; -import { Logging } from "./logging"; +import { EventEmitter } from 'eventemitter3'; +import type { Contact, Content, Stream } from './api'; +import type { Channel } from './types'; +import { Store } from './store'; +import { Logging } from './logging'; export class StreamModule implements Stream { private log: Logging; @@ -20,11 +20,11 @@ export class StreamModule implements Stream { } public addChannelListener(ev: (channels: Channel[]) => void): void { - this.emitter.on("channel", ev); + this.emitter.on('channel', ev); } public removeChannelListener(ev: (channels: Channel[]) => void): void { - this.emitter.off("channel", ev); + this.emitter.off('channel', ev); } public async close(): Promise {}