Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@uppy/companion-client

Package Overview
Dependencies
Maintainers
5
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uppy/companion-client - npm Package Compare versions

Comparing version 3.7.4 to 3.8.0

lib/CompanionPluginOptions.js

8

CHANGELOG.md
# @uppy/companion-client
## 3.8.0
Released: 2024-03-27
Included in: Uppy v3.24.0
- @uppy/box,@uppy/companion-client,@uppy/provider-views,@uppy/status-bar: fix type imports (Antoine du Hamel / #5038)
- @uppy/companion-client: Replace Provider.initPlugin with composition (Merlijn Vos / #4977)
## 3.7.4

@@ -4,0 +12,0 @@

7

lib/index.js

@@ -1,11 +0,12 @@

'use strict';
/**
* Manages communications with Companion
*/
export { default as RequestClient } from "./RequestClient.js";
export { default as Provider } from "./Provider.js";
export { default as SearchProvider } from "./SearchProvider.js";
export { default as getAllowedHosts } from "./getAllowedHosts.js";
import * as _tokenStorage from "./tokenStorage.js";
export { _tokenStorage as tokenStorage };
// TODO: remove in the next major
export { default as Socket } from "./Socket.js";

@@ -5,3 +5,2 @@ function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }

import RequestClient, { authErrorStatusCode } from "./RequestClient.js";
import * as tokenStorage from "./tokenStorage.js";

@@ -292,34 +291,2 @@ // TODO: remove deprecated options in next major release

}
static initPlugin(plugin,
// any because static methods cannot use class generics
opts, defaultOpts) {
/* eslint-disable no-param-reassign */
plugin.type = 'acquirer';
plugin.files = [];
if (defaultOpts) {
plugin.opts = {
...defaultOpts,
...opts
};
}
if (opts.serverUrl || opts.serverPattern) {
throw new Error('`serverUrl` and `serverPattern` have been renamed to `companionUrl` and `companionAllowedHosts` respectively in the 0.30.5 release. Please consult the docs (for example, https://uppy.io/docs/instagram/ for the Instagram plugin) and use the updated options.`');
}
if (opts.companionAllowedHosts) {
const pattern = opts.companionAllowedHosts;
// validate companionAllowedHosts param
if (typeof pattern !== 'string' && !Array.isArray(pattern) && !(pattern instanceof RegExp)) {
throw new TypeError(`${plugin.id}: the option "companionAllowedHosts" must be one of string, Array, RegExp`);
}
plugin.opts.companionAllowedHosts = pattern;
} else if (/^(?!https?:\/\/).*$/i.test(opts.companionUrl)) {
var _opts$companionUrl;
// does not start with https://
plugin.opts.companionAllowedHosts = `https://${(_opts$companionUrl = opts.companionUrl) == null ? void 0 : _opts$companionUrl.replace(/^\/\//, '')}`;
} else {
plugin.opts.companionAllowedHosts = new URL(opts.companionUrl).origin;
}
plugin.storage = plugin.opts.storage || tokenStorage;
/* eslint-enable no-param-reassign */
}
}

@@ -326,0 +293,0 @@ async function _getAuthToken2() {

@@ -16,3 +16,3 @@ let _Symbol$for;

const packageJson = {
"version": "3.7.4"
"version": "3.8.0"
};

@@ -19,0 +19,0 @@ // Remove the trailing slash so we can always safely append /xyz.

{
"name": "@uppy/companion-client",
"description": "Client library for communication with Companion. Intended for use in Uppy plugins.",
"version": "3.7.4",
"version": "3.8.0",
"license": "MIT",

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

"dependencies": {
"@uppy/utils": "^5.7.4",
"@uppy/utils": "^5.7.5",
"namespace-emitter": "^2.0.1",

@@ -34,4 +34,4 @@ "p-retry": "^6.1.0"

"peerDependencies": {
"@uppy/core": "^3.9.3"
"@uppy/core": "^3.10.0"
}
}

@@ -1,3 +0,1 @@

'use strict'
/**

@@ -11,3 +9,9 @@ * Manages communications with Companion

export { default as getAllowedHosts } from './getAllowedHosts.ts'
export * as tokenStorage from './tokenStorage.ts'
export type { CompanionPluginOptions } from './CompanionPluginOptions.ts'
// TODO: remove in the next major
export { default as Socket } from './Socket.ts'
import type { Uppy } from '@uppy/core'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import type { PluginOpts } from '@uppy/core/lib/BasePlugin.ts'
import type { PluginOpts } from '@uppy/core/lib/BasePlugin'
import type {

@@ -8,8 +8,8 @@ RequestOptions,

} from '@uppy/utils/lib/CompanionClientProvider'
import type { UnknownProviderPlugin } from '@uppy/core/lib/Uppy.ts'
import type { UnknownProviderPlugin } from '@uppy/core/lib/Uppy'
import RequestClient, { authErrorStatusCode } from './RequestClient.ts'
import * as tokenStorage from './tokenStorage.ts'
import type { CompanionPluginOptions } from '.'
// TODO: remove deprecated options in next major release
export interface Opts extends PluginOpts {
export interface Opts extends PluginOpts, CompanionPluginOptions {
/** @deprecated */

@@ -19,5 +19,2 @@ serverUrl?: string

serverPattern?: string
companionUrl: string
companionAllowedHosts?: string | RegExp | Array<string | RegExp>
storage?: typeof tokenStorage
pluginId: string

@@ -390,47 +387,2 @@ name?: string

}
static initPlugin(
plugin: UnknownProviderPlugin<any, any>, // any because static methods cannot use class generics
opts: Opts,
defaultOpts: Record<string, unknown>,
): void {
/* eslint-disable no-param-reassign */
plugin.type = 'acquirer'
plugin.files = []
if (defaultOpts) {
plugin.opts = { ...defaultOpts, ...opts }
}
if (opts.serverUrl || opts.serverPattern) {
throw new Error(
'`serverUrl` and `serverPattern` have been renamed to `companionUrl` and `companionAllowedHosts` respectively in the 0.30.5 release. Please consult the docs (for example, https://uppy.io/docs/instagram/ for the Instagram plugin) and use the updated options.`',
)
}
if (opts.companionAllowedHosts) {
const pattern = opts.companionAllowedHosts
// validate companionAllowedHosts param
if (
typeof pattern !== 'string' &&
!Array.isArray(pattern) &&
!(pattern instanceof RegExp)
) {
throw new TypeError(
`${plugin.id}: the option "companionAllowedHosts" must be one of string, Array, RegExp`,
)
}
plugin.opts.companionAllowedHosts = pattern
} else if (/^(?!https?:\/\/).*$/i.test(opts.companionUrl)) {
// does not start with https://
plugin.opts.companionAllowedHosts = `https://${opts.companionUrl?.replace(
/^\/\//,
'',
)}`
} else {
plugin.opts.companionAllowedHosts = new URL(opts.companionUrl).origin
}
plugin.storage = plugin.opts.storage || tokenStorage
/* eslint-enable no-param-reassign */
}
}

@@ -12,3 +12,3 @@ import UserFacingApiError from '@uppy/utils/lib/UserFacingApiError'

import type { UppyFile, Meta, Body } from '@uppy/utils/lib/UppyFile'
import type { RequestOptions } from '@uppy/utils/lib/CompanionClientProvider.ts'
import type { RequestOptions } from '@uppy/utils/lib/CompanionClientProvider'
import AuthError from './AuthError.ts'

@@ -15,0 +15,0 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment

@@ -1,2 +0,2 @@

import type { Body, Meta } from '@uppy/utils/lib/UppyFile.ts'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import type { Uppy } from '@uppy/core'

@@ -3,0 +3,0 @@ import type { CompanionClientSearchProvider } from '@uppy/utils/lib/CompanionClientProvider'

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