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

@vivse/frontend-library

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vivse/frontend-library - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

apollo/auth-token.d.ts

5

apollo/create-connection-link.d.ts

@@ -0,5 +1,6 @@

import { AuthToken } from "./auth-token";
export declare const createConnectionLink: ({ httpEndpoint, wsEndpoint, getAuthToken, }: {
httpEndpoint: string;
wsEndpoint: string;
getAuthToken: () => Promise<string | undefined | null> | string | undefined | null;
wsEndpoint?: string | undefined;
getAuthToken: () => Promise<AuthToken> | AuthToken;
}) => import("@apollo/client").ApolloLink;

33

apollo/create-connection-link.js

@@ -18,2 +18,3 @@ "use strict";

const graphql_ws_1 = require("graphql-ws");
const defs_1 = require("@vivse/shared-library/defs");
const createConnectionLink = ({ httpEndpoint, wsEndpoint, getAuthToken, }) => {

@@ -23,18 +24,28 @@ const httpLink = (0, client_1.createHttpLink)({

});
const wsLink = new subscriptions_1.GraphQLWsLink((0, graphql_ws_1.createClient)({
url: wsEndpoint,
}));
const splitLink = (0, client_1.split)(({ query }) => {
const definition = (0, utilities_1.getMainDefinition)(query);
return (definition.kind === "OperationDefinition" &&
definition.operation === "subscription");
}, wsLink, httpLink);
const wsLink = wsEndpoint &&
new subscriptions_1.GraphQLWsLink((0, graphql_ws_1.createClient)({
url: wsEndpoint,
}));
const connectionLink = wsLink
? (0, client_1.split)(({ query }) => {
const definition = (0, utilities_1.getMainDefinition)(query);
return (definition.kind === "OperationDefinition" &&
definition.operation === "subscription");
}, wsLink, httpLink)
: httpLink;
const authLink = (0, context_1.setContext)((_, { headers }) => __awaiter(void 0, void 0, void 0, function* () {
const token = yield getAuthToken();
const authToken = yield getAuthToken();
if (!authToken)
return {};
const { token, type } = authToken;
return {
headers: Object.assign(Object.assign({}, headers), { authorization: token ? `Bearer ${token}` : "" }),
headers: Object.assign(Object.assign({}, headers), { [type === "bearer" ? "Authorization" : defs_1.VERIFY_TOKEN_HEADER]: token
? type === "bearer"
? `Bearer ${token}`
: token
: "" }),
};
}));
return authLink.concat(splitLink);
return authLink.concat(connectionLink);
};
exports.createConnectionLink = createConnectionLink;
{
"name": "@vivse/frontend-library",
"version": "1.2.0",
"version": "1.2.1",
"description": "Library shared between react projects",

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

"@types/ramda": "^0.28.11",
"@vivse/shared-library": "1.1.4",
"graphql-ws": "^5.8.2",

@@ -28,2 +29,3 @@ "husky": "8.0.1",

"@apollo/client": "^3.6.6",
"@vivse/shared-library": "*",
"graphql-ws": "^5.8.2"

@@ -30,0 +32,0 @@ },

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