Socket
Socket
Sign inDemoInstall

@loopback/context

Package Overview
Dependencies
14
Maintainers
9
Versions
191
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.15.1 to 3.16.0

16

CHANGELOG.md

@@ -6,2 +6,18 @@ # Change Log

# [3.16.0](https://github.com/strongloop/loopback-next/compare/@loopback/context@3.15.1...@loopback/context@3.16.0) (2021-05-03)
### Bug Fixes
* **context:** ensure non-proxy value is cached for bindings ([96cf5da](https://github.com/strongloop/loopback-next/commit/96cf5da1c82017d31f24d6f93f90d1543bee887c))
### Features
* support node v16 ([ac99415](https://github.com/strongloop/loopback-next/commit/ac994154543bde22b4482ba98813351656db1b55))
## [3.15.1](https://github.com/strongloop/loopback-next/compare/@loopback/context@3.15.0...@loopback/context@3.15.1) (2021-04-06)

@@ -8,0 +24,0 @@

1

dist/binding.d.ts

@@ -350,2 +350,3 @@ /// <reference types="node" />

getValue(ctx: Context, options?: ResolutionOptions): ValueOrPromise<T | undefined>;
private getValueOrProxy;
/**

@@ -352,0 +353,0 @@ * Locate and validate the resolution context

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

getValue(ctx, optionsOrSession) {
var _a;
/* istanbul ignore if */

@@ -303,2 +304,4 @@ if (debug.enabled) {

return undefined;
// Keep a snapshot for proxy
const savedSession = (_a = resolution_session_1.ResolutionSession.fork(options.session)) !== null && _a !== void 0 ? _a : new resolution_session_1.ResolutionSession();
// First check cached value for non-transient

@@ -308,3 +311,4 @@ if (this._cache) {

if (resolutionCtx && this._cache.has(resolutionCtx)) {
return this._cache.get(resolutionCtx);
const value = this._cache.get(resolutionCtx);
return this.getValueOrProxy(resolutionCtx, { ...options, session: savedSession }, value);
}

@@ -320,3 +324,8 @@ }

const result = resolution_session_1.ResolutionSession.runWithBinding(s => {
const optionsWithSession = { ...options, session: s };
const optionsWithSession = {
...options,
session: s,
// Force to be the non-proxy version
asProxyWithInterceptors: false,
};
// We already test `this._getValue` is a function. It's safe to assert

@@ -329,3 +338,4 @@ // that `this._getValue` is not undefined.

}, this, options.session);
return this._cacheValue(resolutionCtx, result);
const value = this._cacheValue(resolutionCtx, result);
return this.getValueOrProxy(resolutionCtx, { ...options, session: savedSession }, value);
}

@@ -337,2 +347,11 @@ // `@inject.binding` adds a binding without _getValue

}
getValueOrProxy(resolutionCtx, options, value) {
const session = options.session;
session.pushBinding(this);
return Binding.valueOrProxy({
context: resolutionCtx,
binding: this,
options,
}, value);
}
/**

@@ -339,0 +358,0 @@ * Locate and validate the resolution context

64

package.json
{
"name": "@loopback/context",
"version": "3.15.1",
"description": "Facilities to manage artifacts and their dependencies in your Node.js applications. The module exposes TypeScript/JavaScript APIs and decorators to register artifacts, declare dependencies, and resolve artifacts by keys. It also serves as an IoC container to support dependency injection",
"version": "3.16.0",
"keywords": [
"LoopBack",
"IoC",
"Inversion",
"Control",
"Container",
"Decorators",
"Context"
],
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "IBM Corp.",
"copyright.owner": "IBM Corp.",
"repository": {
"type": "git",
"url": "https://github.com/strongloop/loopback-next.git",
"directory": "packages/context"
},
"engines": {
"node": "^10.16 || 12 || 14 || 15"
"node": "^10.16 || 12 || 14 || 16"
},

@@ -19,10 +36,13 @@ "scripts": {

},
"author": "IBM Corp.",
"copyright.owner": "IBM Corp.",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"files": [
"README.md",
"dist",
"src",
"!*/__tests__"
],
"dependencies": {
"@loopback/metadata": "^3.2.1",
"@loopback/metadata": "^3.3.0",
"@types/debug": "^4.1.5",

@@ -32,35 +52,15 @@ "debug": "^4.3.1",

"p-event": "^4.2.0",
"tslib": "^2.1.0",
"tslib": "^2.2.0",
"uuid": "^8.3.2"
},
"devDependencies": {
"@loopback/build": "^6.3.1",
"@loopback/eslint-config": "^10.1.1",
"@loopback/testlab": "^3.3.1",
"@loopback/build": "^6.4.0",
"@loopback/eslint-config": "^10.2.0",
"@loopback/testlab": "^3.4.0",
"@types/bluebird": "^3.5.33",
"@types/node": "^10.17.56",
"@types/node": "^10.17.59",
"@types/uuid": "^8.3.0",
"bluebird": "^3.7.2"
},
"keywords": [
"LoopBack",
"IoC",
"Inversion",
"Control",
"Container",
"Decorators",
"Context"
],
"files": [
"README.md",
"dist",
"src",
"!*/__tests__"
],
"repository": {
"type": "git",
"url": "https://github.com/strongloop/loopback-next.git",
"directory": "packages/context"
},
"gitHead": "156ca0fcf8fa246ca380ab28b44b3708896be2b6"
"gitHead": "2ca802912d8c7750d0256f3c3d493c4525415201"
}

@@ -511,2 +511,7 @@ // Copyright IBM Corp. 2017,2020. All Rights Reserved.

if (resolutionCtx == null) return undefined;
// Keep a snapshot for proxy
const savedSession =
ResolutionSession.fork(options.session) ?? new ResolutionSession();
// First check cached value for non-transient

@@ -516,3 +521,8 @@ if (this._cache) {

if (resolutionCtx && this._cache.has(resolutionCtx)) {
return this._cache.get(resolutionCtx)!;
const value = this._cache.get(resolutionCtx)!;
return this.getValueOrProxy(
resolutionCtx,
{...options, session: savedSession},
value,
);
}

@@ -529,3 +539,8 @@ }

s => {
const optionsWithSession = {...options, session: s};
const optionsWithSession = {
...options,
session: s,
// Force to be the non-proxy version
asProxyWithInterceptors: false,
};
// We already test `this._getValue` is a function. It's safe to assert

@@ -541,3 +556,8 @@ // that `this._getValue` is not undefined.

);
return this._cacheValue(resolutionCtx!, result);
const value = this._cacheValue(resolutionCtx!, result);
return this.getValueOrProxy(
resolutionCtx,
{...options, session: savedSession},
value,
);
}

@@ -554,2 +574,19 @@ // `@inject.binding` adds a binding without _getValue

private getValueOrProxy(
resolutionCtx: Context,
options: ResolutionOptions,
value: ValueOrPromise<T>,
): ValueOrPromise<T> {
const session = options.session!;
session.pushBinding(this);
return Binding.valueOrProxy(
{
context: resolutionCtx,
binding: this,
options,
},
value,
);
}
/**

@@ -556,0 +593,0 @@ * Locate and validate the resolution context

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc