-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from csfloat/feature/access-token-prover
Adds Access Token Prover
- Loading branch information
Showing
6 changed files
with
72 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {EmptyRequestHandler} from './main'; | ||
import {RequestType} from './types'; | ||
|
||
export interface MetaSettingsResponse { | ||
enable_auto_trade: boolean; | ||
} | ||
|
||
export const MetaSettings = new EmptyRequestHandler<MetaSettingsResponse>(RequestType.META_SETTINGS, async (req) => { | ||
const resp = await fetch(`https://csfloat.com/api/v1/meta/extension`, { | ||
credentials: 'include', | ||
}); | ||
|
||
if (resp.status !== 200) { | ||
throw new Error('invalid status'); | ||
} | ||
|
||
return resp.json() as Promise<MetaSettingsResponse>; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {EmptyRequestHandler, SimpleHandler} from './main'; | ||
import {RequestType} from './types'; | ||
|
||
export interface ProveTradesTokenRequest { | ||
token: string; | ||
} | ||
|
||
export interface ProveTradesTokenResponse { | ||
message: string; | ||
} | ||
|
||
export const ProveTradesToken = new SimpleHandler<ProveTradesTokenRequest, ProveTradesTokenResponse>( | ||
RequestType.PROVE_TRADES_TOKEN, | ||
async (req) => { | ||
const resp = await fetch(`https://csfloat.com/api/v1/trades/prove-token?token=${req.token}`, { | ||
credentials: 'include', | ||
}); | ||
|
||
if (resp.status !== 200) { | ||
throw new Error('failed to prove, are you logged into CSFloat?'); | ||
} | ||
|
||
return resp.json() as Promise<ProveTradesTokenResponse>; | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters