-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.ts
68 lines (54 loc) · 1.77 KB
/
auth.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import Request from "./src/utils/request";
interface Response {
success: boolean;
status: number;
message: string;
}
export default class OneRamp {
private publicKey: string;
private secretKey: string;
constructor(publicKey: string, secretKey: string) {
this.publicKey = publicKey;
this.secretKey = secretKey;
}
/*
Verify application creds middleware
This is a private function, and it will only be accessed and called from the class body
*/
private verifyCreds = async (): Promise<Response> => {
if (!this.publicKey || !this.secretKey) {
return {
success: false,
status: 404,
message: "No Credentials detected!",
};
}
const request = new Request();
/*
Extract the wanted store information from the db by matching the public and secret key that was entered
THIS LINE CAN BE REPLACED WITH AN EXTRACT CALL TO THE DB
*/
const data = {
clientId: this.publicKey,
secret: this.secretKey,
};
const authenticated = await request.db(data);
return authenticated;
};
async withDraw(): Promise<Response> {
const result = await this.verifyCreds();
/* This will return true when the user creds are available in the db and false if they're not available */
return result;
}
async deposit(): Promise<Response> {
const result = await this.verifyCreds();
/* This will return true when the user creds are available in the db and false if they're not available */
return result;
}
async transactions(): Promise<Response> {
const result = await this.verifyCreds();
/* This will return true when the user creds are available in the db and false if they're not available */
return result;
}
/* Add more functions here.... */
}