@collaborne/authorized-image
Advanced tools
Comparing version 2.0.0 to 2.0.2
@@ -0,5 +1,11 @@ | ||
/* eslint-disable valid-jsdoc */ | ||
/** | ||
* Mixin that allows fetching with authorization through the browser cache and providing the result through a data: URL. | ||
* | ||
* @template T type of parent class | ||
* @param {T} parent parent class | ||
* @returns {T & AuthorizedFetchMixin} parent with this mixed in | ||
*/ | ||
export const AuthorizedFetchMixin = parent => class extends parent { | ||
/* eslint-enable valid-jsdoc */ | ||
export const AuthorizedFetchMixin = parent => class extends parent { // eslint-disable-line padded-blocks | ||
/** | ||
@@ -6,0 +12,0 @@ * Fetch the given `src` by authorizing with the given bearer token `token`. |
@@ -1,5 +0,5 @@ | ||
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js'; | ||
import '@polymer/iron-image/iron-image.js'; | ||
import {PolymerElement, html} from '@polymer/polymer/polymer-element.js'; | ||
import { AuthorizedFetchMixin } from './authorized-fetch-mixin.js'; | ||
import {AuthorizedFetchMixin} from './authorized-fetch-mixin.js'; | ||
@@ -57,3 +57,17 @@ /** | ||
_ironImageError: Boolean, | ||
_supportsIntersectionObserver: { | ||
readOnly: true, | ||
type: Boolean, | ||
value: typeof IntersectionObserver === 'function', | ||
}, | ||
/** | ||
* Whether this image was visible according to the intersection observer. | ||
* | ||
* This value is only valid when the component is "ready" and _supportsIntersectionObserver is true. | ||
*/ | ||
_visible: Boolean, | ||
/** | ||
* Whether this image was ever visible. | ||
@@ -66,13 +80,2 @@ * This property is used to delay the internal "fetch" request for invisible images, but avoid | ||
}, | ||
/** | ||
* Whether this image was visible according to the intersection observer. | ||
* | ||
* This value is only valid when the component is "ready" and _supportsIntersectionObserver is true. | ||
*/ | ||
_visible: Boolean, | ||
_supportsIntersectionObserver: { | ||
value: typeof IntersectionObserver === 'function', | ||
readOnly: true, | ||
type: Boolean, | ||
}, | ||
@@ -108,6 +111,6 @@ alt: String, | ||
token: String, | ||
mode: { | ||
token: String, // eslint-disable-line sort-keys | ||
mode: { // eslint-disable-line sort-keys | ||
type: String, | ||
value: 'cors', | ||
type: String, | ||
}, | ||
@@ -125,6 +128,6 @@ }; | ||
if (this._supportsIntersectionObserver) { | ||
this._observer = new IntersectionObserver(entries => { | ||
this._observer = new IntersectionObserver(entries => { // eslint-disable-line no-unused-vars | ||
// See https://stackoverflow.com/a/38873788/196315 | ||
// XXX: Can we instead look at the entries, specifically 'isIntersecting'? | ||
this._visible = !!(this.offsetHeight || this.offsetWidth || this.getClientRects().length > 0); | ||
this._visible = Boolean(this.offsetHeight || this.offsetWidth || this.getClientRects().length > 0); | ||
}); | ||
@@ -152,3 +155,3 @@ this._observer.observe(this); | ||
_computeError(ironImageError, displayed) { | ||
return Boolean(ironImageError || displayed && displayed.dataUrl === ''); | ||
return Boolean(ironImageError) || Boolean(displayed && displayed.dataUrl === ''); | ||
} | ||
@@ -199,3 +202,7 @@ | ||
// Prevent loading when either the user requested that, or when we cannot actually display things. | ||
return preventLoad || (displayed && displayed.dataUrl === ''); | ||
if (preventLoad) { | ||
return true; | ||
} | ||
return Boolean(displayed && displayed.dataUrl === ''); | ||
} | ||
@@ -208,2 +215,4 @@ | ||
} | ||
return undefined; | ||
} | ||
@@ -210,0 +219,0 @@ |
{ | ||
"name": "@collaborne/authorized-image", | ||
"version": "2.0.2", | ||
"description": "A component that allows to show images that require authorization using a bearer token.", | ||
"homepage": "https://github.com/collaborne/authorized-image", | ||
"name": "@collaborne/authorized-image", | ||
"version": "2.0.0", | ||
"resolutions": { | ||
"inherits": "2.0.3", | ||
"samsam": "1.1.3", | ||
"supports-color": "3.1.2", | ||
"type-detect": "1.0.0" | ||
"author": "Collaborne B.V.", | ||
"homepage": "https://github.com/Collaborne/authorized-image", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/Collaborne/authorized-image/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Collaborne/authorized-image.git" | ||
}, | ||
"main": "authorized-image.js", | ||
"author": "collaborne", | ||
"license": "Apache-2.0", | ||
"scripts": { | ||
"lint": "eslint . && polymer lint", | ||
"test": "npm run lint && echo 'No tests yet'" | ||
}, | ||
"dependencies": { | ||
@@ -21,7 +26,9 @@ "@polymer/polymer": "^3.0.0", | ||
"@polymer/iron-demo-helpers": "^3.0.0", | ||
"@polymer/paper-checkbox": "^3.0.0", | ||
"@polymer/paper-input": "^3.0.0", | ||
"@polymer/paper-checkbox": "^3.0.0", | ||
"wct-browser-legacy": "^1.0.1", | ||
"@webcomponents/webcomponentsjs": "^2.0.0" | ||
"@webcomponents/webcomponentsjs": "^2.0.0", | ||
"eslint": "^5.12.1", | ||
"eslint-config-collaborne": "^1.5.0", | ||
"polymer-cli": "^1.9.5" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# `<authorized-image>` | ||
# `<authorized-image>` [](https://travis-ci.com/Collaborne/authorized-image) | ||
@@ -8,3 +8,3 @@ A component that allows to show images that require authorization using a bearer token. | ||
```sh | ||
npm install Collaborne/authorized-image --save | ||
npm install @collaborne/authorized-image --save | ||
``` | ||
@@ -11,0 +11,0 @@ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
11
267
1
0
29469
7
1
2