💻 Sync with laptop
This commit is contained in:
parent
3b4ab46b58
commit
c22fb92746
File diff suppressed because it is too large
Load Diff
|
@ -1,16 +1,64 @@
|
|||
// SpookVooper API - modules/Auth.ts
|
||||
// Written by Bryce Bauer and Brendan Lane - https://github.com/bluebeargreen-2 and https://brndnln.dev/
|
||||
|
||||
import axios from 'axios'
|
||||
import { AuthConfig } from './types/Types'
|
||||
|
||||
const authURL = 'https://spookvooper.com/oauth2'
|
||||
|
||||
class Auth {
|
||||
private clientsecret
|
||||
private authcode
|
||||
private clientid
|
||||
private appsecret: string
|
||||
private code: string
|
||||
private appid: string
|
||||
public urlReturn: string
|
||||
|
||||
constructor (clientid, clientsecret) {
|
||||
this.clientid = clientid
|
||||
this.clientsecret = clientsecret
|
||||
constructor (config: AuthConfig) {
|
||||
if (config.clientid === undefined || config.clientsecret === undefined) {
|
||||
throw new Error('The parans \'clientid\' and \'clientsecret\' must be defined')
|
||||
}
|
||||
|
||||
this.appid = config.clientid
|
||||
this.appsecret = config.clientsecret
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
public get clientsecret (): string {
|
||||
return this.appsecret
|
||||
}
|
||||
|
||||
public set clientsecret (clientsecret: string) {
|
||||
this.appsecret = clientsecret
|
||||
}
|
||||
|
||||
public get authcode (): string {
|
||||
return this.code
|
||||
}
|
||||
|
||||
public set authcode (authcode: string) {
|
||||
this.code = authcode
|
||||
}
|
||||
|
||||
public get clientid (): string {
|
||||
return this.appid
|
||||
}
|
||||
|
||||
public set clientid (clientid: string) {
|
||||
this.appid = clientid
|
||||
}
|
||||
|
||||
public genLink (redirect: string, scope: string, state?: string): string {
|
||||
if (redirect === undefined || scope === undefined) {
|
||||
throw new Error('Arguments \'redirect\' and \'scope\' are required')
|
||||
} else if (state === undefined) {
|
||||
state = ''
|
||||
this.urlReturn = `${authURL}/authorize?response_type=code&client_id=${this.clientid}&redirect_uri=${redirect}&scope=${scope}&state=${state}`
|
||||
this.urlReturn = this.urlReturn.split(' ').join('%20')
|
||||
return this.urlReturn
|
||||
} else {
|
||||
this.urlReturn = `${authURL}/authorize?response_type=code&client_id=${this.clientid}&redirect_uri=${redirect}&scope=${scope}&state=${state}`
|
||||
this.urlReturn = this.urlReturn.split(' ').join('%20')
|
||||
return this.urlReturn
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Auth
|
||||
|
|
|
@ -11,8 +11,8 @@ export interface EntityUser {
|
|||
getStockOffers: () => Promise<any>
|
||||
buyStock: () => Promise<any>
|
||||
sellStock: () => Promise<any>
|
||||
readonly svid: string
|
||||
readonly apikey: string
|
||||
svid: string
|
||||
apikey: string
|
||||
}
|
||||
|
||||
export interface ConfigUser {
|
||||
|
@ -23,3 +23,8 @@ export interface ConfigUser {
|
|||
export interface EntityGroup {
|
||||
svid: string
|
||||
}
|
||||
|
||||
export interface AuthConfig {
|
||||
clientid: string
|
||||
clientsecret: string
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
// SpookVooper API - modules/types/Types.ts
|
||||
// Written by Brendan Lane - https://brndnln.dev/
|
||||
|
||||
import { EntityUser } from './../interfaces/Interfaces'
|
||||
import { EntityUser, AuthConfig as AuthConfigInt } from './../interfaces/Interfaces'
|
||||
|
||||
export type CreditAmount = string | number
|
||||
export type PaymentEntity = string | EntityUser
|
||||
export type SVStockTicker = 'B' | 'IDE' | 'NEWS' | 'POT' | 'TECH' | 'TYCO' | 'VC' | 'VNB' | 'VU' | 'X'
|
||||
export type AuthEntity = EntityUser
|
||||
export type GroupMember = string | EntityUser
|
||||
export type AuthConfig = AuthConfigInt
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// 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 User from './modules/User'
|
||||
import Group from './modules/Group'
|
||||
export { User, Group }
|
||||
|
|
Loading…
Reference in New Issue