Socket
Socket
Sign inDemoInstall

@uppy/provider-views

Package Overview
Dependencies
Maintainers
5
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uppy/provider-views - npm Package Compare versions

Comparing version 0.26.0 to 0.27.0

9

lib/AuthView.js

@@ -92,7 +92,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

AuthView.prototype.render = function render() {
return h(
'div',
{ style: { height: '100%' } },
this.props.checkAuthInProgress ? h(LoaderView, null) : h(AuthBlock, this.props)
);
if (this.props.checkAuthInProgress) {
return h(LoaderView, null);
}
return h(AuthBlock, this.props);
};

@@ -99,0 +98,0 @@

@@ -6,9 +6,5 @@ var _require = require('preact'),

return h(
"li",
null,
h(
"button",
{ type: "button", onclick: props.getFolder },
props.title
)
"button",
{ type: "button", onclick: props.getFolder },
props.title
);

@@ -19,3 +15,3 @@ };

return h(
"ul",
"div",
{ "class": "uppy-Provider-breadcrumbs" },

@@ -22,0 +18,0 @@ props.directories.map(function (directory, i) {

@@ -34,10 +34,14 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

'div',
{ 'class': 'uppy-Provider-breadcrumbsIcon' },
props.pluginIcon && props.pluginIcon()
{ 'class': 'uppy-Provider-breadcrumbsWrap' },
h(
'div',
{ 'class': 'uppy-Provider-breadcrumbsIcon' },
props.pluginIcon && props.pluginIcon()
),
props.showBreadcrumbs && Breadcrumbs({
getFolder: props.getFolder,
directories: props.directories,
title: props.title
})
),
props.showBreadcrumbs && Breadcrumbs({
getFolder: props.getFolder,
directories: props.directories,
title: props.title
}),
h(

@@ -44,0 +48,0 @@ 'span',

@@ -531,8 +531,4 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var authWindow = window.open(link, '_blank');
var noProtocol = function noProtocol(url) {
return url.replace(/^(https?:|)\/\//, '');
};
var handleToken = function handleToken(e) {
var allowedOrigin = new RegExp(noProtocol(_this11.plugin.opts.serverPattern));
if (!allowedOrigin.test(noProtocol(e.origin)) || e.source !== authWindow) {
if (!_this11._isOriginAllowed(e.origin, _this11.plugin.opts.serverPattern) || e.source !== authWindow) {
_this11.plugin.uppy.log('rejecting event from ' + e.origin + ' vs allowed pattern ' + _this11.plugin.opts.serverPattern);

@@ -549,2 +545,19 @@ return;

ProviderView.prototype._isOriginAllowed = function _isOriginAllowed(origin, allowedOrigin) {
var getRegex = function getRegex(value) {
if (typeof value === 'string') {
return new RegExp('^' + value + '$');
} else if (value instanceof RegExp) {
return value;
}
};
var patterns = Array.isArray(allowedOrigin) ? allowedOrigin.map(getRegex) : [getRegex(allowedOrigin)];
return patterns.filter(function (pattern) {
return pattern !== null;
}).some(function (pattern) {
return pattern.test(origin);
});
};
ProviderView.prototype.handleError = function handleError(error) {

@@ -617,5 +630,9 @@ var uppy = this.plugin.uppy;

promise.then(then).catch(catch_).then(function () {
return _this14.plugin.setPluginState({ loading: false });
}); // always called.
promise.then(function (result) {
_this14.plugin.setPluginState({ loading: false });
then(result);
}).catch(function (err) {
_this14.plugin.setPluginState({ loading: false });
catch_(err);
});
this.plugin.setPluginState({ loading: true });

@@ -622,0 +639,0 @@ };

var _require = require('preact'),
h = _require.h;
function mapStringToIcon(string) {
if (string === null) return;
switch (string) {
case 'file':
return h(
'svg',
{ 'aria-hidden': 'true', 'class': 'UppyIcon', width: 11, height: 14.5, viewBox: '0 0 44 58' },
h('path', { d: 'M27.437.517a1 1 0 0 0-.094.03H4.25C2.037.548.217 2.368.217 4.58v48.405c0 2.212 1.82 4.03 4.03 4.03H39.03c2.21 0 4.03-1.818 4.03-4.03V15.61a1 1 0 0 0-.03-.28 1 1 0 0 0 0-.093 1 1 0 0 0-.03-.032 1 1 0 0 0 0-.03 1 1 0 0 0-.032-.063 1 1 0 0 0-.03-.063 1 1 0 0 0-.032 0 1 1 0 0 0-.03-.063 1 1 0 0 0-.032-.03 1 1 0 0 0-.03-.063 1 1 0 0 0-.063-.062l-14.593-14a1 1 0 0 0-.062-.062A1 1 0 0 0 28 .708a1 1 0 0 0-.374-.157 1 1 0 0 0-.156 0 1 1 0 0 0-.03-.03l-.003-.003zM4.25 2.547h22.218v9.97c0 2.21 1.82 4.03 4.03 4.03h10.564v36.438a2.02 2.02 0 0 1-2.032 2.032H4.25c-1.13 0-2.032-.9-2.032-2.032V4.58c0-1.13.902-2.032 2.03-2.032zm24.218 1.345l10.375 9.937.75.718H30.5c-1.13 0-2.032-.9-2.032-2.03V3.89z' })
);
case 'folder':
return h(
'svg',
{ 'aria-hidden': 'true', 'class': 'UppyIcon', style: { width: 16, marginRight: 3 }, viewBox: '0 0 276.157 276.157' },
h('path', { d: 'M273.08 101.378c-3.3-4.65-8.86-7.32-15.254-7.32h-24.34V67.59c0-10.2-8.3-18.5-18.5-18.5h-85.322c-3.63 0-9.295-2.875-11.436-5.805l-6.386-8.735c-4.982-6.814-15.104-11.954-23.546-11.954H58.73c-9.292 0-18.638 6.608-21.737 15.372l-2.033 5.752c-.958 2.71-4.72 5.37-7.596 5.37H18.5C8.3 49.09 0 57.39 0 67.59v167.07c0 .886.16 1.73.443 2.52.152 3.306 1.18 6.424 3.053 9.064 3.3 4.652 8.86 7.32 15.255 7.32h188.487c11.395 0 23.27-8.425 27.035-19.18l40.677-116.188c2.11-6.035 1.43-12.164-1.87-16.816zM18.5 64.088h8.864c9.295 0 18.64-6.607 21.738-15.37l2.032-5.75c.96-2.712 4.722-5.373 7.597-5.373h29.565c3.63 0 9.295 2.876 11.437 5.806l6.386 8.735c4.982 6.815 15.104 11.954 23.546 11.954h85.322c1.898 0 3.5 1.602 3.5 3.5v26.47H69.34c-11.395 0-23.27 8.423-27.035 19.178L15 191.23V67.59c0-1.898 1.603-3.5 3.5-3.5zm242.29 49.15l-40.676 116.188c-1.674 4.78-7.812 9.135-12.877 9.135H18.75c-1.447 0-2.576-.372-3.02-.997-.442-.625-.422-1.814.057-3.18l40.677-116.19c1.674-4.78 7.812-9.134 12.877-9.134h188.487c1.448 0 2.577.372 3.02.997.443.625.423 1.814-.056 3.18z' })
);
case 'video':
return h(
'svg',
{ 'aria-hidden': 'true', viewBox: '0 0 58 58' },
h('path', { d: 'M36.537 28.156l-11-7a1.005 1.005 0 0 0-1.02-.033C24.2 21.3 24 21.635 24 22v14a1 1 0 0 0 1.537.844l11-7a1.002 1.002 0 0 0 0-1.688zM26 34.18V23.82L34.137 29 26 34.18z' }),
h('path', { d: 'M57 6H1a1 1 0 0 0-1 1v44a1 1 0 0 0 1 1h56a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1zM10 28H2v-9h8v9zm-8 2h8v9H2v-9zm10 10V8h34v42H12V40zm44-12h-8v-9h8v9zm-8 2h8v9h-8v-9zm8-22v9h-8V8h8zM2 8h8v9H2V8zm0 42v-9h8v9H2zm54 0h-8v-9h8v9z' })
);
default:
return h('img', { src: string });
}
}
module.exports = function (props) {

@@ -21,5 +49,7 @@ var stop = function stop(ev) {

var itemIcon = props.getItemIcon();
return h(
'li',
{ 'class': 'uppy-ProviderBrowserItem' + (props.isChecked ? ' uppy-ProviderBrowserItem--selected' : '') },
{ 'class': 'uppy-ProviderBrowserItem' + (props.isChecked ? ' uppy-ProviderBrowserItem--selected' : '') + (itemIcon === 'video' ? ' uppy-ProviderBrowserItem--noPreview' : '') },
h(

@@ -51,4 +81,3 @@ 'div',

onclick: handleItemClick },
props.getItemIcon(),
' ',
mapStringToIcon(props.getItemIcon()),
props.showTitles && props.title

@@ -55,0 +84,0 @@ )

{
"name": "@uppy/provider-views",
"description": "View library for Uppy remote provider plugins.",
"version": "0.26.0",
"version": "0.27.0",
"license": "MIT",

@@ -23,3 +23,3 @@ "main": "lib/index.js",

"dependencies": {
"@uppy/utils": "0.26.0",
"@uppy/utils": "0.27.0",
"classnames": "^2.2.6",

@@ -29,3 +29,3 @@ "preact": "^8.2.9"

"devDependencies": {
"@uppy/core": "0.26.0"
"@uppy/core": "0.27.0"
},

@@ -32,0 +32,0 @@ "peerDependencies": {

@@ -37,10 +37,6 @@ const LoaderView = require('./Loader')

render () {
return (
<div style={{ height: '100%' }}>
{this.props.checkAuthInProgress
? <LoaderView />
: <AuthBlock {...this.props} />
}
</div>
)
if (this.props.checkAuthInProgress) {
return <LoaderView />
}
return <AuthBlock {...this.props} />
}

@@ -47,0 +43,0 @@ }

@@ -5,3 +5,3 @@ const { h } = require('preact')

return (
<li><button type="button" onclick={props.getFolder}>{props.title}</button></li>
<button type="button" onclick={props.getFolder}>{props.title}</button>
)

@@ -12,3 +12,3 @@ }

return (
<ul class="uppy-Provider-breadcrumbs">
<div class="uppy-Provider-breadcrumbs">
{

@@ -22,4 +22,4 @@ props.directories.map((directory, i) => {

}
</ul>
</div>
)
}

@@ -23,8 +23,10 @@ const classNames = require('classnames')

<div class={classNames('uppy-ProviderBrowser-headerBar', !props.showBreadcrumbs && 'uppy-ProviderBrowser-headerBar--simple')}>
<div class="uppy-Provider-breadcrumbsIcon">{props.pluginIcon && props.pluginIcon()}</div>
{props.showBreadcrumbs && Breadcrumbs({
getFolder: props.getFolder,
directories: props.directories,
title: props.title
})}
<div class="uppy-Provider-breadcrumbsWrap">
<div class="uppy-Provider-breadcrumbsIcon">{props.pluginIcon && props.pluginIcon()}</div>
{props.showBreadcrumbs && Breadcrumbs({
getFolder: props.getFolder,
directories: props.directories,
title: props.title
})}
</div>
<span class="uppy-ProviderBrowser-user">{props.username}</span>

@@ -31,0 +33,0 @@ <button type="button" onclick={props.logout} class="uppy-ProviderBrowser-userLogout">

@@ -456,6 +456,4 @@ const { h, Component } = require('preact')

const authWindow = window.open(link, '_blank')
const noProtocol = (url) => url.replace(/^(https?:|)\/\//, '')
const handleToken = (e) => {
const allowedOrigin = new RegExp(noProtocol(this.plugin.opts.serverPattern))
if (!allowedOrigin.test(noProtocol(e.origin)) || e.source !== authWindow) {
if (!this._isOriginAllowed(e.origin, this.plugin.opts.serverPattern) || e.source !== authWindow) {
this.plugin.uppy.log(`rejecting event from ${e.origin} vs allowed pattern ${this.plugin.opts.serverPattern}`)

@@ -472,2 +470,17 @@ return

_isOriginAllowed (origin, allowedOrigin) {
const getRegex = (value) => {
if (typeof value === 'string') {
return new RegExp(`^${value}$`)
} else if (value instanceof RegExp) {
return value
}
}
const patterns = Array.isArray(allowedOrigin) ? allowedOrigin.map(getRegex) : [getRegex(allowedOrigin)]
return patterns
.filter((pattern) => pattern !== null)
.some((pattern) => pattern.test(origin))
}
handleError (error) {

@@ -528,4 +541,9 @@ const uppy = this.plugin.uppy

promise
.then(then).catch(catch_)
.then(() => this.plugin.setPluginState({ loading: false })) // always called.
.then((result) => {
this.plugin.setPluginState({ loading: false })
then(result)
}).catch((err) => {
this.plugin.setPluginState({ loading: false })
catch_(err)
})
this.plugin.setPluginState({ loading: true })

@@ -532,0 +550,0 @@ }

const { h } = require('preact')
function mapStringToIcon (string) {
if (string === null) return
switch (string) {
case 'file':
return <svg aria-hidden="true" class="UppyIcon" width={11} height={14.5} viewBox="0 0 44 58">
<path d="M27.437.517a1 1 0 0 0-.094.03H4.25C2.037.548.217 2.368.217 4.58v48.405c0 2.212 1.82 4.03 4.03 4.03H39.03c2.21 0 4.03-1.818 4.03-4.03V15.61a1 1 0 0 0-.03-.28 1 1 0 0 0 0-.093 1 1 0 0 0-.03-.032 1 1 0 0 0 0-.03 1 1 0 0 0-.032-.063 1 1 0 0 0-.03-.063 1 1 0 0 0-.032 0 1 1 0 0 0-.03-.063 1 1 0 0 0-.032-.03 1 1 0 0 0-.03-.063 1 1 0 0 0-.063-.062l-14.593-14a1 1 0 0 0-.062-.062A1 1 0 0 0 28 .708a1 1 0 0 0-.374-.157 1 1 0 0 0-.156 0 1 1 0 0 0-.03-.03l-.003-.003zM4.25 2.547h22.218v9.97c0 2.21 1.82 4.03 4.03 4.03h10.564v36.438a2.02 2.02 0 0 1-2.032 2.032H4.25c-1.13 0-2.032-.9-2.032-2.032V4.58c0-1.13.902-2.032 2.03-2.032zm24.218 1.345l10.375 9.937.75.718H30.5c-1.13 0-2.032-.9-2.032-2.03V3.89z" />
</svg>
case 'folder':
return <svg aria-hidden="true" class="UppyIcon" style={{ width: 16, marginRight: 3 }} viewBox="0 0 276.157 276.157">
<path d="M273.08 101.378c-3.3-4.65-8.86-7.32-15.254-7.32h-24.34V67.59c0-10.2-8.3-18.5-18.5-18.5h-85.322c-3.63 0-9.295-2.875-11.436-5.805l-6.386-8.735c-4.982-6.814-15.104-11.954-23.546-11.954H58.73c-9.292 0-18.638 6.608-21.737 15.372l-2.033 5.752c-.958 2.71-4.72 5.37-7.596 5.37H18.5C8.3 49.09 0 57.39 0 67.59v167.07c0 .886.16 1.73.443 2.52.152 3.306 1.18 6.424 3.053 9.064 3.3 4.652 8.86 7.32 15.255 7.32h188.487c11.395 0 23.27-8.425 27.035-19.18l40.677-116.188c2.11-6.035 1.43-12.164-1.87-16.816zM18.5 64.088h8.864c9.295 0 18.64-6.607 21.738-15.37l2.032-5.75c.96-2.712 4.722-5.373 7.597-5.373h29.565c3.63 0 9.295 2.876 11.437 5.806l6.386 8.735c4.982 6.815 15.104 11.954 23.546 11.954h85.322c1.898 0 3.5 1.602 3.5 3.5v26.47H69.34c-11.395 0-23.27 8.423-27.035 19.178L15 191.23V67.59c0-1.898 1.603-3.5 3.5-3.5zm242.29 49.15l-40.676 116.188c-1.674 4.78-7.812 9.135-12.877 9.135H18.75c-1.447 0-2.576-.372-3.02-.997-.442-.625-.422-1.814.057-3.18l40.677-116.19c1.674-4.78 7.812-9.134 12.877-9.134h188.487c1.448 0 2.577.372 3.02.997.443.625.423 1.814-.056 3.18z" />
</svg>
case 'video':
return <svg aria-hidden="true" viewBox="0 0 58 58">
<path d="M36.537 28.156l-11-7a1.005 1.005 0 0 0-1.02-.033C24.2 21.3 24 21.635 24 22v14a1 1 0 0 0 1.537.844l11-7a1.002 1.002 0 0 0 0-1.688zM26 34.18V23.82L34.137 29 26 34.18z" /><path d="M57 6H1a1 1 0 0 0-1 1v44a1 1 0 0 0 1 1h56a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1zM10 28H2v-9h8v9zm-8 2h8v9H2v-9zm10 10V8h34v42H12V40zm44-12h-8v-9h8v9zm-8 2h8v9h-8v-9zm8-22v9h-8V8h8zM2 8h8v9H2V8zm0 42v-9h8v9H2zm54 0h-8v-9h8v9z" />
</svg>
default:
return <img src={string} />
}
}
module.exports = (props) => {

@@ -20,4 +41,6 @@ const stop = (ev) => {

const itemIcon = props.getItemIcon()
return (
<li class={'uppy-ProviderBrowserItem' + (props.isChecked ? ' uppy-ProviderBrowserItem--selected' : '')}>
<li class={'uppy-ProviderBrowserItem' + (props.isChecked ? ' uppy-ProviderBrowserItem--selected' : '') + (itemIcon === 'video' ? ' uppy-ProviderBrowserItem--noPreview' : '')}>
<div class="uppy-ProviderBrowserItem-checkbox">

@@ -45,3 +68,4 @@ <input type="checkbox"

onclick={handleItemClick}>
{props.getItemIcon()} {props.showTitles && props.title}
{mapStringToIcon(props.getItemIcon())}
{props.showTitles && props.title}
</button>

@@ -48,0 +72,0 @@ </li>

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