@metrichor/epi2me-client-node
Advanced tools
Comparing version 0.1.10010284 to 0.1.10205514
@@ -0,3 +1,5 @@ | ||
import type { Dictionary } from 'ts-runtime-typecheck'; | ||
import type { ClientOptions } from './ClientOptions.type'; | ||
export declare function common_headers(client: ClientOptions['client'], source_headers?: HeadersInit): Headers; | ||
export declare function common_headers(client: ClientOptions['client'], source_headers?: HeadersInit): Dictionary<string>; | ||
export declare function normalise_headers(headers?: HeadersInit): Dictionary<string>; | ||
//# sourceMappingURL=common_headers.d.ts.map |
@@ -1,2 +0,3 @@ | ||
export declare function compose_message(init: RequestInit, headers: Headers): string; | ||
import type { Dictionary } from 'ts-runtime-typecheck'; | ||
export declare function compose_message(init: RequestInit, headers: Dictionary<string>): string; | ||
//# sourceMappingURL=compose_message.d.ts.map |
@@ -1,12 +0,10 @@ | ||
export type { ErrorHandler } from '@apollo/client/link/error'; | ||
export type { ClientOptions } from './ClientOptions.type'; | ||
export type { MockResponse } from '../common/mock_client'; | ||
export type { DocumentNode } from 'graphql'; | ||
export type { TypedDocumentNode } from '@graphql-typed-document-node/core'; | ||
export type { ApolloCache, ApolloClient, FetchPolicy, QueryOptions, MutationOptions, ApolloQueryResult, OperationVariables, ObservableQuery, FetchResult, } from '@apollo/client/core'; | ||
export { DEFAULT_ENDPOINT } from './endpoint.constants'; | ||
import type { ApolloCache, ApolloClient } from '@apollo/client/core'; | ||
import type { ErrorHandler } from '@apollo/client/link/error'; | ||
import type { ClientOptions } from './ClientOptions.type'; | ||
import { DEFAULT_ENDPOINT } from './endpoint.constants'; | ||
export { resolve_endpoint } from './resolve_endpoint'; | ||
export { create_mock_client } from '../common/mock_client'; | ||
export { GraphQLError } from 'graphql'; | ||
export { ApolloError, isApolloError, gql } from '@apollo/client/core'; | ||
export { create_mock_client, MockResponse } from '../common/mock_client'; | ||
export { GraphQLError, DocumentNode } from 'graphql'; | ||
export { TypedDocumentNode } from '@graphql-typed-document-node/core'; | ||
export { DEFAULT_ENDPOINT, ClientOptions, ErrorHandler, ApolloClient, ApolloCache }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -0,3 +1,4 @@ | ||
import type { Dictionary } from 'ts-runtime-typecheck'; | ||
import type { ClientOptions } from './ClientOptions.type'; | ||
export declare function signature_headers(init: RequestInit, client: ClientOptions['client'], apikey: string): Headers; | ||
export declare function signature_headers(init: RequestInit, client: ClientOptions['client'], apikey: string): Dictionary<string>; | ||
//# sourceMappingURL=signature_headers.d.ts.map |
37
index.js
@@ -8,2 +8,3 @@ 'use strict'; | ||
var graphql = require('graphql'); | ||
require('@graphql-typed-document-node/core'); | ||
@@ -15,3 +16,3 @@ function sha1_digest(message, key) { | ||
function compose_message(init, headers) { | ||
const message_parts = [...headers] | ||
const message_parts = Object.entries(headers) | ||
.filter(([key]) => key.startsWith('x-epi2me')) | ||
@@ -30,9 +31,13 @@ .sort() | ||
function common_headers(client, source_headers) { | ||
const headers = new Headers(source_headers); | ||
headers.set('accept', 'application/json'); | ||
headers.set('content-type', 'application/json'); | ||
headers.set('x-epi2me-client', client.name); | ||
headers.set('x-epi2me-version', client.version); | ||
const headers = normalise_headers(source_headers); | ||
headers['accept'] = 'application/json'; | ||
headers['content-type'] = 'application/json'; | ||
headers['x-epi2me-client'] = client.name; | ||
headers['x-epi2me-version'] = client.version; | ||
return headers; | ||
} | ||
function normalise_headers(headers = {}) { | ||
const iterator = Symbol.iterator in headers ? headers : Object.entries(headers); | ||
return Object.fromEntries(Array.from(iterator, ([key, value]) => [key.toLowerCase(), value])); | ||
} | ||
@@ -42,5 +47,5 @@ function signature_headers(init, client, apikey) { | ||
const signature_date = new Date().toISOString(); | ||
headers.set('x-epi2me-apikey', apikey); | ||
headers.set('x-epi2me-signaturedate', signature_date); | ||
return headers; | ||
headers['x-epi2me-apikey'] = apikey; | ||
headers['x-epi2me-signaturedate'] = signature_date; | ||
return normalise_headers(headers); | ||
} | ||
@@ -52,3 +57,3 @@ | ||
const signature = sha1_digest(message, credentials.secret); | ||
headers.set('x-epi2me-signaturev0', signature); | ||
headers['x-epi2me-signaturev0'] = signature; | ||
return headers; | ||
@@ -224,14 +229,2 @@ } | ||
Object.defineProperty(exports, 'ApolloError', { | ||
enumerable: true, | ||
get: function () { return core.ApolloError; } | ||
}); | ||
Object.defineProperty(exports, 'gql', { | ||
enumerable: true, | ||
get: function () { return core.gql; } | ||
}); | ||
Object.defineProperty(exports, 'isApolloError', { | ||
enumerable: true, | ||
get: function () { return core.isApolloError; } | ||
}); | ||
Object.defineProperty(exports, 'GraphQLError', { | ||
@@ -238,0 +231,0 @@ enumerable: true, |
import type { NodeClientOptions } from './ClientOptions.type'; | ||
export declare function sign_message(init: RequestInit, { client, credentials }: NodeClientOptions): Headers; | ||
import type { Dictionary } from 'ts-runtime-typecheck'; | ||
export declare function sign_message(init: RequestInit, { client, credentials }: NodeClientOptions): Dictionary<string>; | ||
//# sourceMappingURL=sign_message.d.ts.map |
{ | ||
"name": "@metrichor/epi2me-client-node", | ||
"version": "0.1.10010284", | ||
"version": "0.1.10205514", | ||
"license": "MPL-2.0", | ||
@@ -11,2 +11,3 @@ "author": "Metrichor <support@nanoporetech.com>", | ||
"@apollo/client": "^3.7.6", | ||
"@graphql-typed-document-node/core": "^3.1.1", | ||
"graphql": "^16.6.0", | ||
@@ -13,0 +14,0 @@ "node-fetch": "^3.3.0" |
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
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
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
28505
4