@polymarket/relayer-client 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/handler.js +12 -8
- package/dist/client.js +1 -0
- package/dist/http-helpers/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/auth/handler.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AuthHandler = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
/* eslint-disable max-depth */
|
|
6
|
+
const browser_or_node_1 = require("browser-or-node");
|
|
5
7
|
const http_helpers_1 = require("../http-helpers");
|
|
6
8
|
const POLYMARKET_COOKIE_NAME = "polymarket";
|
|
7
9
|
class AuthHandler {
|
|
@@ -22,15 +24,17 @@ class AuthHandler {
|
|
|
22
24
|
if (this.cookie == undefined) {
|
|
23
25
|
// Logging in will set the session cookies on the httpClient
|
|
24
26
|
const resp = yield this.httpClient.send(`${this.url}/login`, http_helpers_1.GET, { Authorization: `Bearer ${this.token}` });
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
if (!browser_or_node_1.isBrowser) {
|
|
28
|
+
const cookies = resp.headers['set-cookie'];
|
|
29
|
+
let aggregatedCookie = "";
|
|
30
|
+
for (const cookie of cookies) {
|
|
31
|
+
if (cookie.includes(POLYMARKET_COOKIE_NAME)) {
|
|
32
|
+
aggregatedCookie += `${cookie}; `;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (aggregatedCookie != "") {
|
|
36
|
+
this.cookie = aggregatedCookie;
|
|
30
37
|
}
|
|
31
|
-
}
|
|
32
|
-
if (aggregatedCookie != "") {
|
|
33
|
-
this.cookie = aggregatedCookie;
|
|
34
38
|
}
|
|
35
39
|
console.log(`Successfully logged in!`);
|
|
36
40
|
}
|
package/dist/client.js
CHANGED
|
@@ -116,6 +116,7 @@ class RelayClient {
|
|
|
116
116
|
}
|
|
117
117
|
send(endpoint, method, headers, data, params) {
|
|
118
118
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
// ensure the
|
|
119
120
|
yield this.authHandler.login();
|
|
120
121
|
// If client is instantiated locally/not on the browser, explicitly inject the polymarket session cookies
|
|
121
122
|
// this is to ensure examples still run locally
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxiosInstance, Method } from "axios";
|
|
1
|
+
import { AxiosInstance, AxiosResponse, Method } from "axios";
|
|
2
2
|
export declare const GET = "GET";
|
|
3
3
|
export declare const POST = "POST";
|
|
4
4
|
export declare const DELETE = "DELETE";
|
|
@@ -6,5 +6,5 @@ export declare const PUT = "PUT";
|
|
|
6
6
|
export declare class HttpClient {
|
|
7
7
|
readonly instance: AxiosInstance;
|
|
8
8
|
constructor();
|
|
9
|
-
send(endpoint: string, method: Method, headers?: any, data?: any, params?: any): Promise<
|
|
9
|
+
send(endpoint: string, method: Method, headers?: any, data?: any, params?: any): Promise<AxiosResponse>;
|
|
10
10
|
}
|