New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@therms/rpc-client

Package Overview
Dependencies
Maintainers
4
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@therms/rpc-client - npm Package Compare versions

Comparing version 2.1.2 to 2.2.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

# [2.2.0](http://bitbucket.org/thermsio/rpc-client-ts/compare/v2.1.2...v2.2.0) (2021-10-02)
### Features
* added registerResponseInterceptor registerRequestInterceptor for adding additional interceptors after initialization ([72ac5be](http://bitbucket.org/thermsio/rpc-client-ts/commits/72ac5bec8a726be5503c8e089d855c88aa91244a))
## [2.1.2](http://bitbucket.org/thermsio/rpc-client-ts/compare/v2.1.1...v2.1.2) (2021-10-01)

@@ -2,0 +9,0 @@

50

dist/cjs.js

@@ -159,3 +159,3 @@ 'use strict';

}
return (...args) => undefined;
return (() => undefined);
};

@@ -169,4 +169,4 @@

interceptors = {
request: undefined,
response: undefined,
request: [],
response: [],
};

@@ -177,6 +177,20 @@ transports;

this.cache = options.cache;
this.interceptors.request = options.requestInterceptor;
this.interceptors.response = options.responseInterceptor;
if (options.requestInterceptor) {
this.interceptors.request.push(options.requestInterceptor);
}
if (options.responseInterceptor) {
this.interceptors.response.push(options.responseInterceptor);
}
this.transports = options.transports;
}
addResponseInterceptor = (interceptor) => {
if (typeof interceptor !== 'function')
throw new Error('cannot add interceptor that is not a function');
this.interceptors.response.push(interceptor);
};
addRequestInterceptor = (interceptor) => {
if (typeof interceptor !== 'function')
throw new Error('cannot add interceptor that is not a function');
this.interceptors.request.push(interceptor);
};
clearCache = (request) => {

@@ -241,5 +255,7 @@ debug$3('clearCache');

let request = originalRequest;
if (this.interceptors.request) {
debug$3('interceptRequestMutator', originalRequest);
request = await this.interceptors.request(originalRequest);
if (this.interceptors.request.length) {
debug$3('interceptRequestMutator(), original request:', originalRequest);
for (const interceptor of this.interceptors.request) {
request = await interceptor(request);
}
}

@@ -250,5 +266,13 @@ return request;

let response = originalResponse;
if (this.interceptors.response) {
if (this.interceptors.response.length) {
debug$3('interceptResponseMutator', request, originalResponse);
response = await this.interceptors.response(originalResponse, request);
for (const interceptor of this.interceptors.response) {
try {
response = await interceptor(response, request);
}
catch (e) {
debug$3('caught response interceptor, request:', request, 'original response:', originalResponse, 'mutated response:', response);
throw e;
}
}
}

@@ -733,2 +757,8 @@ return response;

};
registerResponseInterceptor = (responseInterceptor) => {
this.callManager.addResponseInterceptor(responseInterceptor);
};
registerRequestInterceptor = (requestInterceptor) => {
this.callManager.addRequestInterceptor(requestInterceptor);
};
setIdentity = (identity) => {

@@ -735,0 +765,0 @@ this.identity = identity;

4

dist/manager/ClientManager.d.ts

@@ -16,2 +16,4 @@ import { Cache } from '../cache/Cache';

export interface ClientManager {
addResponseInterceptor(interceptor: CallResponseInterceptor): void;
addRequestInterceptor(interceptor: CallRequestInterceptor): void;
clearCache(request?: CallRequestDTO): void;

@@ -30,2 +32,4 @@ getCachedResponse(request: CallRequestDTO): CallResponseDTO | undefined;

constructor(options: ClientManagerOptions);
addResponseInterceptor: (interceptor: CallResponseInterceptor) => void;
addRequestInterceptor: (interceptor: CallRequestInterceptor) => void;
clearCache: (request?: CallRequestDTO<any> | undefined) => void;

@@ -32,0 +36,0 @@ getCachedResponse: (request: CallRequestDTO<any>) => CallResponseDTO<any> | undefined;

@@ -14,4 +14,4 @@ import { CallRequestError } from '../errors/CallRequestError.js';

interceptors = {
request: undefined,
response: undefined,
request: [],
response: [],
};

@@ -22,6 +22,20 @@ transports;

this.cache = options.cache;
this.interceptors.request = options.requestInterceptor;
this.interceptors.response = options.responseInterceptor;
if (options.requestInterceptor) {
this.interceptors.request.push(options.requestInterceptor);
}
if (options.responseInterceptor) {
this.interceptors.response.push(options.responseInterceptor);
}
this.transports = options.transports;
}
addResponseInterceptor = (interceptor) => {
if (typeof interceptor !== 'function')
throw new Error('cannot add interceptor that is not a function');
this.interceptors.response.push(interceptor);
};
addRequestInterceptor = (interceptor) => {
if (typeof interceptor !== 'function')
throw new Error('cannot add interceptor that is not a function');
this.interceptors.request.push(interceptor);
};
clearCache = (request) => {

@@ -86,5 +100,7 @@ debug('clearCache');

let request = originalRequest;
if (this.interceptors.request) {
debug('interceptRequestMutator', originalRequest);
request = await this.interceptors.request(originalRequest);
if (this.interceptors.request.length) {
debug('interceptRequestMutator(), original request:', originalRequest);
for (const interceptor of this.interceptors.request) {
request = await interceptor(request);
}
}

@@ -95,5 +111,13 @@ return request;

let response = originalResponse;
if (this.interceptors.response) {
if (this.interceptors.response.length) {
debug('interceptResponseMutator', request, originalResponse);
response = await this.interceptors.response(originalResponse, request);
for (const interceptor of this.interceptors.response) {
try {
response = await interceptor(response, request);
}
catch (e) {
debug('caught response interceptor, request:', request, 'original response:', originalResponse, 'mutated response:', response);
throw e;
}
}
}

@@ -100,0 +124,0 @@ return response;

@@ -15,2 +15,4 @@ import { CallRequestDTO } from './CallRequestDTO';

makeProcedure<Args = any, Data = any>(request: CallRequestDTO<Args> | string): (args?: any) => Promise<CallResponseDTO<Data>>;
registerResponseInterceptor(responseInterceptor: CallResponseInterceptor): void;
registerRequestInterceptor(requestInterceptor: CallRequestInterceptor): void;
setIdentity(identity?: Identity): void;

@@ -49,4 +51,6 @@ }

makeProcedure: <Args = any, Data = any>(request: string | CallRequestDTO<Args>) => (args?: any) => Promise<CallResponseDTO<Data>>;
registerResponseInterceptor: (responseInterceptor: CallResponseInterceptor) => void;
registerRequestInterceptor: (requestInterceptor: CallRequestInterceptor) => void;
setIdentity: (identity?: Identity | undefined) => void;
}
//# sourceMappingURL=RPCClient.d.ts.map

@@ -127,2 +127,8 @@ import { CallRequestDTO } from './CallRequestDTO.js';

};
registerResponseInterceptor = (responseInterceptor) => {
this.callManager.addResponseInterceptor(responseInterceptor);
};
registerRequestInterceptor = (requestInterceptor) => {
this.callManager.addRequestInterceptor(requestInterceptor);
};
setIdentity = (identity) => {

@@ -129,0 +135,0 @@ this.identity = identity;

@@ -16,3 +16,3 @@ let lsDebug = null;

}
return (...args) => undefined;
return (() => undefined);
};

@@ -19,0 +19,0 @@

{
"name": "@therms/rpc-client",
"version": "2.1.2",
"version": "2.2.0",
"description": "RPC framework, browser client lib",

@@ -5,0 +5,0 @@ "private": false,

@@ -74,3 +74,3 @@ {

"include": ["src/**/*"],
"exclude": ["dist/*", "node_modules/*", "example/**/*", "spec/*"]
"exclude": ["dist/*", "node_modules/*", "example/**/*", "spec/**/*"]
}

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

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