➕ Add Auth to SVAPI
This commit is contained in:
parent
c22fb92746
commit
bb4e28e5c9
|
@ -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
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
|
||||
import User from './modules/User'
|
||||
import Group from './modules/Group'
|
||||
import Auth from './modules/Auth'
|
||||
|
||||
export {
|
||||
User,
|
||||
Group
|
||||
Group,
|
||||
Auth
|
||||
}
|
||||
|
|
|
@ -59,6 +59,26 @@ class Auth {
|
|||
return this.urlReturn
|
||||
}
|
||||
}
|
||||
|
||||
public async requestToken (redirect: string): Promise<any> {
|
||||
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
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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<any>;
|
||||
}
|
||||
export default Auth
|
|
@ -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<any>
|
||||
sendCredits (amount: CreditAmount, to: PaymentEntity, reason: string, auth: AuthEntity): Promise<any>
|
||||
doesGroupExist (): Promise<any>
|
||||
getGroupMembers (): Promise<any>
|
||||
hasGroupPermission (user: GroupMember, permission: string): Promise<any>
|
||||
get svid (): string
|
||||
set svid (svid: string)
|
||||
private readonly accountid
|
||||
constructor (svid: string);
|
||||
getGroup (): Promise<any>;
|
||||
sendCredits (amount: CreditAmount, to: PaymentEntity, reason: string, auth: AuthEntity): Promise<any>;
|
||||
doesGroupExist (): Promise<any>;
|
||||
getGroupMembers (): Promise<any>;
|
||||
hasGroupPermission (user: GroupMember, permission: string): Promise<any>;
|
||||
get svid (): string;
|
||||
set svid (svid: string);
|
||||
}
|
||||
export default Group
|
||||
|
|
|
@ -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<any>
|
||||
getUsername (): Promise<any>
|
||||
getBalance (): Promise<any>
|
||||
hasDiscordRole (role: string): Promise<any>
|
||||
getDiscordRoles (): Promise<any>
|
||||
sendCredits (amount: CreditAmount, to: PaymentEntity, reason: string): Promise<any>
|
||||
getStockOffers (ticker: SVStockTicker): Promise<any>
|
||||
buyStock (ticker: SVStockTicker, amount: number, price: CreditAmount): Promise<any>
|
||||
sellStock (ticker: SVStockTicker, amount: number, price: CreditAmount): Promise<any>
|
||||
cancelOffer (orderid: number): Promise<any>
|
||||
private readonly accountid
|
||||
private readonly authkey
|
||||
constructor (config: ConfigUser);
|
||||
getUser (): Promise<any>;
|
||||
getUsername (): Promise<any>;
|
||||
getBalance (): Promise<any>;
|
||||
hasDiscordRole (role: string): Promise<any>;
|
||||
getDiscordRoles (): Promise<any>;
|
||||
sendCredits (amount: CreditAmount, to: PaymentEntity, reason: string): Promise<any>;
|
||||
getStockOffers (ticker: SVStockTicker): Promise<any>;
|
||||
buyStock (ticker: SVStockTicker, amount: number, price: CreditAmount): Promise<any>;
|
||||
sellStock (ticker: SVStockTicker, amount: number, price: CreditAmount): Promise<any>;
|
||||
cancelOffer (orderid: number): Promise<any>;
|
||||
get apikey (): string;
|
||||
set apikey (apikey: string);
|
||||
get svid (): string;
|
||||
|
|
|
@ -17,6 +17,12 @@ export interface ConfigUser {
|
|||
svid: string
|
||||
apikey?: string
|
||||
}
|
||||
|
||||
export interface EntityGroup {
|
||||
svid: string
|
||||
}
|
||||
|
||||
export interface AuthConfig {
|
||||
clientid: string
|
||||
clientsecret: string
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue