diff --git a/SECURITY.md b/SECURITY.md index be856a1..e9c701b 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -19,5 +19,5 @@ You can [email](mailto:me@brndnln.dev?cc=bluebeargreen2@gmail.com&subject=%F0%9F 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) -> Happy Hacking! -> \- Brendan Lane +Happy Hacking! + \- Brendan Lane diff --git a/src/main.ts b/src/main.ts index 6534067..13ff6ff 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,8 +3,10 @@ import User from './modules/User' import Group from './modules/Group' +import Auth from './modules/Auth' export { User, - Group + Group, + Auth } diff --git a/src/modules/Auth.ts b/src/modules/Auth.ts index 04c0c7d..1812895 100644 --- a/src/modules/Auth.ts +++ b/src/modules/Auth.ts @@ -59,6 +59,26 @@ class Auth { return this.urlReturn } } + + public async requestToken (redirect: string): Promise { + return await new Promise((resolve, reject) => { + axios.get(`${authURL}/requestToken`, { + params: { + grant_type: 'authorization_code', + code: this.code, + redirect_uri: redirect, + client_id: this.appid, + client_secret: this.appsecret + } + }) + .then((response) => { + resolve(response.data) + }) + .catch((error) => { + reject(error) + }) + }) + } } export default Auth diff --git a/typings/main.d.ts b/typings/main.d.ts index 22bb0a0..ecc1f37 100644 --- a/typings/main.d.ts +++ b/typings/main.d.ts @@ -1,5 +1,4 @@ -// SpookVooper API - src/main.ts -// Written by Brendan Lane - https://brndnln.dev/ import User from './modules/User' import Group from './modules/Group' -export { User, Group } +import Auth from './modules/Auth' +export { User, Group, Auth } diff --git a/typings/modules/Auth.d.ts b/typings/modules/Auth.d.ts new file mode 100644 index 0000000..260b88c --- /dev/null +++ b/typings/modules/Auth.d.ts @@ -0,0 +1,17 @@ +import { AuthConfig } from './types/Types' +declare class Auth { + private readonly appsecret + private readonly code + private readonly appid + urlReturn: string + constructor (config: AuthConfig); + get clientsecret (): string; + set clientsecret (clientsecret: string); + get authcode (): string; + set authcode (authcode: string); + get clientid (): string; + set clientid (clientid: string); + genLink (redirect: string, scope: string, state?: string): string; + requestToken (redirect: string): Promise; +} +export default Auth diff --git a/typings/modules/Group.d.ts b/typings/modules/Group.d.ts index d17f051..0e7d580 100644 --- a/typings/modules/Group.d.ts +++ b/typings/modules/Group.d.ts @@ -1,14 +1,13 @@ import { AuthEntity, CreditAmount, GroupMember, PaymentEntity } from './types/Types' declare class Group { - // eslint-disable-next-line @typescript-eslint/prefer-readonly - private accountid - constructor (svid: string) - getGroup (): Promise - sendCredits (amount: CreditAmount, to: PaymentEntity, reason: string, auth: AuthEntity): Promise - doesGroupExist (): Promise - getGroupMembers (): Promise - hasGroupPermission (user: GroupMember, permission: string): Promise - get svid (): string - set svid (svid: string) + private readonly accountid + constructor (svid: string); + getGroup (): Promise; + sendCredits (amount: CreditAmount, to: PaymentEntity, reason: string, auth: AuthEntity): Promise; + doesGroupExist (): Promise; + getGroupMembers (): Promise; + hasGroupPermission (user: GroupMember, permission: string): Promise; + get svid (): string; + set svid (svid: string); } export default Group diff --git a/typings/modules/User.d.ts b/typings/modules/User.d.ts index d07dc31..1668195 100644 --- a/typings/modules/User.d.ts +++ b/typings/modules/User.d.ts @@ -1,21 +1,19 @@ import { CreditAmount, PaymentEntity, SVStockTicker } from './types/Types' import { ConfigUser } from './interfaces/Interfaces' declare class User { - // eslint-disable-next-line @typescript-eslint/prefer-readonly - private accountid - // eslint-disable-next-line @typescript-eslint/prefer-readonly - private authkey - constructor (config: ConfigUser) - getUser (): Promise - getUsername (): Promise - getBalance (): Promise - 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 - cancelOffer (orderid: number): Promise + private readonly accountid + private readonly authkey + constructor (config: ConfigUser); + getUser (): Promise; + getUsername (): Promise; + getBalance (): Promise; + 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; + cancelOffer (orderid: number): Promise; get apikey (): string; set apikey (apikey: string); get svid (): string; diff --git a/typings/modules/interfaces/Interfaces.d.ts b/typings/modules/interfaces/Interfaces.d.ts index e46bc03..c70f990 100644 --- a/typings/modules/interfaces/Interfaces.d.ts +++ b/typings/modules/interfaces/Interfaces.d.ts @@ -17,6 +17,12 @@ export interface ConfigUser { svid: string apikey?: string } + export interface EntityGroup { svid: string } + +export interface AuthConfig { + clientid: string + clientsecret: string +} diff --git a/typings/modules/types/Types.d.ts b/typings/modules/types/Types.d.ts index 423239b..199ab46 100644 --- a/typings/modules/types/Types.d.ts +++ b/typings/modules/types/Types.d.ts @@ -1,6 +1,7 @@ -import { EntityUser } from './../interfaces/Interfaces' +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