@polymarket/relayer-client 0.0.9 → 0.0.10

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.
@@ -2,8 +2,6 @@
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");
7
5
  const http_helpers_1 = require("../http-helpers");
8
6
  const POLYMARKET_COOKIE_NAME = "polymarket";
9
7
  class AuthHandler {
@@ -24,18 +22,16 @@ class AuthHandler {
24
22
  if (this.cookie == undefined) {
25
23
  // Logging in will set the session cookies on the httpClient
26
24
  const resp = yield this.httpClient.send(`${this.url}/login`, http_helpers_1.GET, { Authorization: `Bearer ${this.token}` });
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;
25
+ const cookies = resp.headers['set-cookie'];
26
+ let aggregatedCookie = "";
27
+ for (const cookie of cookies) {
28
+ if (cookie.includes(POLYMARKET_COOKIE_NAME)) {
29
+ aggregatedCookie += `${cookie}; `;
37
30
  }
38
31
  }
32
+ if (aggregatedCookie != "") {
33
+ this.cookie = aggregatedCookie;
34
+ }
39
35
  console.log(`Successfully logged in!`);
40
36
  }
41
37
  });
package/dist/client.js CHANGED
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RelayClient = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const ethers_1 = require("ethers");
6
- const browser_or_node_1 = require("browser-or-node");
7
6
  const http_helpers_1 = require("./http-helpers");
8
7
  const types_1 = require("./types");
9
8
  const endpoints_1 = require("./endpoints");
@@ -116,20 +115,16 @@ class RelayClient {
116
115
  }
117
116
  send(endpoint, method, headers, data, params) {
118
117
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
119
- // ensure the
120
- yield this.authHandler.login();
121
- // If client is instantiated locally/not on the browser, explicitly inject the polymarket session cookies
122
- // this is to ensure examples still run locally
123
- if (!browser_or_node_1.isBrowser) {
124
- const cookie = yield this.authHandler.getPolymarketCookies();
125
- if (headers != undefined) {
126
- headers["Cookie"] = cookie;
127
- }
128
- else {
129
- headers = { "Cookie": cookie };
130
- }
118
+ // Explicitly inject the polymarket session cookies
119
+ // In prod environments, this will be unnecessary as the browser will have the needed cookies
120
+ // Needed only for local testing
121
+ const cookie = yield this.authHandler.getPolymarketCookies();
122
+ if (headers != undefined) {
123
+ headers["Cookie"] = cookie;
124
+ }
125
+ else {
126
+ headers = { "Cookie": cookie };
131
127
  }
132
- // If the client is instantiated on the browser, do not inject cookies
133
128
  const resp = yield this.httpClient.send(endpoint, method, headers, data, params);
134
129
  return resp.data;
135
130
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@polymarket/relayer-client",
3
3
  "description": "Client for Polymarket relayers",
4
- "version": "0.0.9",
4
+ "version": "0.0.10",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [