💻 Sync with laptop
This commit is contained in:
parent
831d581e19
commit
7fb8121533
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 axios from 'axios'
|
||||||
|
import { AuthConfig } from './types/Types'
|
||||||
|
|
||||||
const authURL = 'https://spookvooper.com/oauth2'
|
const authURL = 'https://spookvooper.com/oauth2'
|
||||||
|
|
||||||
class Auth {
|
class Auth {
|
||||||
private clientsecret
|
private appsecret: string
|
||||||
private authcode
|
private code: string
|
||||||
private clientid
|
private appid: string
|
||||||
|
public urlReturn: string
|
||||||
|
|
||||||
constructor (clientid, clientsecret) {
|
constructor (config: AuthConfig) {
|
||||||
this.clientid = clientid
|
if (config.clientid === undefined || config.clientsecret === undefined) {
|
||||||
this.clientsecret = clientsecret
|
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>
|
getStockOffers: () => Promise<any>
|
||||||
buyStock: () => Promise<any>
|
buyStock: () => Promise<any>
|
||||||
sellStock: () => Promise<any>
|
sellStock: () => Promise<any>
|
||||||
readonly svid: string
|
svid: string
|
||||||
readonly apikey: string
|
apikey: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConfigUser {
|
export interface ConfigUser {
|
||||||
|
@ -23,3 +23,8 @@ export interface ConfigUser {
|
||||||
export interface EntityGroup {
|
export interface EntityGroup {
|
||||||
svid: string
|
svid: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AuthConfig {
|
||||||
|
clientid: string
|
||||||
|
clientsecret: string
|
||||||
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
// SpookVooper API - modules/types/Types.ts
|
// SpookVooper API - modules/types/Types.ts
|
||||||
// Written by Brendan Lane - https://brndnln.dev/
|
// 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 CreditAmount = string | number
|
||||||
export type PaymentEntity = string | EntityUser
|
export type PaymentEntity = string | EntityUser
|
||||||
export type SVStockTicker = 'B' | 'IDE' | 'NEWS' | 'POT' | 'TECH' | 'TYCO' | 'VC' | 'VNB' | 'VU' | 'X'
|
export type SVStockTicker = 'B' | 'IDE' | 'NEWS' | 'POT' | 'TECH' | 'TYCO' | 'VC' | 'VNB' | 'VU' | 'X'
|
||||||
export type AuthEntity = EntityUser
|
export type AuthEntity = EntityUser
|
||||||
export type GroupMember = string | EntityUser
|
export type GroupMember = string | EntityUser
|
||||||
|
export type AuthConfig = AuthConfigInt
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// SpookVooper API - src/main.ts
|
// SpookVooper API - src/main.ts
|
||||||
// Written by Brendan Lane - https://brndnln.dev/
|
// Written by Brendan Lane - https://brndnln.dev/
|
||||||
import User from './modules/User';
|
import User from './modules/User'
|
||||||
import Group from './modules/Group';
|
import Group from './modules/Group'
|
||||||
export { User, Group };
|
export { User, Group }
|
||||||
|
|
Loading…
Reference in New Issue