Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@subql/apollo-links

Package Overview
Dependencies
Maintainers
2
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@subql/apollo-links - npm Package Compare versions

Comparing version 0.5.5 to 0.5.6-0

3

dist/core/clusterAuthLink.d.ts
import { ApolloLink, FetchResult, NextLink, Observable, Operation } from '@apollo/client/core';
import { Logger } from '../utils/logger';
import OrderMananger from '../utils/orderManager';
import { Logger } from '../utils/logger';
export declare type AuthOptions = {

@@ -16,2 +16,3 @@ authUrl: string;

request(operation: Operation, forward?: NextLink): Observable<FetchResult> | null;
private tokenToAuthHeader;
private getRequestParams;

@@ -18,0 +19,0 @@ private getAgreementRequestParams;

@@ -8,4 +8,4 @@ "use strict";

const authHelper_1 = require("../auth/authHelper");
const types_1 = require("../types");
const query_1 = require("../utils/query");
const types_1 = require("../types");
class ClusterAuthLink extends core_1.ApolloLink {

@@ -26,4 +26,4 @@ constructor(options) {

if (data) {
const { token, url, type } = data;
const headers = { authorization: `${token}` };
const { authorization, url, type } = data;
const headers = { authorization };
operation.setContext({ url, headers, type });

@@ -40,2 +40,5 @@ }

}
tokenToAuthHeader(token) {
return { authorization: `Bearer ${token}` };
}
async getRequestParams() {

@@ -61,3 +64,3 @@ const orderType = await this.orderMananger.getNextOrderType();

if (!(0, authHelper_1.isTokenExpired)(token))
return { token, url, type };
return Object.assign({ url, type }, this.tokenToAuthHeader(token));
this.logger.debug(`request new token for indexer ${indexer}`);

@@ -73,3 +76,3 @@ const { projectId, authUrl } = this.options;

this.logger.debug(`request new token for indexer ${indexer} success`);
return { token: `Bearer ${res.token}`, url, type };
return Object.assign({ url, type }, this.tokenToAuthHeader(token));
}

@@ -90,5 +93,5 @@ async getPlanRequestParams() {

this.logger.debug(`state signature: ${signedState}`);
const token = JSON.stringify(signedState);
const authorization = JSON.stringify(signedState);
this.logger.debug(`request new state signature for indexer ${indexer} success`);
return { token, url, type };
return { authorization, url, type };
}

@@ -95,0 +98,0 @@ }

@@ -0,3 +1,3 @@

import { Agreement, OrderType, Plan, ProjectType } from '../types';
import { Logger } from './logger';
import { Agreement, ProjectType, Plan, OrderType } from '../types';
declare type Options = {

@@ -4,0 +4,0 @@ logger: Logger;

@@ -5,4 +5,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const types_1 = require("../types");
const query_1 = require("./query");
const types_1 = require("../types");
class OrderManager {

@@ -9,0 +9,0 @@ constructor(options) {

{
"name": "@subql/apollo-links",
"version": "0.5.5",
"version": "0.5.6-0",
"description": "SubQuery Network - graphql links",

@@ -28,3 +28,3 @@ "main": "dist/index.js",

},
"stableVersion": "0.5.3"
"stableVersion": "0.5.5"
}

@@ -8,6 +8,6 @@ // Copyright 2020-2022 SubQuery Pte Ltd authors & contributors

import { isTokenExpired } from '../auth/authHelper';
import { ChannelState, OrderType } from '../types';
import { Logger } from '../utils/logger';
import OrderMananger from '../utils/orderManager';
import { POST } from '../utils/query';
import { Logger } from '../utils/logger';
import { ChannelState, OrderType } from '../types';

@@ -23,3 +23,3 @@ export type AuthOptions = {

url: string;
token: string;
authorization: string;
type: OrderType;

@@ -48,4 +48,4 @@ };

if (data) {
const { token, url, type } = data;
const headers = { authorization: `${token}` };
const { authorization, url, type } = data;
const headers = { authorization };
operation.setContext({ url, headers, type });

@@ -65,2 +65,6 @@ }

private tokenToAuthHeader(token: string) {
return { authorization: `Bearer ${token}` };
}
private async getRequestParams(): Promise<RequestParams | undefined> {

@@ -85,6 +89,7 @@ const orderType = await this.orderMananger.getNextOrderType();

const { token, id, url, indexer } = nextAgreement;
if (!isTokenExpired(token)) return { token, url, type };
if (!isTokenExpired(token)) return { url, type, ...this.tokenToAuthHeader(token) };
this.logger.debug(`request new token for indexer ${indexer}`);
const { projectId, authUrl } = this.options;
const tokenUrl = new URL('/orders/token', authUrl);

@@ -99,3 +104,3 @@ const res = await POST<{ token: string }>(tokenUrl.toString(), {

this.logger.debug(`request new token for indexer ${indexer} success`);
return { token: `Bearer ${res.token}`, url, type };
return { url, type, ...this.tokenToAuthHeader(token) };
}

@@ -120,7 +125,7 @@

this.logger.debug(`state signature: ${signedState}`);
const token = JSON.stringify(signedState);
const authorization = JSON.stringify(signedState);
this.logger.debug(`request new state signature for indexer ${indexer} success`);
return { token, url, type };
return { authorization, url, type };
}
}
// Copyright 2020-2022 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { Agreement, OrderType, Plan, ProjectType } from '../types';
import { Logger } from './logger';
import { fetchOrders } from './query';
import { Agreement, ProjectType, Plan, OrderType } from '../types';

@@ -8,0 +8,0 @@ type Options = {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc