@metrichor/epi2me-client-node
Advanced tools
Comparing version 0.1.10209158 to 0.1.10211367
@@ -11,3 +11,3 @@ import type { Dictionary } from 'ts-runtime-typecheck'; | ||
}; | ||
export type RestrictedFetch = (url: string, info?: RestrictedRequestInfo) => Promise<RestrictedResponse>; | ||
export type RestrictedFetch = (url: string, info: RestrictedRequestInfo) => Promise<RestrictedResponse>; | ||
//# sourceMappingURL=restricted_fetch.type.d.ts.map |
17
index.js
@@ -212,2 +212,15 @@ 'use strict'; | ||
async function session_jwt_common(fetcher, endpoint = DEFAULT_ENDPOINT) { | ||
const uri = new URL('validate', resolve_endpoint(endpoint)); | ||
const res = await fetcher(uri.toString(), { method: 'POST' }); | ||
if (!res.ok) { | ||
throw new Error(res.statusText); | ||
} | ||
const data = await res.json(); | ||
if (!data.valid || typeof data.jwt !== 'string') { | ||
throw new Error('Invalid credentials'); | ||
} | ||
return data.jwt; | ||
} | ||
function create_epi2me_client_jwt(options, on_error) { | ||
@@ -245,2 +258,5 @@ var _a; | ||
} | ||
function session_jwt(options) { | ||
return session_jwt_common((uri, info) => authenticated_fetch(uri, info, options), options.endpoint); | ||
} | ||
@@ -270,1 +286,2 @@ Object.defineProperty(exports, 'ApolloError', { | ||
exports.resolve_endpoint = resolve_endpoint; | ||
exports.session_jwt = session_jwt; |
@@ -9,4 +9,5 @@ import { ApolloClient } from '@apollo/client/core'; | ||
export declare function authenticated_fetch(info: RequestInfo, init: RequestInit, options: NodeClientOptions): Promise<Response>; | ||
export declare function session_jwt(options: NodeClientOptions): Promise<string>; | ||
export * from '../common/index'; | ||
export { NodeClientOptions, NodeClientJWTOptions }; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@metrichor/epi2me-client-node", | ||
"version": "0.1.10209158", | ||
"version": "0.1.10211367", | ||
"license": "MPL-2.0", | ||
@@ -5,0 +5,0 @@ "author": "Metrichor <support@nanoporetech.com>", |
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
35890
40
621