diff --git a/SECURITY.md b/SECURITY.md index e9c701b..e80f3a0 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -15,7 +15,7 @@ These are all the versions that we support right now. ## Reporting a Vulnerability -You can [email](mailto:me@brndnln.dev?cc=bluebeargreen2@gmail.com&subject=%F0%9F%90%9B%20Security%20Issue%20in%20vexico%2Fspookvooper-api&body=This%20is%20a%20security%20issue%20email.%0D%0A%0D%0APlease%20describe%20the%20issue%20and%20include%3A%0D%0A-%20Screenshots%0D%0A-%20Code%20Snippets%0D%0A-%20Examples%20of%20how%20an%20enterprising%20individual%20could%20use%20this%20to%20their%20advantage%0D%0A-%20Pictures%20of%20cats%20(they%20are%20always%20fun)%0D%0A%0D%0AThank%20you%20for%20showing%20enough%20interest%20in%20our%20software%2C%20and%20more%20importantly%2C%20thank%20you%20for%20breaking%20it.%0D%0AHappy%20Hacking!%0D%0A-%20Brendan) +You can [email](mailto:me@brndnln.dev?cc=brycebauer@bluebeargreen.live&subject=%F0%9F%90%9B%20Security%20Issue%20in%20vexico%2Fspookvooper-api&body=This%20is%20a%20security%20issue%20email.%0D%0A%0D%0APlease%20describe%20the%20issue%20and%20include%3A%0D%0A-%20Screenshots%0D%0A-%20Code%20Snippets%0D%0A-%20Examples%20of%20how%20an%20enterprising%20individual%20could%20use%20this%20to%20their%20advantage%0D%0A-%20Pictures%20of%20cats%20(they%20are%20always%20fun)%0D%0A%0D%0AThank%20you%20for%20showing%20enough%20interest%20in%20our%20software%2C%20and%20more%20importantly%2C%20thank%20you%20for%20breaking%20it.%0D%0AHappy%20Hacking!%0D%0A-%20Brendan) us about your findings, just don't send them to us over Discord, post them in any public places, etc. Basically don't be a moron. You can also tell us that you sent us an email over at [our bounties site](https://bounties.vexi.cc) (just wait until its done) diff --git a/src/modules/ExchangeHub.ts b/src/modules/ExchangeHub.ts index 171eef8..c49f516 100644 --- a/src/modules/ExchangeHub.ts +++ b/src/modules/ExchangeHub.ts @@ -5,6 +5,7 @@ import { Observable } from 'rxjs' import { HubConnectionBuilder, LogLevel } from '@microsoft/signalr' +import { AuthEntity, QueueType } from './types/Types' const URI = 'https://spookvooper.com/ExchangeHub' const retryTime = 5 @@ -55,7 +56,7 @@ class ExchangeHub { this.start() } - public async start (): Promise { + private async start (): Promise { console.log(`ExchangeHub: Starting connection between local and ${URI}`) try { @@ -74,6 +75,34 @@ class ExchangeHub { console.error('ExchangeHub Error: Connection closed unexpectedly', e) await this.start() } + + public async sendChatMessage (message: string, accountid: string, auth: AuthEntity, ticker: string, tradeState: QueueType): Promise { + return await new Promise((resolve, reject) => { + if (message === undefined || accountid === undefined || auth === undefined || ticker === undefined || tradeState === undefined) { + throw new Error('All parameters need to be set') + } + + this.connection.invoke('SendMessage', accountid, auth.apikey, message, ticker, tradeState) + .then(() => { + resolve(true) + }) + .catch((err) => { + reject(err) + }) + }) + } + + public async getMessageHistory (): Promise { + return await new Promise((resolve, reject) => { + this.connection.invoke('RequestHistory') + .then((val) => { + resolve(val) + }) + .catch((err) => { + reject(err) + }) + }) + } } export default ExchangeHub diff --git a/typings/modules/District.d.ts b/typings/modules/District.d.ts new file mode 100644 index 0000000..4c3b38d --- /dev/null +++ b/typings/modules/District.d.ts @@ -0,0 +1,11 @@ +import { District as DistrictType, DistrictWealthType, SenatorDistrict } from './types/Types' +import { ReturnedUser } from './interfaces/Interfaces' +declare class District { + private readonly districtName + get name (): DistrictType; + set name (name: DistrictType); + constructor (name: DistrictType); + getWealth (type: DistrictWealthType): Promise; + getSenator (district?: SenatorDistrict): Promise; +} +export default District diff --git a/typings/modules/ExchangeHub.d.ts b/typings/modules/ExchangeHub.d.ts new file mode 100644 index 0000000..376a028 --- /dev/null +++ b/typings/modules/ExchangeHub.d.ts @@ -0,0 +1,16 @@ +import { Observable } from 'rxjs' +import { AuthEntity, QueueType } from './types/Types' +declare class ExchangeHub { + private readonly connection + onOffer: Observable + onOfferCancel: Observable + onTradeEvent: Observable + onMessage: Observable + onMessageHistory: Observable + constructor (); + private readonly start + private readonly onClosed + sendChatMessage (message: string, accountid: string, auth: AuthEntity, ticker: string, tradeState: QueueType): Promise; + getMessageHistory (): Promise; +} +export default ExchangeHub diff --git a/typings/modules/Stock.d.ts b/typings/modules/Stock.d.ts new file mode 100644 index 0000000..379683c --- /dev/null +++ b/typings/modules/Stock.d.ts @@ -0,0 +1,12 @@ +import { QueueType } from './types/Types' +declare class Stock { + private readonly stockTicker + get ticker (): string; + set ticker (ticker: string); + constructor (ticker: string); + getValue (): Promise; + getBuyPrice (): Promise; + getQueueInfo (type: QueueType): Promise; + getOwnerData (): Promise; +} +export default Stock diff --git a/typings/modules/TransactionHub.d.ts b/typings/modules/TransactionHub.d.ts new file mode 100644 index 0000000..b6edb2d --- /dev/null +++ b/typings/modules/TransactionHub.d.ts @@ -0,0 +1,12 @@ +import { Observable } from 'rxjs' +declare class TransactionHub { + private readonly connection + private readonly val + fromAccount: string + toAccount: string + event: Observable + constructor (); + start (): Promise; + private readonly onClosed +} +export default TransactionHub diff --git a/typings/modules/User.d.ts b/typings/modules/User.d.ts index 1668195..5c1c48d 100644 --- a/typings/modules/User.d.ts +++ b/typings/modules/User.d.ts @@ -1,4 +1,4 @@ -import { CreditAmount, PaymentEntity, SVStockTicker } from './types/Types' +import { CreditAmount, PaymentEntity } from './types/Types' import { ConfigUser } from './interfaces/Interfaces' declare class User { private readonly accountid @@ -10,13 +10,14 @@ declare class User { hasDiscordRole (role: string): Promise; getDiscordRoles (): Promise; sendCredits (amount: CreditAmount, to: PaymentEntity, reason: string): Promise; - getStockOffers (ticker: SVStockTicker): Promise; - buyStock (ticker: SVStockTicker, amount: number, price: CreditAmount): Promise; - sellStock (ticker: SVStockTicker, amount: number, price: CreditAmount): Promise; + getStockOffers (ticker: string): Promise; + buyStock (ticker: string, amount: number, price: CreditAmount): Promise; + sellStock (ticker: string, amount: number, price: CreditAmount): Promise; cancelOffer (orderid: number): Promise; get apikey (): string; set apikey (apikey: string); get svid (): string; set svid (svid: string); + hasFossPp (): boolean; } export default User diff --git a/typings/modules/interfaces/Interfaces.d.ts b/typings/modules/interfaces/Interfaces.d.ts index c70f990..6cf69f0 100644 --- a/typings/modules/interfaces/Interfaces.d.ts +++ b/typings/modules/interfaces/Interfaces.d.ts @@ -1,5 +1,7 @@ -export interface EntityUser { +import { DistrictWealthType, SenatorDistrict } from '../types/Types' +interface EntityUser { svid: string + apikey: string getUser: () => Promise getUsername: () => Promise getBalance: () => Promise @@ -9,20 +11,64 @@ export interface EntityUser { getStockOffers: () => Promise buyStock: () => Promise sellStock: () => Promise - setApiKey: () => void - setSvid: () => void } - -export interface ConfigUser { +interface EntityGroup { + svid: string +} +interface EntityDistrict { + name: string + getWealth: (type: DistrictWealthType) => Promise + getSenator: (district: SenatorDistrict) => Promise +} +interface ConfigUser { svid: string apikey?: string } - -export interface EntityGroup { - svid: string -} - -export interface AuthConfig { +interface ConfigAuth { clientid: string clientsecret: string } +interface ReturnedUser { + userName: string + twitch_id: string | null + discord_id: number | null + post_likes: number + comment_likes: number + nationstate: string | null + description: string | null + api_use_count: number + minecraft_id: string | null + twitch_last_message_minute: number + twitch_message_xp: number + twitch_messages: number + discord_commends: number + discord_commends_sent: number + discord_last_commend_hour: number + discord_last_commend_message: number + discord_message_xp: number + discord_message_count: number + discord_last_message_minute: number + discord_warning_count: number + discord_ban_count: number + discord_kick_count: number + discord_game_xp: number + district: string | null + id: string + name: string + credits: number + image_Url: string | null +} +interface ReturnedTransaction { + FromAccount: string + ToAccount: string + Amount: number + Detail: string + Force: boolean + IsCompleted: boolean + Tax: number + Result: { + Info: string + Succeeded: boolean + } +} +export { EntityUser, EntityGroup, EntityDistrict, ConfigUser, ConfigAuth, ReturnedUser, ReturnedTransaction } diff --git a/typings/modules/types/Types.d.ts b/typings/modules/types/Types.d.ts index 199ab46..4225af9 100644 --- a/typings/modules/types/Types.d.ts +++ b/typings/modules/types/Types.d.ts @@ -1,7 +1,11 @@ -import { EntityUser, AuthConfig as AuthConfigInt } from './../interfaces/Interfaces' -export declare type CreditAmount = string | number -export declare type PaymentEntity = string | EntityUser -export declare type SVStockTicker = 'B' | 'IDE' | 'NEWS' | 'POT' | 'TECH' | 'TYCO' | 'VC' | 'VNB' | 'VU' | 'X' -export declare type AuthEntity = EntityUser -export declare type GroupMember = string | EntityUser -export declare type AuthConfig = AuthConfigInt +import { EntityUser, ConfigAuth } from './../interfaces/Interfaces' +declare type CreditAmount = string | number +declare type PaymentEntity = string | EntityUser +declare type AuthEntity = EntityUser +declare type GroupMember = string | EntityUser +declare type AuthConfig = ConfigAuth +declare type District = 'Voopmont' | 'New Yam' | 'San Vooperisco' | 'Medievala' | 'Landing Cove' | 'New Spudland' | 'Vooperia City' | 'Corgi' | 'Old Yam' | 'New Vooperis' | 'The Netherlands' | 'Queensland' | 'Servers Past' | 'Los Vooperis' | 'Old King Peninsula' +declare type DistrictWealthType = 'ALL' | 'USER' | 'GROUP' +declare type SenatorDistrict = District | 'ALL' +declare type QueueType = 'BUY' | 'SELL' +export { CreditAmount, PaymentEntity, AuthEntity, GroupMember, AuthConfig, District, DistrictWealthType, SenatorDistrict, QueueType }