@subql/apollo-links
Advanced tools
Comparing version 1.0.9-0 to 1.1.0
@@ -10,2 +10,6 @@ # Changelog | ||
## [1.1.0] - 2023-10-13 | ||
- Support new communication protocol | ||
## [1.0.8] - 2023-09-07 | ||
@@ -82,3 +86,4 @@ | ||
[unreleased]: https://github.com/subquery/network-clients/compare/v1.0.8...HEAD | ||
[unreleased]: https://github.com/subquery/network-clients/compare/v1.1.0...HEAD | ||
[1.1.0]: https://github.com/subquery/network-clients/compare/v1.0.8...v1.1.0 | ||
[1.0.8]: https://github.com/subquery/network-clients/compare/v1.0.4...v1.0.8 | ||
@@ -85,0 +90,0 @@ [1.0.4]: https://github.com/subquery/network-clients/compare/v1.0.2...v1.0.4 |
@@ -9,2 +9,3 @@ "use strict"; | ||
const types_1 = require("../types"); | ||
const js_base64_1 = require("js-base64"); | ||
class ResponseLink extends core_1.ApolloLink { | ||
@@ -20,10 +21,15 @@ constructor(option) { | ||
async syncChannelState(state) { | ||
var _a, _b; | ||
var _a, _b, _c; | ||
try { | ||
const stateUrl = new URL('/channel/state', this.options.authUrl); | ||
await (0, query_1.POST)(stateUrl.toString(), state); | ||
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`syncChannelState succeed`); | ||
const res = await (0, query_1.POST)(stateUrl.toString(), state); | ||
if (res.consumerSign) { | ||
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`syncChannelState succeed`); | ||
} | ||
else { | ||
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.debug(`syncChannelState failed: ${JSON.stringify(res)}`); | ||
} | ||
} | ||
catch (e) { | ||
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.debug(`syncChannelState failed: ${e}`); | ||
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug(`syncChannelState failed: ${e}`); | ||
} | ||
@@ -39,3 +45,7 @@ } | ||
if (!response.errors && type === types_1.OrderType.flexPlan) { | ||
void this.syncChannelState(response.state); | ||
const responseHeaders = operation.getContext().response.headers; | ||
const channelState = responseHeaders.get('X-Channel-State') | ||
? JSON.parse(js_base64_1.Base64.decode(responseHeaders.get('X-Channel-State')).toString()) | ||
: response.state; | ||
void this.syncChannelState(channelState); | ||
} | ||
@@ -42,0 +52,0 @@ observer.next(response); |
{ | ||
"name": "@subql/apollo-links", | ||
"version": "1.0.9-0", | ||
"version": "1.1.0", | ||
"description": "SubQuery Network - graphql links", | ||
@@ -18,2 +18,3 @@ "main": "dist/index.js", | ||
"ethers": "^5.6.8", | ||
"js-base64": "^3.7.5", | ||
"jwt-decode": "^3.1.2", | ||
@@ -20,0 +21,0 @@ "lru-cache": "^10.0.1" |
@@ -8,2 +8,3 @@ // Copyright 2020-2022 SubQuery Pte Ltd authors & contributors | ||
import { ChannelState, OrderType } from '../types'; | ||
import { Base64 } from 'js-base64'; | ||
@@ -30,4 +31,9 @@ export type ResponseLinkOptions = { | ||
const stateUrl = new URL('/channel/state', this.options.authUrl); | ||
await POST(stateUrl.toString(), state); | ||
this.logger?.debug(`syncChannelState succeed`); | ||
const res = await POST<{ consumerSign: string }>(stateUrl.toString(), state); | ||
if (res.consumerSign) { | ||
this.logger?.debug(`syncChannelState succeed`); | ||
} else { | ||
this.logger?.debug(`syncChannelState failed: ${JSON.stringify(res)}`); | ||
} | ||
} catch (e) { | ||
@@ -47,3 +53,9 @@ this.logger?.debug(`syncChannelState failed: ${e}`); | ||
if (!response.errors && type === OrderType.flexPlan) { | ||
void this.syncChannelState(response.state); | ||
const responseHeaders = operation.getContext().response.headers; | ||
const channelState = responseHeaders.get('X-Channel-State') | ||
? (JSON.parse( | ||
Base64.decode(responseHeaders.get('X-Channel-State')).toString() | ||
) as ChannelState) | ||
: response.state; | ||
void this.syncChannelState(channelState); | ||
} | ||
@@ -50,0 +62,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
211571
1958
1
11
+ Addedjs-base64@^3.7.5
+ Addedjs-base64@3.7.7(transitive)