Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected applyUnpatch(): void {
// Only Client and Server constructors will be unwrapped. Any existing
// Client or Server instances will still trace
shimmer.unwrap(this.moduleExports, 'createServer');
shimmer.unwrap(this.moduleExports, 'createSecureServer');
shimmer.unwrap(this.moduleExports, 'connect');
}
_cacheClientFromJSON: typeof writer.authClient.fromJSON;
},
'_cacheClientFromJSON',
cacheClientFromJSON => {
return function(
this: GoogleAuth,
json: JWTInput,
options?: RefreshOptions
) {
capturedJson = json;
return cacheClientFromJSON.call(this, json, options);
};
}
);
await writer.authClient.getClient();
shimmer.unwrap(
writer.authClient as typeof writer.authClient & {
_cacheClientFromJSON: typeof writer.authClient.fromJSON;
},
'_cacheClientFromJSON'
);
return capturedJson;
};
afterEach(function () {
shimmer.unwrap(Observable.prototype, 'backoff')
shimmer.unwrap(Function.prototype, 'bind')
})
function unpatchMethod(mod: typeof http | typeof https, method: "get" | "request") {
if (mod[method].__wrapped !== undefined) {
shimmer.unwrap(mod, method);
}
}
return function patchedCreateServer(
this: Http2Plugin
): http2.Http2Server {
const server = original.apply(this, arguments);
shimmer.wrap(
server.constructor.prototype,
'emit',
plugin.getPatchEmitFunction()
);
shimmer.unwrap(plugin.moduleExports, 'createServer');
shimmer.unwrap(plugin.moduleExports, 'createSecureServer');
return server;
};
};
protected applyUnpatch(): void {
shimmer.unwrap(this.moduleExports, 'request');
if (semver.satisfies(this.version, '>=8.0.0')) {
shimmer.unwrap(this.moduleExports, 'get');
}
if (
this.moduleExports &&
this.moduleExports.Server &&
this.moduleExports.Server.prototype
) {
shimmer.unwrap(this.moduleExports.Server.prototype, 'emit');
}
}
applyUnpatch(): void {
if (semver.lt(this.version, '2.6.0')) return;
shimmer.unwrap(
this.moduleExports.RedisClient.prototype,
'internal_send_command'
);
shimmer.unwrap(this.moduleExports, 'createClient');
shimmer.unwrap(this.moduleExports.RedisClient.prototype, 'create_stream');
}
protected applyUnpatch(): void {
if (
this.moduleExports &&
this.moduleExports.Server &&
this.moduleExports.Server.prototype
) {
shimmer.unwrap(
this.moduleExports &&
this.moduleExports.Server &&
this.moduleExports.Server.prototype,
'emit'
);
}
shimmer.unwrap(this.moduleExports, 'request');
if (semver.satisfies(this.version, '>=8.0.0')) {
shimmer.unwrap(this.moduleExports, 'get');
}
}
}
applyUnpatch (): void {
shimmer.unwrap(this.moduleExports.Server.prototype, 'insert')
shimmer.unwrap(this.moduleExports.Server.prototype, 'remove')
shimmer.unwrap(this.moduleExports.Server.prototype, 'command')
shimmer.unwrap(this.moduleExports.Server.prototype, 'update')
shimmer.unwrap(this.moduleExports.Cursor.prototype, 'next')
if (this.internalFilesExports.ConnectionPool) {
shimmer.unwrap(this.internalFilesExports.ConnectionPool.prototype, 'once')
}
}
unpatch: function(mongo) {
shimmer.unwrap(mongo.Server.prototype, 'command');
shimmer.unwrap(mongo.Server.prototype, 'insert');
shimmer.unwrap(mongo.Server.prototype, 'update');
shimmer.unwrap(mongo.Server.prototype, 'remove');
shimmer.unwrap(mongo.Cursor.prototype, 'next');
}
}