Socket
Socket
Sign inDemoInstall

mediapicker

Package Overview
Dependencies
2
Maintainers
9
Versions
100
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 11.1.7 to 11.1.8

jest.config.json

4

CHANGELOG.md
## MediaPicker
#### 11.1.8 (2017-11-16)
* **patch:**
* Fix ASAP support for all local media pickers (binary, browse, etc)
#### 11.1.7 (2017-11-15)

@@ -4,0 +8,0 @@ * **patch:**

@@ -11,2 +11,3 @@ const getPrintedValue = function (parameter) {

$('#currentCollection').text(getPrintedValue(uploadParams.collection));
$('#currentAuthMethod').text(getPrintedValue(uploadParams.authMethod));
$('#currentFetchMetadata').text(getPrintedValue(uploadParams.fetchMetadata));

@@ -18,2 +19,3 @@ $('#currentAutoFinalize').text(getPrintedValue(uploadParams.autoFinalize));

$('#newCollection').val(uploadParams.collection);
$('#newAuthMethod').val(uploadParams.authMethod);
$('#newFetchMetadata').attr('checked', !!uploadParams.fetchMetadata);

@@ -26,2 +28,3 @@ $('#newAutoFinalize').attr('checked', !!uploadParams.autoFinalize);

collection: $('#newCollection').val(),
authMethod: $('#newAuthMethod').val(),
fetchMetadata: $('#newFetchMetadata').prop('checked'),

@@ -32,3 +35,3 @@ autoFinalize: $('#newAutoFinalize').prop('checked')

const addUploadParametersUI = function (container, initialUploadParams, collections, updater) {
const addUploadParametersUI = function (container, initialUploadParams, collections, updater, authMethods) {
$(container)

@@ -56,2 +59,14 @@ .html(

'<tr>' +
'<td class="paramHeader">Auth Method</td>' +
'<td>' +
'<span id="currentAuthMethod">' +
'</span>' +
'</td>' +
'<td>' +
'<select id="newAuthMethod">' +
'</select>' +
'</td>' +
'</tr>' +
'<tr>' +
'<td class="paramHeader">Fetch metadata</td>' +

@@ -96,2 +111,6 @@ '<td>' +

authMethods.forEach(function (item) {
$('#newAuthMethod').append($('<option>', { value: item }).text(item))
});
updateCurrentParameters(initialUploadParams);

@@ -98,0 +117,0 @@ updateNewParameters(initialUploadParams);

1

lib/types/src/service/mediaClient.d.ts
import { Auth, AuthProvider } from '@atlaskit/media-core';
export declare type TokenProvider = () => Promise<string>;
export interface MediaApiError {

@@ -4,0 +3,0 @@ error: {

{
"name": "mediapicker",
"version": "11.1.7",
"version": "11.1.8",
"description": "Library for handling file uploads",

@@ -5,0 +5,0 @@ "main": "./lib/mediapicker.js",

@@ -6,4 +6,2 @@ import { AxiosRequestConfig, default as axios } from 'axios';

export type TokenProvider = () => Promise<string>;
export interface MediaApiError {

@@ -10,0 +8,0 @@ error: {

import { UploadParams } from '../../popup/src/domain';
import { ResumableFile, ResumableChunk } from 'resumablejs';
import * as Resumable from 'resumablejs';
import { Hasher } from './hashing/hasher';

@@ -11,2 +10,3 @@ import * as hasherCreatorModule from './hashing/hasherCreator';

let hasherHashSpy: jest.SpyInstance<Hasher['hash']>;
createHasherSpy.mockImplementation(() => {

@@ -19,13 +19,22 @@ const hasher = createHasher();

import { UploadService } from './uploadService';
import { AuthProvider } from '@atlaskit/media-core';
import ResumableFile = Resumable.ResumableFile;
import ResumableChunk = Resumable.ResumableChunk;
describe('UploadService', () => {
const apiUrl = 'some-api-url';
const clientId = 'come-client-id';
const clientId = 'some-client-id';
const asapIssuer = 'some-asap-issuer';
const token = 'some-token';
const collection = 'some-collection';
const authProvider = () => Promise.resolve({ clientId, token });
const clientBasedAuthProvider = () => Promise.resolve({ clientId, token });
const issuerBasedAuthProvider = () => Promise.resolve({ asapIssuer, token });
beforeEach(() => {
hasherHashSpy.mockReset();
});
describe('setUploadParams', () => {
const setup = () => ({
uploadService: new UploadService(apiUrl, authProvider, {})
uploadService: new UploadService(apiUrl, clientBasedAuthProvider, {})
});

@@ -64,3 +73,3 @@

const setup = () => {
const uploadService = new UploadService(apiUrl, authProvider, {});
const uploadService = new UploadService(apiUrl, clientBasedAuthProvider, {});
const resumable = uploadService['resumable'];

@@ -168,3 +177,3 @@ const element = document.createElement('div');

const setup = () => {
const uploadService = new UploadService(apiUrl, authProvider, {});
const uploadService = new UploadService(apiUrl, clientBasedAuthProvider, {});
const resumable = uploadService['resumable'];

@@ -220,5 +229,73 @@ const resumableFile = {

const setupForSpy = (authProvider: AuthProvider): Promise<Resumable> => {
const uploadService = new UploadService(apiUrl, authProvider, {});
const resumable: Resumable = uploadService['resumable'];
const file = new File([new Blob()], 'filename');
uploadService.addFile(file);
resumable.upload();
return new Promise(resolve => {
resumable.on('uploadStart', () => resolve(resumable));
});
};
describe('query', () => {
it('should have client based auth parameters', () =>
setupForSpy(clientBasedAuthProvider).then((resumable: Resumable) => {
const queryResult = (resumable.opts.query as any)(
resumable.files[0],
resumable.files[0].chunks[0]
);
expect(queryResult).toEqual(
expect.objectContaining({
client: clientId,
token
})
);
}));
it('should have issuer based auth parameters', () =>
setupForSpy(issuerBasedAuthProvider).then((resumable: Resumable) => {
const queryResult = (resumable.opts.query as any)(
resumable.files[0],
resumable.files[0].chunks[0]
);
expect(queryResult).toEqual(
expect.objectContaining({
issuer: asapIssuer,
token
})
);
}));
});
describe('target', () => {
it('should have client based auth parameters', () =>
setupForSpy(clientBasedAuthProvider).then((resumable: Resumable) => {
const rawParams: Array<string> = [
`client=${clientId}`,
`token=${token}`,
'hash=some_hash',
'resumableCurrentChunkSize=10'
];
const url: string = (resumable.opts.target as any)(rawParams);
expect(url).toEqual(`${apiUrl}/chunk/some_hash-10?client=${clientId}&token=${token}`);
}));
it('should have issuer based auth parameters', () =>
setupForSpy(issuerBasedAuthProvider).then((resumable: Resumable) => {
const rawParams: Array<string> = [
`issuer=${asapIssuer}`,
`token=${token}`,
'hash=some_hash',
'resumableCurrentChunkSize=10'
];
const url: string = (resumable.opts.target as any)(rawParams);
expect(url).toEqual(`${apiUrl}/chunk/some_hash-10?issuer=${asapIssuer}&token=${token}`);
}));
});
describe('add', () => {
const setup = () => {
const uploadService = new UploadService(apiUrl, authProvider, {});
const uploadService = new UploadService(apiUrl, clientBasedAuthProvider, {});
const resumable = uploadService['resumable'];

@@ -249,3 +326,7 @@ return { uploadService, resumable };

const setup = (config: { uploadParams?: UploadParams; progress?: number } = {}) => {
const uploadService = new UploadService(apiUrl, authProvider, config.uploadParams || {});
const uploadService = new UploadService(
apiUrl,
clientBasedAuthProvider,
config.uploadParams || {}
);
const resumable = uploadService['resumable'];

@@ -252,0 +333,0 @@ const emitter = uploadService['emitter'];

@@ -5,3 +5,3 @@ import * as Resumable from 'resumablejs';

import { ResumableFile, ResumableChunk } from 'resumablejs';
import { AuthProvider, isClientBasedAuth } from '@atlaskit/media-core';
import { AuthProvider } from '@atlaskit/media-core';

@@ -236,10 +236,6 @@ import { handleError } from '../util/handleError';

if (storedAuth) {
if (isClientBasedAuth(storedAuth)) {
return {
hash: (chunk as any).hash,
...mapAuthToQueryParameters(storedAuth)
};
} else {
throw new Error('ASAP based authentication not yet implemented');
}
return {
hash: (chunk as any).hash,
...mapAuthToQueryParameters(storedAuth)
};
} else {

@@ -259,4 +255,9 @@ throw new Error('auth required');

const { hash, resumableCurrentChunkSize, client, token } = params;
const authQueryParameters = `client=${client}&token=${token}`;
const { hash, resumableCurrentChunkSize, client, issuer, token } = params;
let authQueryParameters;
if (issuer) {
authQueryParameters = `issuer=${issuer}&token=${token}`;
} else {
authQueryParameters = `client=${client}&token=${token}`;
}

@@ -263,0 +264,0 @@ return `${this.uploadChunkUrl}/${hash}-${resumableCurrentChunkSize}?${authQueryParameters}`;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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

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

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

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

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

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

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

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

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

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

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

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc