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

@uppy/companion-client

Package Overview
Dependencies
Maintainers
8
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 2.0.4 to 2.0.5

CHANGELOG.md

36

lib/Provider.js

@@ -62,3 +62,18 @@ 'use strict';

}
/**
* Ensure we have a preauth token if necessary. Attempts to fetch one if we don't,
* or rejects if loading one fails.
*/
async ensurePreAuth() {
if (this.companionKeysParams && !this.preAuthToken) {
await this.fetchPreAuthToken();
if (!this.preAuthToken) {
throw new Error('Could not load authentication data required for third-party login. Please try again later.');
}
}
}
authUrl(queries) {

@@ -69,7 +84,9 @@ if (queries === void 0) {

const params = new URLSearchParams(queries);
if (this.preAuthToken) {
queries.uppyPreAuthToken = this.preAuthToken;
params.set('uppyPreAuthToken', this.preAuthToken);
}
return `${this.hostname}/${this.id}/connect?${new URLSearchParams(queries)}`;
return `${this.hostname}/${this.id}/connect?${params}`;
}

@@ -81,14 +98,15 @@

fetchPreAuthToken() {
async fetchPreAuthToken() {
if (!this.companionKeysParams) {
return Promise.resolve();
return;
}
return this.post(`${this.id}/preauth/`, {
params: this.companionKeysParams
}).then(res => {
try {
const res = await this.post(`${this.id}/preauth/`, {
params: this.companionKeysParams
});
this.preAuthToken = res.token;
}).catch(err => {
} catch (err) {
this.uppy.log(`[CompanionClient] unable to fetch preAuthToken ${err}`, 'warning');
});
}
}

@@ -95,0 +113,0 @@

@@ -161,3 +161,3 @@ 'use strict';

}), _class.VERSION = "2.0.4", _class.defaultHeaders = {
}), _class.VERSION = "2.0.5", _class.defaultHeaders = {
Accept: 'application/json',

@@ -164,0 +164,0 @@ 'Content-Type': 'application/json',

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

"use strict";
var _queued, _emitter, _isOpen, _socket, _handleMessage;

@@ -4,0 +2,0 @@

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

@@ -24,5 +24,5 @@ "main": "lib/index.js",

"dependencies": {
"@uppy/utils": "^4.0.4",
"@uppy/utils": "^4.0.5",
"namespace-emitter": "^2.0.1"
}
}

@@ -56,8 +56,23 @@ 'use strict'

/**
* Ensure we have a preauth token if necessary. Attempts to fetch one if we don't,
* or rejects if loading one fails.
*/
async ensurePreAuth () {
if (this.companionKeysParams && !this.preAuthToken) {
await this.fetchPreAuthToken()
if (!this.preAuthToken) {
throw new Error('Could not load authentication data required for third-party login. Please try again later.')
}
}
}
authUrl (queries = {}) {
const params = new URLSearchParams(queries)
if (this.preAuthToken) {
queries.uppyPreAuthToken = this.preAuthToken
params.set('uppyPreAuthToken', this.preAuthToken)
}
return `${this.hostname}/${this.id}/connect?${new URLSearchParams(queries)}`
return `${this.hostname}/${this.id}/connect?${params}`
}

@@ -69,13 +84,13 @@

fetchPreAuthToken () {
async fetchPreAuthToken () {
if (!this.companionKeysParams) {
return Promise.resolve()
return
}
return this.post(`${this.id}/preauth/`, { params: this.companionKeysParams })
.then((res) => {
this.preAuthToken = res.token
}).catch((err) => {
this.uppy.log(`[CompanionClient] unable to fetch preAuthToken ${err}`, 'warning')
})
try {
const res = await this.post(`${this.id}/preauth/`, { params: this.companionKeysParams })
this.preAuthToken = res.token
} catch (err) {
this.uppy.log(`[CompanionClient] unable to fetch preAuthToken ${err}`, 'warning')
}
}

@@ -82,0 +97,0 @@

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