-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Companion 4x breaking changes #5198
Conversation
Diff output filesdiff --git a/packages/@uppy/aws-s3/lib/index.js b/packages/@uppy/aws-s3/lib/index.js
index 856e4de..a2fb0b7 100644
--- a/packages/@uppy/aws-s3/lib/index.js
+++ b/packages/@uppy/aws-s3/lib/index.js
@@ -78,7 +78,7 @@ var _setResumableUploadsCapability = _classPrivateFieldLooseKey("setResumableUpl
var _resetResumableCapability = _classPrivateFieldLooseKey("resetResumableCapability");
export default class AwsS3Multipart extends BasePlugin {
constructor(uppy, opts) {
- var _rateLimitedQueue;
+ var _ref3, _rateLimitedQueue;
super(uppy, {
...defaultOptions,
uploadPartBytes: AwsS3Multipart.uploadPartBytes,
@@ -204,7 +204,7 @@ export default class AwsS3Multipart extends BasePlugin {
});
this.type = "uploader";
this.id = this.opts.id || "AwsS3Multipart";
- _classPrivateFieldLooseBase(this, _client)[_client] = new RequestClient(uppy, opts);
+ _classPrivateFieldLooseBase(this, _client)[_client] = new RequestClient(uppy, (_ref3 = opts) != null ? _ref3 : {});
const dynamicDefaultOptions = {
createMultipartUpload: this.createMultipartUpload,
listParts: this.listParts,
@@ -283,13 +283,13 @@ export default class AwsS3Multipart extends BasePlugin {
signal,
}).then(assertServerError);
}
- listParts(file, _ref3, oldSignal) {
+ listParts(file, _ref4, oldSignal) {
var _signal;
let {
key,
uploadId,
signal,
- } = _ref3;
+ } = _ref4;
(_signal = signal) != null ? _signal : signal = oldSignal;
this.assertHost("listParts");
throwIfAborted(signal);
@@ -301,14 +301,14 @@ export default class AwsS3Multipart extends BasePlugin {
},
).then(assertServerError);
}
- completeMultipartUpload(file, _ref4, oldSignal) {
+ completeMultipartUpload(file, _ref5, oldSignal) {
var _signal2;
let {
key,
uploadId,
parts,
signal,
- } = _ref4;
+ } = _ref5;
(_signal2 = signal) != null ? _signal2 : signal = oldSignal;
this.assertHost("completeMultipartUpload");
throwIfAborted(signal);
@@ -353,13 +353,13 @@ export default class AwsS3Multipart extends BasePlugin {
},
};
}
- signPart(file, _ref5) {
+ signPart(file, _ref6) {
let {
uploadId,
key,
partNumber,
signal,
- } = _ref5;
+ } = _ref6;
this.assertHost("signPart");
throwIfAborted(signal);
if (uploadId == null || key == null || partNumber == null) {
@@ -373,13 +373,13 @@ export default class AwsS3Multipart extends BasePlugin {
},
).then(assertServerError);
}
- abortMultipartUpload(file, _ref6, oldSignal) {
+ abortMultipartUpload(file, _ref7, oldSignal) {
var _signal3;
let {
key,
uploadId,
signal,
- } = _ref6;
+ } = _ref7;
(_signal3 = signal) != null ? _signal3 : signal = oldSignal;
this.assertHost("abortMultipartUpload");
const filename = encodeURIComponent(key);
@@ -413,7 +413,7 @@ export default class AwsS3Multipart extends BasePlugin {
});
return _classPrivateFieldLooseBase(this, _client)[_client].get(`s3/params?${query}`, options);
}
- static async uploadPartBytes(_ref7) {
+ static async uploadPartBytes(_ref8) {
let {
signature: {
url,
@@ -426,7 +426,7 @@ export default class AwsS3Multipart extends BasePlugin {
onProgress,
onComplete,
signal,
- } = _ref7;
+ } = _ref8;
throwIfAborted(signal);
if (url == null) {
throw new Error("Cannot upload to an undefined URL");
diff --git a/packages/@uppy/companion-client/lib/Provider.js b/packages/@uppy/companion-client/lib/Provider.js
index cf36452..59caae7 100644
--- a/packages/@uppy/companion-client/lib/Provider.js
+++ b/packages/@uppy/companion-client/lib/Provider.js
@@ -35,7 +35,6 @@ var _getAuthToken = _classPrivateFieldLooseKey("getAuthToken");
var _getPlugin = _classPrivateFieldLooseKey("getPlugin");
export default class Provider extends RequestClient {
constructor(uppy, opts) {
- var _opts$supportsRefresh;
super(uppy, opts);
Object.defineProperty(this, _getPlugin, {
value: _getPlugin2,
@@ -54,9 +53,7 @@ export default class Provider extends RequestClient {
this.tokenKey = `companion-${this.pluginId}-auth-token`;
this.companionKeysParams = this.opts.companionKeysParams;
this.preAuthToken = null;
- this.supportsRefreshToken = (_opts$supportsRefresh = opts.supportsRefreshToken) != null
- ? _opts$supportsRefresh
- : true;
+ this.supportsRefreshToken = !!opts.supportsRefreshToken;
}
async headers() {
const [headers, token] = await Promise.all([
diff --git a/packages/@uppy/companion-client/lib/RequestClient.js b/packages/@uppy/companion-client/lib/RequestClient.js
index 4cd47bd..a22de91 100644
--- a/packages/@uppy/companion-client/lib/RequestClient.js
+++ b/packages/@uppy/companion-client/lib/RequestClient.js
@@ -101,9 +101,7 @@ export default class RequestClient {
this.uppy = uppy;
this.opts = opts;
this.onReceiveResponse = this.onReceiveResponse.bind(this);
- _classPrivateFieldLooseBase(this, _companionHeaders)[_companionHeaders] = opts == null
- ? void 0
- : opts.companionHeaders;
+ _classPrivateFieldLooseBase(this, _companionHeaders)[_companionHeaders] = opts.companionHeaders;
}
setCompanionHeaders(headers) {
_classPrivateFieldLooseBase(this, _companionHeaders)[_companionHeaders] = headers;
@@ -176,22 +174,12 @@ export default class RequestClient {
}
}
async get(path, options) {
- if (typeof options === "boolean") {
- options = {
- skipPostResponse: options,
- };
- }
return this.request({
...options,
path,
});
}
async post(path, data, options) {
- if (typeof options === "boolean") {
- options = {
- skipPostResponse: options,
- };
- }
return this.request({
...options,
path,
@@ -200,11 +188,6 @@ export default class RequestClient {
});
}
async delete(path, data, options) {
- if (typeof options === "boolean") {
- options = {
- skipPostResponse: options,
- };
- }
return this.request({
...options,
path,
diff --git a/packages/@uppy/companion-client/lib/index.js b/packages/@uppy/companion-client/lib/index.js
index ef8da3e..97d80e6 100644
--- a/packages/@uppy/companion-client/lib/index.js
+++ b/packages/@uppy/companion-client/lib/index.js
@@ -4,4 +4,3 @@ export { default as RequestClient } from "./RequestClient.js";
export { default as SearchProvider } from "./SearchProvider.js";
import * as _tokenStorage from "./tokenStorage.js";
export { _tokenStorage as tokenStorage };
-export { default as Socket } from "./Socket.js";
diff --git a/packages/@uppy/companion/lib/companion.js b/packages/@uppy/companion/lib/companion.js
index 468315f..94f7d77 100644
--- a/packages/@uppy/companion/lib/companion.js
+++ b/packages/@uppy/companion/lib/companion.js
@@ -71,8 +71,8 @@ module.exports.app = (optionsArg = {}) => {
if (customProviders) {
providerManager.addCustomProviders(customProviders, providers, grantConfig);
}
- const getAuthProvider = (providerName) => providers[providerName]?.authProvider;
- providerManager.addProviderOptions(options, grantConfig, getAuthProvider);
+ const getOauthProvider = (providerName) => providers[providerName]?.oauthProvider;
+ providerManager.addProviderOptions(options, grantConfig, getOauthProvider);
// mask provider secrets from log messages
logger.setMaskables(getMaskableSecrets(options));
// create singleton redis client if corresponding options are set
@@ -88,7 +88,7 @@ module.exports.app = (optionsArg = {}) => {
// Making `POST` request to the `/connect/:provider/:override?` route requires a form body parser middleware:
// See https://github.com/simov/grant#dynamic-http
app.use(
- "/connect/:authProvider/:override?",
+ "/connect/:oauthProvider/:override?",
express.urlencoded({ extended: false }),
getCredentialsOverrideMiddleware(providers, options),
);
@@ -209,11 +209,11 @@ module.exports.app = (optionsArg = {}) => {
// we would query based on parameters
const { key, secret } = options.providerOptions[providerName];
function getRedirectUri() {
- const authProvider = getAuthProvider(providerName);
- if (!isOAuthProvider(authProvider)) {
+ const oauthProvider = getOauthProvider(providerName);
+ if (!isOAuthProvider(oauthProvider)) {
return undefined;
}
- return grantConfig[authProvider]?.redirect_uri;
+ return grantConfig[oauthProvider]?.redirect_uri;
}
res.send({
credentials: {
diff --git a/packages/@uppy/companion/lib/config/companion.js b/packages/@uppy/companion/lib/config/companion.js
index 400d9bc..f0d266d 100644
--- a/packages/@uppy/companion/lib/config/companion.js
+++ b/packages/@uppy/companion/lib/config/companion.js
@@ -17,7 +17,7 @@ const defaultOptions = {
getKey: defaultGetKey,
expires: 800, // seconds
},
- enableUrlEndpoint: true, // todo next major make this default false
+ enableUrlEndpoint: false,
allowLocalUrls: false,
periodicPingUrls: [],
streamingUpload: false,
diff --git a/packages/@uppy/companion/lib/server/Uploader.d.ts b/packages/@uppy/companion/lib/server/Uploader.d.ts
index ae38c05..41e1124 100644
--- a/packages/@uppy/companion/lib/server/Uploader.d.ts
+++ b/packages/@uppy/companion/lib/server/Uploader.d.ts
@@ -145,5 +145,4 @@ import tus = require("tus-js-client");
declare var FILE_NAME_PREFIX: string;
declare var STORAGE_PREFIX: string;
declare class ValidationError extends Error {
- constructor(message: any);
}
diff --git a/packages/@uppy/companion/lib/server/Uploader.js b/packages/@uppy/companion/lib/server/Uploader.js
index d487105..a391f1f 100644
--- a/packages/@uppy/companion/lib/server/Uploader.js
+++ b/packages/@uppy/companion/lib/server/Uploader.js
@@ -4,16 +4,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
const tus = require("tus-js-client");
const { randomUUID } = require("node:crypto");
const validator = require("validator");
-const { pipeline: pipelineCb } = require("node:stream");
+const { pipeline } = require("node:stream/promises");
const { join } = require("node:path");
const fs = require("node:fs");
-const { promisify } = require("node:util");
const throttle = require("lodash/throttle");
+const { once } = require("node:events");
const { Upload } = require("@aws-sdk/lib-storage");
const { rfc2047EncodeMetadata, getBucket } = require("./helpers/utils");
const got = require("./got");
-// TODO move to `require('streams/promises').pipeline` when dropping support for Node.js 14.x.
-const pipeline = promisify(pipelineCb);
const { createReadStream, createWriteStream, ReadStream } = fs;
const { stat, unlink } = fs.promises;
const emitter = require("./emitter");
@@ -33,22 +31,8 @@ const PROTOCOLS = Object.freeze({
function exceedsMaxFileSize(maxFileSize, size) {
return maxFileSize && size && size > maxFileSize;
}
-// TODO remove once we migrate away from form-data
-function sanitizeMetadata(inputMetadata) {
- if (inputMetadata == null) {
- return {};
- }
- const outputMetadata = {};
- Object.keys(inputMetadata).forEach((key) => {
- outputMetadata[key] = String(inputMetadata[key]);
- });
- return outputMetadata;
-}
class ValidationError extends Error {
- constructor(message) {
- super(message);
- this.name = "ValidationError";
- }
+ name = "ValidationError";
}
/**
* Validate the options passed down to the uplaoder
@@ -159,7 +143,7 @@ class Uploader {
this.options = options;
this.token = randomUUID();
this.fileName = `${Uploader.FILE_NAME_PREFIX}-${this.token}`;
- this.options.metadata = sanitizeMetadata(this.options.metadata);
+ this.options.metadata = this.options.metadata || {};
this.options.fieldname = this.options.fieldname || DEFAULT_FIELD_NAME;
this.size = options.size;
this.uploadFileName = this.options.metadata.name
@@ -306,7 +290,7 @@ class Uploader {
return;
}
logger.error(err, "uploader.error", this.shortToken);
- this.#emitError(err);
+ await this.#emitError(err);
} finally {
emitter().removeAllListeners(`pause:${this.token}`);
emitter().removeAllListeners(`resume:${this.token}`);
@@ -361,29 +345,9 @@ class Uploader {
}
async awaitReady(timeout) {
logger.debug("waiting for socket connection", "uploader.socket.wait", this.shortToken);
- // TODO: replace the Promise constructor call when dropping support for Node.js <16 with
- // await once(emitter, eventName, timeout && { signal: AbortSignal.timeout(timeout) })
- await new Promise((resolve, reject) => {
- const eventName = `connection:${this.token}`;
- let timer;
- let onEvent;
- function cleanup() {
- emitter().removeListener(eventName, onEvent);
- clearTimeout(timer);
- }
- if (timeout) {
- // Need to timeout after a while, or we could leak emitters
- timer = setTimeout(() => {
- cleanup();
- reject(new Error("Timed out waiting for socket connection"));
- }, timeout);
- }
- onEvent = () => {
- cleanup();
- resolve();
- };
- emitter().once(eventName, onEvent);
- });
+ const eventName = `connection:${this.token}`;
+ // eslint-disable-next-line compat/compat
+ await once(emitter(), eventName, timeout && { signal: AbortSignal.timeout(timeout) });
logger.debug("socket connection received", "uploader.socket.wait", this.shortToken);
}
/**
@@ -457,14 +421,13 @@ class Uploader {
*/
async #emitError(err) {
// delete stack to avoid sending server info to client
- // todo remove also extraData from serializedErr in next major,
// see PR discussion https://github.com/transloadit/uppy/pull/3832
+ // @ts-ignore
const { serializeError } = await import("serialize-error");
const { stack, ...serializedErr } = serializeError(err);
const dataToEmit = {
action: "error",
- // @ts-ignore
- payload: { ...err.extraData, error: serializedErr },
+ payload: { error: serializedErr },
};
this.saveState(dataToEmit);
emitter().emit(this.token, dataToEmit);
diff --git a/packages/@uppy/companion/lib/server/controllers/connect.js b/packages/@uppy/companion/lib/server/controllers/connect.js
index 08e799f..d61d7b5 100644
--- a/packages/@uppy/companion/lib/server/controllers/connect.js
+++ b/packages/@uppy/companion/lib/server/controllers/connect.js
@@ -42,11 +42,11 @@ module.exports = function connect(req, res) {
]];
}) || [],
);
- const { authProvider } = providerClass;
+ const { oauthProvider } = providerClass;
const qs = queryString({
...grantDynamicConfig,
state,
});
// Now we redirect to grant's /connect endpoint, see `app.use(Grant(grantConfig))`
- res.redirect(req.companion.buildURL(`/connect/${authProvider}${qs}`, true));
+ res.redirect(req.companion.buildURL(`/connect/${oauthProvider}${qs}`, true));
};
diff --git a/packages/@uppy/companion/lib/server/controllers/logout.js b/packages/@uppy/companion/lib/server/controllers/logout.js
index e7d05b4..6a5d4e2 100644
--- a/packages/@uppy/companion/lib/server/controllers/logout.js
+++ b/packages/@uppy/companion/lib/server/controllers/logout.js
@@ -24,7 +24,7 @@ async function logout(req, res, next) {
const { accessToken } = providerUserSession;
const data = await companion.provider.logout({ token: accessToken, providerUserSession, companion });
delete companion.providerUserSession;
- tokenService.removeFromCookies(res, companion.options, companion.providerClass.authProvider);
+ tokenService.removeFromCookies(res, companion.options, companion.providerClass.oauthProvider);
cleanSession();
res.json({ ok: true, ...data });
} catch (err) {
diff --git a/packages/@uppy/companion/lib/server/controllers/oauth-redirect.js b/packages/@uppy/companion/lib/server/controllers/oauth-redirect.js
index 85f0a6c..b5302d9 100644
--- a/packages/@uppy/companion/lib/server/controllers/oauth-redirect.js
+++ b/packages/@uppy/companion/lib/server/controllers/oauth-redirect.js
@@ -10,9 +10,9 @@ const oAuthState = require("../helpers/oauth-state");
*/
module.exports = function oauthRedirect(req, res) {
const params = qs.stringify(req.query);
- const { authProvider } = req.companion.providerClass;
+ const { oauthProvider } = req.companion.providerClass;
if (!req.companion.options.server.oauthDomain) {
- res.redirect(req.companion.buildURL(`/connect/${authProvider}/callback?${params}`, true));
+ res.redirect(req.companion.buildURL(`/connect/${oauthProvider}/callback?${params}`, true));
return;
}
const { state } = oAuthState.getGrantDynamicFromRequest(req);
@@ -23,7 +23,7 @@ module.exports = function oauthRedirect(req, res) {
const handler = oAuthState.getFromState(state, "companionInstance", req.companion.options.secret);
const handlerHostName = (new URL(handler)).host;
if (hasMatch(handlerHostName, req.companion.options.server.validHosts)) {
- const url = `${handler}/connect/${authProvider}/callback?${params}`;
+ const url = `${handler}/connect/${oauthProvider}/callback?${params}`;
res.redirect(url);
return;
}
diff --git a/packages/@uppy/companion/lib/server/controllers/s3.js b/packages/@uppy/companion/lib/server/controllers/s3.js
index 0776a58..2c49841 100644
--- a/packages/@uppy/companion/lib/server/controllers/s3.js
+++ b/packages/@uppy/companion/lib/server/controllers/s3.js
@@ -74,7 +74,7 @@ module.exports = function s3(config) {
Key: key,
}).then(data => {
res.json({
- method: "post", // TODO: switch to the uppercase 'POST' in the next major
+ method: "POST",
url: data.url,
fields: data.fields,
expires: config.expires,
diff --git a/packages/@uppy/companion/lib/server/controllers/url.js b/packages/@uppy/companion/lib/server/controllers/url.js
index 4eec4d6..67a67aa 100644
--- a/packages/@uppy/companion/lib/server/controllers/url.js
+++ b/packages/@uppy/companion/lib/server/controllers/url.js
@@ -16,15 +16,13 @@ const logger = require("../logger");
* to the callback chunk by chunk.
*
* @param {string} url
- * @param {boolean} blockLocalIPs
+ * @param {boolean} allowLocalIPs
* @param {string} traceId
* @returns {Promise}
*/
-const downloadURL = async (url, blockLocalIPs, traceId) => {
- // TODO in next major, rename all blockLocalIPs to allowLocalUrls and invert the bool, to make it consistent
- // see discussion https://github.com/transloadit/uppy/pull/4554/files#r1268677162
+const downloadURL = async (url, allowLocalIPs, traceId) => {
try {
- const protectedGot = await getProtectedGot({ blockLocalIPs });
+ const protectedGot = await getProtectedGot({ allowLocalIPs });
const stream = protectedGot.stream.get(url, { responseType: "json" });
await prepareStream(stream);
return stream;
@@ -47,7 +45,7 @@ const meta = async (req, res) => {
logger.debug("Invalid request body detected. Exiting url meta handler.", null, req.id);
return res.status(400).json({ error: "Invalid request body" });
}
- const urlMeta = await getURLMeta(req.body.url, !allowLocalUrls);
+ const urlMeta = await getURLMeta(req.body.url, allowLocalUrls);
return res.json(urlMeta);
} catch (err) {
logger.error(err, "controller.url.meta.error", req.id);
@@ -70,11 +68,11 @@ const get = async (req, res) => {
return;
}
async function getSize() {
- const { size } = await getURLMeta(req.body.url, !allowLocalUrls);
+ const { size } = await getURLMeta(req.body.url, allowLocalUrls);
return size;
}
async function download() {
- return downloadURL(req.body.url, !allowLocalUrls, req.id);
+ return downloadURL(req.body.url, allowLocalUrls, req.id);
}
try {
await startDownUpload({ req, res, getSize, download });
diff --git a/packages/@uppy/companion/lib/server/helpers/jwt.d.ts b/packages/@uppy/companion/lib/server/helpers/jwt.d.ts
index e2ccb3e..cdcf720 100644
--- a/packages/@uppy/companion/lib/server/helpers/jwt.d.ts
+++ b/packages/@uppy/companion/lib/server/helpers/jwt.d.ts
@@ -3,6 +3,6 @@ export function generateEncryptedAuthToken(payload: any, secret: string, maxAge:
export function verifyEncryptedToken(token: string, secret: string): any;
export function verifyEncryptedAuthToken(token: string, secret: string, providerName: any): any;
export function addToCookiesIfNeeded(req: any, res: any, uppyAuthToken: any, maxAge: any): void;
-export function removeFromCookies(res: object, companionOptions: object, authProvider: string): void;
+export function removeFromCookies(res: object, companionOptions: object, oauthProvider: string): void;
export const MAX_AGE_24H: number;
export const MAX_AGE_REFRESH_TOKEN: number;
diff --git a/packages/@uppy/companion/lib/server/helpers/jwt.js b/packages/@uppy/companion/lib/server/helpers/jwt.js
index d12b8d7..9a1d191 100644
--- a/packages/@uppy/companion/lib/server/helpers/jwt.js
+++ b/packages/@uppy/companion/lib/server/helpers/jwt.js
@@ -93,14 +93,14 @@ function getCommonCookieOptions({ companionOptions }) {
}
return cookieOptions;
}
-const getCookieName = (authProvider) => `uppyAuthToken--${authProvider}`;
-const addToCookies = ({ res, token, companionOptions, authProvider, maxAge = MAX_AGE_24H * 1000 }) => {
+const getCookieName = (oauthProvider) => `uppyAuthToken--${oauthProvider}`;
+const addToCookies = ({ res, token, companionOptions, oauthProvider, maxAge = MAX_AGE_24H * 1000 }) => {
const cookieOptions = {
...getCommonCookieOptions({ companionOptions }),
maxAge,
};
// send signed token to client.
- res.cookie(getCookieName(authProvider), token, cookieOptions);
+ res.cookie(getCookieName(oauthProvider), token, cookieOptions);
};
module.exports.addToCookiesIfNeeded = (req, res, uppyAuthToken, maxAge) => {
// some providers need the token in cookies for thumbnail/image requests
@@ -109,7 +109,7 @@ module.exports.addToCookiesIfNeeded = (req, res, uppyAuthToken, maxAge) => {
res,
token: uppyAuthToken,
companionOptions: req.companion.options,
- authProvider: req.companion.providerClass.authProvider,
+ oauthProvider: req.companion.providerClass.oauthProvider,
maxAge,
});
}
@@ -117,11 +117,11 @@ module.exports.addToCookiesIfNeeded = (req, res, uppyAuthToken, maxAge) => {
/**
* @param {object} res
* @param {object} companionOptions
- * @param {string} authProvider
+ * @param {string} oauthProvider
*/
-module.exports.removeFromCookies = (res, companionOptions, authProvider) => {
+module.exports.removeFromCookies = (res, companionOptions, oauthProvider) => {
// options must be identical to those given to res.cookie(), excluding expires and maxAge.
// https://expressjs.com/en/api.html#res.clearCookie
const cookieOptions = getCommonCookieOptions({ companionOptions });
- res.clearCookie(getCookieName(authProvider), cookieOptions);
+ res.clearCookie(getCookieName(oauthProvider), cookieOptions);
};
diff --git a/packages/@uppy/companion/lib/server/helpers/request.d.ts b/packages/@uppy/companion/lib/server/helpers/request.d.ts
index ae249b4..eff658a 100644
--- a/packages/@uppy/companion/lib/server/helpers/request.d.ts
+++ b/packages/@uppy/companion/lib/server/helpers/request.d.ts
@@ -1,5 +1,5 @@
/// <reference types="node" />
-export function getURLMeta(url: string, blockLocalIPs?: boolean): Promise<{
+export function getURLMeta(url: string, allowLocalIPs?: boolean): Promise<{
name: string;
type: string;
size: number;
@@ -15,15 +15,15 @@ export function validateURL(url: string, allowLocalUrls: boolean): boolean;
/**
* Returns http Agent that will prevent requests to private IPs (to prevent SSRF)
*/
-export function getProtectedHttpAgent({ protocol, blockLocalIPs }: {
+export function getProtectedHttpAgent({ protocol, allowLocalIPs }: {
protocol: any;
- blockLocalIPs: any;
+ allowLocalIPs: any;
}): {
new (options?: https.AgentOptions): {
createConnection(options: any, callback: any): any;
};
};
-export function getProtectedGot({ blockLocalIPs }: {
- blockLocalIPs: any;
+export function getProtectedGot({ allowLocalIPs }: {
+ allowLocalIPs: any;
}): Promise<import("got", { with: { "resolution-mode": "import" } }).Got>;
import https = require("node:https");
diff --git a/packages/@uppy/companion/lib/server/helpers/request.js b/packages/@uppy/companion/lib/server/helpers/request.js
index b0233ab..9c78f29 100644
--- a/packages/@uppy/companion/lib/server/helpers/request.js
+++ b/packages/@uppy/companion/lib/server/helpers/request.js
@@ -39,7 +39,7 @@ module.exports.validateURL = validateURL;
/**
* Returns http Agent that will prevent requests to private IPs (to prevent SSRF)
*/
-const getProtectedHttpAgent = ({ protocol, blockLocalIPs }) => {
+const getProtectedHttpAgent = ({ protocol, allowLocalIPs }) => {
function dnsLookup(hostname, options, callback) {
dns.lookup(hostname, options, (err, addresses, maybeFamily) => {
if (err) {
@@ -50,7 +50,7 @@ const getProtectedHttpAgent = ({ protocol, blockLocalIPs }) => {
// because dns.lookup seems to be called with option `all: true`, if we are on an ipv6 system,
// `addresses` could contain a list of ipv4 addresses as well as ipv6 mapped addresses (rfc6052) which we cannot allow
// however we should still allow any valid ipv4 addresses, so we filter out the invalid addresses
- const validAddresses = !blockLocalIPs ? toValidate : toValidate.filter(({ address }) => !isDisallowedIP(address));
+ const validAddresses = allowLocalIPs ? toValidate : toValidate.filter(({ address }) => !isDisallowedIP(address));
// and check if there's anything left after we filtered:
if (validAddresses.length === 0) {
callback(
@@ -68,7 +68,7 @@ const getProtectedHttpAgent = ({ protocol, blockLocalIPs }) => {
}
return class HttpAgent extends (protocol.startsWith("https") ? https : http).Agent {
createConnection(options, callback) {
- if (ipaddr.isValid(options.host) && blockLocalIPs && isDisallowedIP(options.host)) {
+ if (ipaddr.isValid(options.host) && !allowLocalIPs && isDisallowedIP(options.host)) {
callback(new Error(FORBIDDEN_IP_ADDRESS));
return undefined;
}
@@ -78,9 +78,9 @@ const getProtectedHttpAgent = ({ protocol, blockLocalIPs }) => {
};
};
module.exports.getProtectedHttpAgent = getProtectedHttpAgent;
-async function getProtectedGot({ blockLocalIPs }) {
- const HttpAgent = getProtectedHttpAgent({ protocol: "http", blockLocalIPs });
- const HttpsAgent = getProtectedHttpAgent({ protocol: "https", blockLocalIPs });
+async function getProtectedGot({ allowLocalIPs }) {
+ const HttpAgent = getProtectedHttpAgent({ protocol: "http", allowLocalIPs });
+ const HttpsAgent = getProtectedHttpAgent({ protocol: "https", allowLocalIPs });
const httpAgent = new HttpAgent();
const httpsAgent = new HttpsAgent();
// @ts-ignore
@@ -91,12 +91,12 @@ module.exports.getProtectedGot = getProtectedGot;
* Gets the size and content type of a url's content
*
* @param {string} url
- * @param {boolean} blockLocalIPs
+ * @param {boolean} allowLocalIPs
* @returns {Promise<{name: string, type: string, size: number}>}
*/
-exports.getURLMeta = async (url, blockLocalIPs = false) => {
+exports.getURLMeta = async (url, allowLocalIPs = false) => {
async function requestWithMethod(method) {
- const protectedGot = await getProtectedGot({ blockLocalIPs });
+ const protectedGot = await getProtectedGot({ allowLocalIPs });
const stream = protectedGot.stream(url, { method, throwHttpErrors: false });
return new Promise((resolve, reject) => (stream
.on("response", (response) => {
diff --git a/packages/@uppy/companion/lib/server/jobs.js b/packages/@uppy/companion/lib/server/jobs.js
index c1ad3bd..9639dea 100644
--- a/packages/@uppy/companion/lib/server/jobs.js
+++ b/packages/@uppy/companion/lib/server/jobs.js
@@ -3,12 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
const schedule = require("node-schedule");
const fs = require("node:fs");
const path = require("node:path");
-const { promisify } = require("node:util");
+const { setTimeout: sleep } = require("node:timers/promises");
const got = require("./got");
const { FILE_NAME_PREFIX } = require("./Uploader");
const logger = require("./logger");
-// TODO rewrite to use require('timers/promises').setTimeout when we support newer node versions
-const sleep = promisify(setTimeout);
const cleanUpFinishedUploads = (dirPath) => {
logger.info(`running clean up job for path: ${dirPath}`, "jobs.cleanup.progress.read");
fs.readdir(dirPath, (err, files) => {
diff --git a/packages/@uppy/companion/lib/server/middlewares.js b/packages/@uppy/companion/lib/server/middlewares.js
index ad99f4a..1648c3c 100644
--- a/packages/@uppy/companion/lib/server/middlewares.js
+++ b/packages/@uppy/companion/lib/server/middlewares.js
@@ -20,7 +20,7 @@ exports.hasSessionAndProvider = (req, res, next) => {
}
return next();
};
-const isOAuthProviderReq = (req) => isOAuthProvider(req.companion.providerClass.authProvider);
+const isOAuthProviderReq = (req) => isOAuthProvider(req.companion.providerClass.oauthProvider);
const isSimpleAuthProviderReq = (req) => !!req.companion.providerClass.hasSimpleAuth;
/**
* Middleware can be used to verify that the current request is to an OAuth provider
@@ -108,7 +108,7 @@ exports.gentleVerifyToken = (req, res, next) => {
next();
};
exports.cookieAuthToken = (req, res, next) => {
- req.companion.authToken = req.cookies[`uppyAuthToken--${req.companion.providerClass.authProvider}`];
+ req.companion.authToken = req.cookies[`uppyAuthToken--${req.companion.providerClass.oauthProvider}`];
return next();
};
exports.cors = (options = {}) => (req, res, next) => {
@@ -116,15 +116,12 @@ exports.cors = (options = {}) => (req, res, next) => {
// I believe that HTTP verbs are case sensitive, and should be uppercase.
const existingExposeHeaders = res.get("Access-Control-Expose-Headers");
const exposeHeadersSet = new Set(existingExposeHeaders?.split(",")?.map((method) => method.trim().toLowerCase()));
- // exposed so it can be accessed for our custom uppy client preflight
- exposeHeadersSet.add("access-control-allow-headers"); // todo remove in next major, see https://github.com/transloadit/uppy/pull/4462
if (options.sendSelfEndpoint) {
exposeHeadersSet.add("i-am");
}
// Needed for basic operation: https://github.com/transloadit/uppy/issues/3021
const allowedHeaders = [
"uppy-auth-token",
- "uppy-versions", // todo remove in the future? see https://github.com/transloadit/uppy/pull/4462
"uppy-credentials-params",
"authorization",
"origin",
diff --git a/packages/@uppy/companion/lib/server/provider/Provider.d.ts b/packages/@uppy/companion/lib/server/provider/Provider.d.ts
index ebb30cd..8977358 100644
--- a/packages/@uppy/companion/lib/server/provider/Provider.d.ts
+++ b/packages/@uppy/companion/lib/server/provider/Provider.d.ts
@@ -5,15 +5,14 @@ export = Provider;
declare class Provider {
/**
* config to extend the grant config
- * todo major: rename to getExtraGrantConfig
*/
- static getExtraConfig(): {};
+ static getExtraGrantConfig(): {};
/**
* Name of the OAuth provider (passed to Grant). Return empty string if no OAuth provider is needed.
*
* @returns {string}
*/
- static get authProvider(): string;
+ static get oauthProvider(): string;
static grantDynamicToUserSession({ grantDynamic }: {
grantDynamic: any;
}): {};
@@ -79,4 +78,4 @@ declare class Provider {
declare namespace Provider {
export { isOAuthProvider };
}
-declare function isOAuthProvider(authProvider: any): boolean;
+declare function isOAuthProvider(oauthProvider: any): boolean;
diff --git a/packages/@uppy/companion/lib/server/provider/Provider.js b/packages/@uppy/companion/lib/server/provider/Provider.js
index f48844b..1ec5d0d 100644
--- a/packages/@uppy/companion/lib/server/provider/Provider.js
+++ b/packages/@uppy/companion/lib/server/provider/Provider.js
@@ -17,9 +17,8 @@ class Provider {
}
/**
* config to extend the grant config
- * todo major: rename to getExtraGrantConfig
*/
- static getExtraConfig() {
+ static getExtraGrantConfig() {
return {};
}
/**
@@ -93,8 +92,7 @@ class Provider {
*
* @returns {string}
*/
- // todo next major: rename authProvider to oauthProvider (we have other non-oauth auth types too now)
- static get authProvider() {
+ static get oauthProvider() {
return undefined;
}
// eslint-disable-next-line no-unused-vars
@@ -109,5 +107,5 @@ class Provider {
}
}
module.exports = Provider;
-// OAuth providers are those that have an `authProvider` set. It means they require OAuth authentication to work
-module.exports.isOAuthProvider = (authProvider) => typeof authProvider === "string" && authProvider.length > 0;
+// OAuth providers are those that have an `oauthProvider` set. It means they require OAuth authentication to work
+module.exports.isOAuthProvider = (oauthProvider) => typeof oauthProvider === "string" && oauthProvider.length > 0;
diff --git a/packages/@uppy/companion/lib/server/provider/box/index.js b/packages/@uppy/companion/lib/server/provider/box/index.js
index aecedbc..d80f7cd 100644
--- a/packages/@uppy/companion/lib/server/provider/box/index.js
+++ b/packages/@uppy/companion/lib/server/provider/box/index.js
@@ -34,7 +34,7 @@ class Box extends Provider {
// needed for the thumbnails fetched via companion
this.needsCookieAuth = true;
}
- static get authProvider() {
+ static get oauthProvider() {
return "box";
}
/**
@@ -108,7 +108,7 @@ class Box extends Provider {
return withProviderErrorHandling({
fn,
tag,
- providerName: _a.authProvider,
+ providerName: _a.oauthProvider,
isAuthError: (response) => response.statusCode === 401,
getJsonErrorMessage: (body) => body?.message,
});
diff --git a/packages/@uppy/companion/lib/server/provider/credentials.js b/packages/@uppy/companion/lib/server/provider/credentials.js
index ea3ed97..cdd6fb2 100644
--- a/packages/@uppy/companion/lib/server/provider/credentials.js
+++ b/packages/@uppy/companion/lib/server/provider/credentials.js
@@ -66,8 +66,8 @@ async function fetchProviderKeys(providerName, companionOptions, credentialReque
exports.getCredentialsOverrideMiddleware = (providers, companionOptions) => {
return async (req, res, next) => {
try {
- const { authProvider, override } = req.params;
- const [providerName] = Object.keys(providers).filter((name) => providers[name].authProvider === authProvider);
+ const { oauthProvider, override } = req.params;
+ const [providerName] = Object.keys(providers).filter((name) => providers[name].oauthProvider === oauthProvider);
if (!providerName) {
next();
return;
diff --git a/packages/@uppy/companion/lib/server/provider/drive/index.js b/packages/@uppy/companion/lib/server/provider/drive/index.js
index 8dd13a2..c5381fd 100644
--- a/packages/@uppy/companion/lib/server/provider/drive/index.js
+++ b/packages/@uppy/companion/lib/server/provider/drive/index.js
@@ -51,7 +51,7 @@ async function getStats({ id, token }) {
* Adapter for API https://developers.google.com/drive/api/v3/
*/
class Drive extends Provider {
- static get authProvider() {
+ static get oauthProvider() {
return "google";
}
static get authStateExpiry() {
@@ -205,7 +205,7 @@ class Drive extends Provider {
return withProviderErrorHandling({
fn,
tag,
- providerName: _a.authProvider,
+ providerName: _a.oauthProvider,
isAuthError: (response) => (
response.statusCode === 401
|| (response.statusCode === 400 && response.body?.error === "invalid_grant") // Refresh token has expired or been revoked
diff --git a/packages/@uppy/companion/lib/server/provider/dropbox/index.js b/packages/@uppy/companion/lib/server/provider/dropbox/index.js
index b611a97..8c7eb6a 100644
--- a/packages/@uppy/companion/lib/server/provider/dropbox/index.js
+++ b/packages/@uppy/companion/lib/server/provider/dropbox/index.js
@@ -55,7 +55,7 @@ class DropBox extends Provider {
super(options);
this.needsCookieAuth = true;
}
- static get authProvider() {
+ static get oauthProvider() {
return "dropbox";
}
static get authStateExpiry() {
@@ -141,7 +141,7 @@ class DropBox extends Provider {
return withProviderErrorHandling({
fn,
tag,
- providerName: _a.authProvider,
+ providerName: _a.oauthProvider,
isAuthError: (response) => response.statusCode === 401,
getJsonErrorMessage: (body) => body?.error_summary,
});
diff --git a/packages/@uppy/companion/lib/server/provider/facebook/index.js b/packages/@uppy/companion/lib/server/provider/facebook/index.js
index 55eec3c..d760375 100644
--- a/packages/@uppy/companion/lib/server/provider/facebook/index.js
+++ b/packages/@uppy/companion/lib/server/provider/facebook/index.js
@@ -27,7 +27,7 @@ async function getMediaUrl({ token, id }) {
* Adapter for API https://developers.facebook.com/docs/graph-api/using-graph-api/
*/
class Facebook extends Provider {
- static get authProvider() {
+ static get oauthProvider() {
return "facebook";
}
async list({ directory, token, query = { cursor: null } }) {
@@ -66,7 +66,7 @@ class Facebook extends Provider {
async size({ id, token }) {
return this.#withErrorHandling("provider.facebook.size.error", async () => {
const url = await getMediaUrl({ token, id });
- const { size } = await getURLMeta(url, true);
+ const { size } = await getURLMeta(url);
return size;
});
}
@@ -81,7 +81,7 @@ class Facebook extends Provider {
return withProviderErrorHandling({
fn,
tag,
- providerName: _a.authProvider,
+ providerName: _a.oauthProvider,
isAuthError: (response) => typeof response.body === "object" && response.body?.error?.code === 190, // Invalid OAuth 2.0 Access Token
getJsonErrorMessage: (body) => body?.error?.message,
});
diff --git a/packages/@uppy/companion/lib/server/provider/index.d.ts b/packages/@uppy/companion/lib/server/provider/index.d.ts
index 4b01f57..9c58d63 100644
--- a/packages/@uppy/companion/lib/server/provider/index.d.ts
+++ b/packages/@uppy/companion/lib/server/provider/index.d.ts
@@ -4,7 +4,7 @@ export function addCustomProviders(customProviders: Record<string, CustomProvide
export function addProviderOptions(companionOptions: {
server: object;
providerOptions: object;
-}, grantConfig: object, getAuthProvider: (a: string) => string): void;
+}, grantConfig: object, getOauthProvider: (a: string) => string): void;
export type CustomProvider = {
'module': typeof Provider;
config: Record<string, unknown>;
diff --git a/packages/@uppy/companion/lib/server/provider/index.js b/packages/@uppy/companion/lib/server/provider/index.js
index c9693ac..3be93fc 100644
--- a/packages/@uppy/companion/lib/server/provider/index.js
+++ b/packages/@uppy/companion/lib/server/provider/index.js
@@ -39,11 +39,11 @@ module.exports.getProviderMiddleware = (providers, grantConfig) => {
const ProviderClass = providers[providerName];
if (ProviderClass && validOptions(req.companion.options)) {
const { allowLocalUrls } = req.companion.options;
- const { authProvider } = ProviderClass;
+ const { oauthProvider } = ProviderClass;
let providerGrantConfig;
- if (isOAuthProvider(authProvider)) {
+ if (isOAuthProvider(oauthProvider)) {
req.companion.getProviderCredentials = getCredentialsResolver(providerName, req.companion.options, req);
- providerGrantConfig = grantConfig[authProvider];
+ providerGrantConfig = grantConfig[oauthProvider];
req.companion.providerGrantConfig = providerGrantConfig;
}
req.companion.provider = new ProviderClass({ providerName, providerGrantConfig, allowLocalUrls });
@@ -78,10 +78,10 @@ module.exports.addCustomProviders = (customProviders, providers, grantConfig) =>
const customProvider = customProviders[providerName];
// eslint-disable-next-line no-param-reassign
providers[providerName] = customProvider.module;
- const { authProvider } = customProvider.module;
- if (isOAuthProvider(authProvider)) {
+ const { oauthProvider } = customProvider.module;
+ if (isOAuthProvider(oauthProvider)) {
// eslint-disable-next-line no-param-reassign
- grantConfig[authProvider] = {
+ grantConfig[oauthProvider] = {
...customProvider.config,
// todo: consider setting these options from a universal point also used
// by official providers. It'll prevent these from getting left out if the
@@ -95,9 +95,9 @@ module.exports.addCustomProviders = (customProviders, providers, grantConfig) =>
/**
* @param {{server: object, providerOptions: object}} companionOptions
* @param {object} grantConfig
- * @param {(a: string) => string} getAuthProvider
+ * @param {(a: string) => string} getOauthProvider
*/
-module.exports.addProviderOptions = (companionOptions, grantConfig, getAuthProvider) => {
+module.exports.addProviderOptions = (companionOptions, grantConfig, getOauthProvider) => {
const { server, providerOptions } = companionOptions;
if (!validOptions({ server })) {
logger.warn("invalid provider options detected. Providers will not be loaded", "provider.options.invalid");
@@ -112,36 +112,36 @@ module.exports.addProviderOptions = (companionOptions, grantConfig, getAuthProvi
const { oauthDomain } = server;
const keys = Object.keys(providerOptions).filter((key) => key !== "server");
keys.forEach((providerName) => {
- const authProvider = getAuthProvider?.(providerName);
- if (isOAuthProvider(authProvider) && grantConfig[authProvider]) {
+ const oauthProvider = getOauthProvider?.(providerName);
+ if (isOAuthProvider(oauthProvider) && grantConfig[oauthProvider]) {
// explicitly add providerOptions so users don't override other providerOptions.
// eslint-disable-next-line no-param-reassign
- grantConfig[authProvider].key = providerOptions[providerName].key;
+ grantConfig[oauthProvider].key = providerOptions[providerName].key;
// eslint-disable-next-line no-param-reassign
- grantConfig[authProvider].secret = providerOptions[providerName].secret;
+ grantConfig[oauthProvider].secret = providerOptions[providerName].secret;
if (providerOptions[providerName].credentialsURL) {
// eslint-disable-next-line no-param-reassign
- grantConfig[authProvider].dynamic = ["key", "secret", "redirect_uri"];
+ grantConfig[oauthProvider].dynamic = ["key", "secret", "redirect_uri"];
}
const provider = exports.getDefaultProviders()[providerName];
- Object.assign(grantConfig[authProvider], provider.getExtraConfig());
+ Object.assign(grantConfig[oauthProvider], provider.getExtraGrantConfig());
// override grant.js redirect uri with companion's custom redirect url
const isExternal = !!server.implicitPath;
const redirectPath = `/${providerName}/redirect`;
// eslint-disable-next-line no-param-reassign
- grantConfig[authProvider].redirect_uri = getURLBuilder(companionOptions)(redirectPath, isExternal);
+ grantConfig[oauthProvider].redirect_uri = getURLBuilder(companionOptions)(redirectPath, isExternal);
if (oauthDomain) {
const fullRedirectPath = getURLBuilder(companionOptions)(redirectPath, isExternal, true);
// eslint-disable-next-line no-param-reassign
- grantConfig[authProvider].redirect_uri = `${server.protocol}://${oauthDomain}${fullRedirectPath}`;
+ grantConfig[oauthProvider].redirect_uri = `${server.protocol}://${oauthDomain}${fullRedirectPath}`;
}
if (server.implicitPath) {
// no url builder is used for this because grant internally adds the path
// eslint-disable-next-line no-param-reassign
- grantConfig[authProvider].callback = `${server.implicitPath}${grantConfig[authProvider].callback}`;
+ grantConfig[oauthProvider].callback = `${server.implicitPath}${grantConfig[oauthProvider].callback}`;
} else if (server.path) {
// eslint-disable-next-line no-param-reassign
- grantConfig[authProvider].callback = `${server.path}${grantConfig[authProvider].callback}`;
+ grantConfig[oauthProvider].callback = `${server.path}${grantConfig[oauthProvider].callback}`;
}
}
});
diff --git a/packages/@uppy/companion/lib/server/provider/instagram/graph/index.d.ts b/packages/@uppy/companion/lib/server/provider/instagram/graph/index.d.ts
index f596a39..96532dc 100644
--- a/packages/@uppy/companion/lib/server/provider/instagram/graph/index.d.ts
+++ b/packages/@uppy/companion/lib/server/provider/instagram/graph/index.d.ts
@@ -3,7 +3,7 @@ export = Instagram;
* Adapter for API https://developers.facebook.com/docs/instagram-api/overview
*/
declare class Instagram extends Provider {
- static getExtraConfig(): {
+ static getExtraGrantConfig(): {
protocol: string;
scope: string[];
};
diff --git a/packages/@uppy/companion/lib/server/provider/instagram/graph/index.js b/packages/@uppy/companion/lib/server/provider/instagram/graph/index.js
index 6a26f19..c674bbe 100644
--- a/packages/@uppy/companion/lib/server/provider/instagram/graph/index.js
+++ b/packages/@uppy/companion/lib/server/provider/instagram/graph/index.js
@@ -27,13 +27,13 @@ async function getMediaUrl({ token, id }) {
*/
class Instagram extends Provider {
// for "grant"
- static getExtraConfig() {
+ static getExtraGrantConfig() {
return {
protocol: "https",
scope: ["user_profile", "user_media"],
};
}
- static get authProvider() {
+ static get oauthProvider() {
return "instagram";
}
async list({ directory, token, query = { cursor: null } }) {
@@ -70,7 +70,7 @@ class Instagram extends Provider {
async size({ id, token }) {
return this.#withErrorHandling("provider.instagram.size.error", async () => {
const url = await getMediaUrl({ token, id });
- const { size } = await getURLMeta(url, true);
+ const { size } = await getURLMeta(url);
return size;
});
}
@@ -84,7 +84,7 @@ class Instagram extends Provider {
return withProviderErrorHandling({
fn,
tag,
- providerName: _a.authProvider,
+ providerName: _a.oauthProvider,
isAuthError: (response) => typeof response.body === "object" && response.body?.error?.code === 190, // Invalid OAuth 2.0 Access Token
getJsonErrorMessage: (body) => body?.error?.message,
});
diff --git a/packages/@uppy/companion/lib/server/provider/onedrive/index.js b/packages/@uppy/companion/lib/server/provider/onedrive/index.js
index 9baad68..3f8fb0c 100644
--- a/packages/@uppy/companion/lib/server/provider/onedrive/index.js
+++ b/packages/@uppy/companion/lib/server/provider/onedrive/index.js
@@ -23,7 +23,7 @@ const getRootPath = (query) => (query.driveId ? `drives/${query.driveId}` : "me/
* Adapter for API https://docs.microsoft.com/en-us/onedrive/developer/rest-api/
*/
class OneDrive extends Provider {
- static get authProvider() {
+ static get oauthProvider() {
return "microsoft";
}
/**
@@ -101,7 +101,7 @@ class OneDrive extends Provider {
return withProviderErrorHandling({
fn,
tag,
- providerName: _a.authProvider,
+ providerName: _a.oauthProvider,
isAuthError: (response) => response.statusCode === 401,
isUserFacingError: (response) => [400, 403].includes(response.statusCode),
// onedrive gives some errors here that the user might want to know about
diff --git a/packages/@uppy/companion/lib/server/provider/unsplash/index.js b/packages/@uppy/companion/lib/server/provider/unsplash/index.js
index 1d6b8b4..cf69ba7 100644
--- a/packages/@uppy/companion/lib/server/provider/unsplash/index.js
+++ b/packages/@uppy/companion/lib/server/provider/unsplash/index.js
@@ -53,7 +53,7 @@ class Unsplash extends Provider {
async size({ id, token }) {
return this.#withErrorHandling("provider.unsplash.size.error", async () => {
const { links: { download: url } } = await getPhotoMeta(await getClient({ token }), id);
- const { size } = await getURLMeta(url, true);
+ const { size } = await getURLMeta(url);
return size;
});
}
diff --git a/packages/@uppy/companion/lib/server/provider/zoom/index.js b/packages/@uppy/companion/lib/server/provider/zoom/index.js
index 59b4017..b674764 100644
--- a/packages/@uppy/companion/lib/server/provider/zoom/index.js
+++ b/packages/@uppy/companion/lib/server/provider/zoom/index.js
@@ -29,7 +29,7 @@ async function findFile({ client, meetingId, fileId, recordingStart }) {
* Adapter for API https://marketplace.zoom.us/docs/api-reference/zoom-api
*/
class Zoom extends Provider {
- static get authProvider() {
+ static get oauthProvider() {
return "zoom";
}
/*
@@ -145,7 +145,7 @@ class Zoom extends Provider {
return withProviderErrorHandling({
fn,
tag,
- providerName: _a.authProvider,
+ providerName: _a.oauthProvider,
isAuthError: (response) => authErrorCodes.includes(response.statusCode),
getJsonErrorMessage: (body) => body?.message,
});
diff --git a/packages/@uppy/companion/lib/standalone/helper.js b/packages/@uppy/companion/lib/standalone/helper.js
index 7731990..7fee749 100644
--- a/packages/@uppy/companion/lib/standalone/helper.js
+++ b/packages/@uppy/companion/lib/standalone/helper.js
@@ -127,9 +127,7 @@ const getConfigFromEnv = () => {
oauthDomain: process.env.COMPANION_OAUTH_DOMAIN,
validHosts,
},
- // todo next major make this default false
- enableUrlEndpoint: process.env.COMPANION_ENABLE_URL_ENDPOINT == null
- || process.env.COMPANION_ENABLE_URL_ENDPOINT === "true",
+ enableUrlEndpoint: process.env.COMPANION_ENABLE_URL_ENDPOINT === "true",
periodicPingUrls: process.env.COMPANION_PERIODIC_PING_URLS
? process.env.COMPANION_PERIODIC_PING_URLS.split(",")
: [],
diff --git a/packages/@uppy/companion/lib/standalone/index.js b/packages/@uppy/companion/lib/standalone/index.js
index 71517a9..1ac6011 100644
--- a/packages/@uppy/companion/lib/standalone/index.js
+++ b/packages/@uppy/companion/lib/standalone/index.js
@@ -107,10 +107,9 @@ module.exports = function server(inputCompanionOptions) {
};
const redisClient = redis.client(companionOptions);
if (redisClient) {
- // todo next major: change default prefix to something like "companion-session:" and possibly remove this option
sessionOptions.store = new RedisStore({
client: redisClient,
- prefix: process.env.COMPANION_REDIS_EXPRESS_SESSION_PREFIX || "sess:",
+ prefix: process.env.COMPANION_REDIS_EXPRESS_SESSION_PREFIX || "companion-session:",
});
}
if (process.env.COMPANION_COOKIE_DOMAIN) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Doing it in separate commits really helped with reviewing.
I think it would be good to start a migration guide file already and add to it in every PR. We're a bit late with that, as many PRs are already landed, but it will be a lot easier to document the breaking changes while we still have it fresh on our minds than to dive into this PR again later to figure out what changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migration guide looks good 👍
`COMPANION_REDIS_EXPRESS_SESSION_PREFIX` to `companion-session:`
fef4f90
to
2872f22
Compare
`serverUrl` and `serverPattern` were deprecated, this commit removes them.
Now that we are no longer using form-data which had a bug and crashed when sending non-string meta.
Uppy no longer uses `Access-Control-Expose-Headers` and `uppy-versions`.
`COMPANION_REDIS_EXPRESS_SESSION_PREFIX` to `companion-session:`.
See discussion in #3832.
`serverUrl` and `serverPattern` were deprecated, this commit removes them.
Now that we are no longer using form-data which had a bug and crashed when sending non-string meta.
Uppy no longer uses `Access-Control-Expose-Headers` and `uppy-versions`.
2872f22
to
1b1e5c7
Compare
I've reworded c148139...fef4f90 and squashed commits when it made sense. CI is green, landing. |
| Package | Version | Package | Version | | ---------------------- | ------------- | ---------------------- | ------------- | | @uppy/angular | 0.7.0-beta.5 | @uppy/instagram | 4.0.0-beta.6 | | @uppy/audio | 2.0.0-beta.6 | @uppy/locales | 4.0.0-beta.2 | | @uppy/aws-s3 | 4.0.0-beta.5 | @uppy/onedrive | 4.0.0-beta.6 | | @uppy/aws-s3-multipart | 4.0.0-beta.6 | @uppy/provider-views | 4.0.0-beta.7 | | @uppy/box | 3.0.0-beta.6 | @uppy/status-bar | 4.0.0-beta.9 | | @uppy/companion | 5.0.0-beta.9 | @uppy/transloadit | 4.0.0-beta.7 | | @uppy/companion-client | 4.0.0-beta.7 | @uppy/tus | 4.0.0-beta.6 | | @uppy/core | 4.0.0-beta.9 | @uppy/unsplash | 4.0.0-beta.7 | | @uppy/dashboard | 4.0.0-beta.9 | @uppy/url | 4.0.0-beta.7 | | @uppy/drop-target | 3.0.0-beta.5 | @uppy/utils | 6.0.0-beta.8 | | @uppy/dropbox | 4.0.0-beta.7 | @uppy/webcam | 4.0.0-beta.8 | | @uppy/facebook | 4.0.0-beta.6 | @uppy/xhr-upload | 4.0.0-beta.6 | | @uppy/form | 4.0.0-beta.4 | @uppy/zoom | 3.0.0-beta.6 | | @uppy/golden-retriever | 4.0.0-beta.5 | uppy | 4.0.0-beta.10 | | @uppy/google-drive | 4.0.0-beta.6 | | | - @uppy/audio: remove unused component props (Antoine du Hamel / #5209) - @uppy/angular: fix invalid char in `package.json` (Antoine du Hamel / #5224) - meta: use default argument value instead of `defaultProps` (Antoine du Hamel / #5222) - @uppy/angular: upgrade to Angular 18 (Antoine du Hamel / #5215) - @uppy/utils: remove unused `settle` (Antoine du Hamel / #5210) - @uppy/form: move internal property to private field (Antoine du Hamel / #5214) - @uppy/dashboard: remove unused component props (Antoine du Hamel / #5213) - @uppy/status-bar: remove unused component props (Antoine du Hamel / #5211) - @uppy/audio: move internal property to private field (Antoine du Hamel / #5207) - @uppy/aws-s3: remove todo (Mikael Finstad / #5200) - @uppy/core: remove unnecessary todo (Mikael Finstad / #5200) - @uppy/aws-s3: do not expose internal `assertHost` method (Mikael Finstad / #5200) - @uppy/aws-s3: make passing `signal` consistent (Mikael Finstad / #5200) - @uppy/core: remove `'upload-started'` event (Mikael Finstad / #5200) - @uppy/aws-s3: remove `chunkState` getter (Mikael Finstad / #5200) - @uppy/drop-target: remove `title` property (Mikael Finstad / #5200) - @uppy/golden-retriever: remove unused `ready` setters (Mikael Finstad / #5200) - @uppy/dashboard: remove deprecated `autoOpenFileEditor` option (Mikael Finstad / #5200) - @uppy/aws-s3: remove `uploaderSockets` (Mikael Finstad / #5200) - @uppy/locales: remove hacks for legacy bundle (Mikael Finstad / #5200) - @uppy/status-bar: rename `StatusBar` to `StatusBarUI` (Mikael Finstad / #5200) - @uppy/url: remove unused error handler (Mikael Finstad / #5200) - @uppy/aws-s3,@uppy/tus,@uppy/utils,@uppy/xhr-upload: remove `uploader` from `upload-progress` event (Mikael Finstad / #5200) - @uppy/webcam: remove `facingMode` option (Mikael Finstad / #5200) - @uppy/companion: invert some internal boolean options (Mikael Finstad / #5198) - @uppy/companion: rename `authProvider` to `oauthProvider` (Mikael Finstad / #5198) - @uppy/companion: remove unused headers (Mikael Finstad / #5198) - @uppy/companion: remove sanitizing of metadata (Mikael Finstad / #5198) - @uppy/companion-client: do not allow boolean `RequestOptions` (Mikael Finstad / #5198) - @uppy/companion-client: remove deprecated options (Mikael Finstad / #5198) - @uppy/companion: remove `error.extraData` (Mikael Finstad / #5198) - @uppy/companion-client: make `supportsRefreshToken` default (Mikael Finstad / #5198) - @uppy/companion-client: remove optional chaining (Mikael Finstad / #5198) - @uppy/companion: capitalize POST (Mikael Finstad / #5198) - @uppy/companion: simplify code by using modern Node.js APIs (Mikael Finstad / #5198) - @uppy/companion-client: remove `Socket` (Mikael Finstad / #5198) - @uppy/companion: rename `getExtraConfig` to `getExtraGrantConfig` (Mikael Finstad / #5198) - @uppy/companion: change `COMPANION_ENABLE_URL_ENDPOINT` default (Mikael Finstad / #5198) - @uppy/companion: change default value for Redis session prefix (Mikael Finstad / #5198) - examples: make React example up-to-date (Merlijn Vos / #5205) - @uppy/core: add type tests (Merlijn Vos / #5153) - @uppy/provider-views: PartialTree - get rid of `.onFirstRender()` (Evgenia Karunus / #5187) - @uppy/core: pass file to events consistently (Merlijn Vos / #5136) - docs: assume tree-shaking bundler is the most common case (Antoine du Hamel / #5160) - @uppy/core: remove `reason` (Antoine du Hamel / #5159) - @uppy/core: remove `resetProgress` and `reset-progress` (Mikael Finstad / #5221)
from todos in codebase
probably best reviewed commit by commit