@scaleflex/widget-companion-client 4.8.4 → 4.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7057 -7040
- package/LICENSE +21 -21
- package/README.md +33 -33
- package/package.json +3 -3
- package/types/index.d.ts +65 -65
- package/lib/AuthError.js +0 -31
- package/lib/Provider.js +0 -117
- package/lib/RequestClient.js +0 -271
- package/lib/SearchProvider.js +0 -46
- package/lib/Socket.js +0 -102
- package/lib/index.js +0 -16
- package/lib/tokenStorage.js +0 -21
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2019 scaleflex
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 scaleflex
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
# @scaleflex/widget-companion-client
|
|
2
|
-
|
|
3
|
-
[![Plugins][plugins-image]](#plugins)
|
|
4
|
-
[![Website][filerobot-image]][sfx-url]
|
|
5
|
-
[![Version][filerobot-version]][version-url]
|
|
6
|
-
[![Scaleflex team][made-by-image]][sfx-url]
|
|
7
|
-
[![License][license-image]][license-url]
|
|
8
|
-
[![CodeSandbox][codeSandbox-image]][codeSandbox-url]
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<div align='center'>
|
|
12
|
-
<img title="Scaleflex Widget logo" alt="Scaleflex Widget logo" src="https://assets.scaleflex.com/Corporate+Branding/%5B2025%5D+ALL+LOGOS+%2B+ICONS/SCALEFLEX/VXP+logo/Horizontal+White/VXP+logo+WHITE.png?vh=663932" width="140"/>
|
|
13
|
-
</div>
|
|
14
|
-
|
|
15
|
-
The package used internally in [Scaleflex Media Asset Widget](https://www.npmjs.com/package/@scaleflex/widget-core) while communicating with companion of backend for handling 3rd parties uploading.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<!-- Variables -->
|
|
19
|
-
|
|
20
|
-
[npm-url]: https://www.npmjs.com/package/@scaleflex/widget-companion-client
|
|
21
|
-
[license-url]: https://opensource.org/licenses/MIT
|
|
22
|
-
[sfx-url]: https://www.scaleflex.com/
|
|
23
|
-
[version-url]: https://www.npmjs.com/package/@scaleflex/widget-companion-client
|
|
24
|
-
[codeSandbox-url]: https://codesandbox.io/p/sandbox/scalelfex-widget-v4-sandbox-dtp6l3?file=%2Fsrc%2Findex.js
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
[npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
|
|
28
|
-
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
|
|
29
|
-
[made-by-image]: https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg?style=for-the-badge
|
|
30
|
-
[plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
|
|
31
|
-
[filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
|
|
32
|
-
[filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-companion-client?label=Version&style=for-the-badge&logo=npm
|
|
33
|
-
[codeSandbox-image]: https://img.shields.io/badge/CodeSandbox-black?style=for-the-badge&logo=CodeSandbox
|
|
1
|
+
# @scaleflex/widget-companion-client
|
|
2
|
+
|
|
3
|
+
[![Plugins][plugins-image]](#plugins)
|
|
4
|
+
[![Website][filerobot-image]][sfx-url]
|
|
5
|
+
[![Version][filerobot-version]][version-url]
|
|
6
|
+
[![Scaleflex team][made-by-image]][sfx-url]
|
|
7
|
+
[![License][license-image]][license-url]
|
|
8
|
+
[![CodeSandbox][codeSandbox-image]][codeSandbox-url]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
<div align='center'>
|
|
12
|
+
<img title="Scaleflex Widget logo" alt="Scaleflex Widget logo" src="https://assets.scaleflex.com/Corporate+Branding/%5B2025%5D+ALL+LOGOS+%2B+ICONS/SCALEFLEX/VXP+logo/Horizontal+White/VXP+logo+WHITE.png?vh=663932" width="140"/>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
The package used internally in [Scaleflex Media Asset Widget](https://www.npmjs.com/package/@scaleflex/widget-core) while communicating with companion of backend for handling 3rd parties uploading.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
<!-- Variables -->
|
|
19
|
+
|
|
20
|
+
[npm-url]: https://www.npmjs.com/package/@scaleflex/widget-companion-client
|
|
21
|
+
[license-url]: https://opensource.org/licenses/MIT
|
|
22
|
+
[sfx-url]: https://www.scaleflex.com/
|
|
23
|
+
[version-url]: https://www.npmjs.com/package/@scaleflex/widget-companion-client
|
|
24
|
+
[codeSandbox-url]: https://codesandbox.io/p/sandbox/scalelfex-widget-v4-sandbox-dtp6l3?file=%2Fsrc%2Findex.js
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
[npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
|
|
28
|
+
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
|
|
29
|
+
[made-by-image]: https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg?style=for-the-badge
|
|
30
|
+
[plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
|
|
31
|
+
[filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
|
|
32
|
+
[filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-companion-client?label=Version&style=for-the-badge&logo=npm
|
|
33
|
+
[codeSandbox-image]: https://img.shields.io/badge/CodeSandbox-black?style=for-the-badge&logo=CodeSandbox
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/widget-companion-client",
|
|
3
3
|
"description": "Client library for communication with Companion. Intended for use in Scaleflex plugins.",
|
|
4
|
-
"version": "4.8.
|
|
4
|
+
"version": "4.8.6",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "types/index.d.ts",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@scaleflex/widget-utils": "^4.8.
|
|
17
|
+
"@scaleflex/widget-utils": "^4.8.6",
|
|
18
18
|
"namespace-emitter": "^2.0.1"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "cbb232cc92583c3888556df91ff90b4654e64790"
|
|
21
21
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Async storage interface, similar to `localStorage`. This can be used to
|
|
3
|
-
* implement custom storages for authentication tokens.
|
|
4
|
-
*/
|
|
5
|
-
export interface TokenStorage {
|
|
6
|
-
setItem: (key: string, value: string) => Promise<void>
|
|
7
|
-
getItem: (key: string) => Promise<string>
|
|
8
|
-
removeItem: (key: string) => Promise<void>
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface RequestClientOptions {
|
|
12
|
-
companionUrl: string
|
|
13
|
-
companionHeaders?: object
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class RequestClient {
|
|
17
|
-
constructor (filerobot: any, opts: RequestClientOptions)
|
|
18
|
-
get (path: string): Promise<any>
|
|
19
|
-
post (path: string, data: object): Promise<any>
|
|
20
|
-
delete (path: string, data: object): Promise<any>
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Options for Providers that can be passed in by Filerobot users through
|
|
25
|
-
* Plugin constructors.
|
|
26
|
-
*/
|
|
27
|
-
export interface PublicProviderOptions extends RequestClientOptions {
|
|
28
|
-
companionAllowedHosts?: string | RegExp | Array<string | RegExp>
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Options for Providers, including internal options that Plugins can set.
|
|
33
|
-
*/
|
|
34
|
-
export interface ProviderOptions extends PublicProviderOptions {
|
|
35
|
-
provider: string
|
|
36
|
-
name?: string
|
|
37
|
-
pluginId: string
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export class Provider extends RequestClient {
|
|
41
|
-
constructor (filerobot: any, opts: ProviderOptions)
|
|
42
|
-
checkAuth (): Promise<boolean>
|
|
43
|
-
authUrl (): string
|
|
44
|
-
fileUrl (id: string): string
|
|
45
|
-
list (directory: string): Promise<any>
|
|
46
|
-
logout (redirect?: string): Promise<any>
|
|
47
|
-
static initPlugin (plugin: any, opts: object, defaultOpts?: object): void
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface SocketOptions {
|
|
51
|
-
target: string
|
|
52
|
-
autoOpen?: boolean
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export class Socket {
|
|
56
|
-
isOpen: boolean
|
|
57
|
-
|
|
58
|
-
constructor (opts: SocketOptions)
|
|
59
|
-
open (): void
|
|
60
|
-
close (): void
|
|
61
|
-
send (action: string, payload: any): void
|
|
62
|
-
on (action: string, handler: (param: any) => void): void
|
|
63
|
-
once (action: string, handler: (param: any) => void): void
|
|
64
|
-
emit (action: string, payload: (param: any) => void): void
|
|
65
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Async storage interface, similar to `localStorage`. This can be used to
|
|
3
|
+
* implement custom storages for authentication tokens.
|
|
4
|
+
*/
|
|
5
|
+
export interface TokenStorage {
|
|
6
|
+
setItem: (key: string, value: string) => Promise<void>
|
|
7
|
+
getItem: (key: string) => Promise<string>
|
|
8
|
+
removeItem: (key: string) => Promise<void>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface RequestClientOptions {
|
|
12
|
+
companionUrl: string
|
|
13
|
+
companionHeaders?: object
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class RequestClient {
|
|
17
|
+
constructor (filerobot: any, opts: RequestClientOptions)
|
|
18
|
+
get (path: string): Promise<any>
|
|
19
|
+
post (path: string, data: object): Promise<any>
|
|
20
|
+
delete (path: string, data: object): Promise<any>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Options for Providers that can be passed in by Filerobot users through
|
|
25
|
+
* Plugin constructors.
|
|
26
|
+
*/
|
|
27
|
+
export interface PublicProviderOptions extends RequestClientOptions {
|
|
28
|
+
companionAllowedHosts?: string | RegExp | Array<string | RegExp>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Options for Providers, including internal options that Plugins can set.
|
|
33
|
+
*/
|
|
34
|
+
export interface ProviderOptions extends PublicProviderOptions {
|
|
35
|
+
provider: string
|
|
36
|
+
name?: string
|
|
37
|
+
pluginId: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export class Provider extends RequestClient {
|
|
41
|
+
constructor (filerobot: any, opts: ProviderOptions)
|
|
42
|
+
checkAuth (): Promise<boolean>
|
|
43
|
+
authUrl (): string
|
|
44
|
+
fileUrl (id: string): string
|
|
45
|
+
list (directory: string): Promise<any>
|
|
46
|
+
logout (redirect?: string): Promise<any>
|
|
47
|
+
static initPlugin (plugin: any, opts: object, defaultOpts?: object): void
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface SocketOptions {
|
|
51
|
+
target: string
|
|
52
|
+
autoOpen?: boolean
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export class Socket {
|
|
56
|
+
isOpen: boolean
|
|
57
|
+
|
|
58
|
+
constructor (opts: SocketOptions)
|
|
59
|
+
open (): void
|
|
60
|
+
close (): void
|
|
61
|
+
send (action: string, payload: any): void
|
|
62
|
+
on (action: string, handler: (param: any) => void): void
|
|
63
|
+
once (action: string, handler: (param: any) => void): void
|
|
64
|
+
emit (action: string, payload: (param: any) => void): void
|
|
65
|
+
}
|
package/lib/AuthError.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
5
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
7
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
9
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
10
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
11
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
12
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
13
|
-
function _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); }
|
|
14
|
-
function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
|
|
15
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
16
|
-
function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } }
|
|
17
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
18
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
19
|
-
var AuthError = /*#__PURE__*/function (_Error) {
|
|
20
|
-
function AuthError() {
|
|
21
|
-
var _this;
|
|
22
|
-
_classCallCheck(this, AuthError);
|
|
23
|
-
_this = _callSuper(this, AuthError, ['Authorization required']);
|
|
24
|
-
_this.name = 'AuthError';
|
|
25
|
-
_this.isAuthError = true;
|
|
26
|
-
return _this;
|
|
27
|
-
}
|
|
28
|
-
_inherits(AuthError, _Error);
|
|
29
|
-
return _createClass(AuthError);
|
|
30
|
-
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
31
|
-
export default AuthError;
|
package/lib/Provider.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
5
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
6
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
7
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
8
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
9
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
11
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
12
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
13
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
14
|
-
function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
|
|
15
|
-
function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }
|
|
16
|
-
function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
|
|
17
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
18
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
19
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
20
|
-
import RequestClient from './RequestClient';
|
|
21
|
-
import * as tokenStorage from './tokenStorage';
|
|
22
|
-
var _getName = function _getName(id) {
|
|
23
|
-
return id.split('-').map(function (s) {
|
|
24
|
-
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
25
|
-
}).join(' ');
|
|
26
|
-
};
|
|
27
|
-
var Provider = /*#__PURE__*/function (_RequestClient) {
|
|
28
|
-
function Provider(filerobot) {
|
|
29
|
-
var _this;
|
|
30
|
-
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
31
|
-
_classCallCheck(this, Provider);
|
|
32
|
-
_this = _callSuper(this, Provider, [filerobot, opts]);
|
|
33
|
-
_this.provider = opts.provider;
|
|
34
|
-
_this.id = _this.provider;
|
|
35
|
-
_this.name = _this.opts.name || _getName(_this.id);
|
|
36
|
-
_this.pluginId = _this.opts.pluginId;
|
|
37
|
-
_this.tokenKey = "companion-".concat(_this.pluginId, "-auth-token");
|
|
38
|
-
return _this;
|
|
39
|
-
}
|
|
40
|
-
_inherits(Provider, _RequestClient);
|
|
41
|
-
return _createClass(Provider, [{
|
|
42
|
-
key: "headers",
|
|
43
|
-
value: function headers() {
|
|
44
|
-
var _this2 = this;
|
|
45
|
-
return new Promise(function (resolve, reject) {
|
|
46
|
-
_superPropGet(Provider, "headers", _this2, 3)([]).then(function (headers) {
|
|
47
|
-
_this2.getAuthToken().then(function (token) {
|
|
48
|
-
// TODO: change uppy-auth-token & all uppyTokens to filerobot-auth-token & filerobotTokens when BE do it.
|
|
49
|
-
resolve(_extends({}, headers, {
|
|
50
|
-
'uppy-auth-token': token
|
|
51
|
-
}));
|
|
52
|
-
});
|
|
53
|
-
})["catch"](reject);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}, {
|
|
57
|
-
key: "onReceiveResponse",
|
|
58
|
-
value: function onReceiveResponse(response) {
|
|
59
|
-
response = _superPropGet(Provider, "onReceiveResponse", this, 3)([response]);
|
|
60
|
-
var plugin = this.filerobot.getPlugin(this.pluginId);
|
|
61
|
-
var oldAuthenticated = plugin.getPluginCommonState().authenticated;
|
|
62
|
-
var authenticated = oldAuthenticated ? response.status !== 401 : response.status < 400;
|
|
63
|
-
plugin.setPluginCommonState({
|
|
64
|
-
authenticated: authenticated
|
|
65
|
-
});
|
|
66
|
-
return response;
|
|
67
|
-
}
|
|
68
|
-
}, {
|
|
69
|
-
key: "setAuthToken",
|
|
70
|
-
value: function setAuthToken(token) {
|
|
71
|
-
return this.filerobot.getPlugin(this.pluginId).storage.setItem(this.tokenKey, token);
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
key: "getAuthToken",
|
|
75
|
-
value: function getAuthToken() {
|
|
76
|
-
return this.filerobot.getPlugin(this.pluginId).storage.getItem(this.tokenKey);
|
|
77
|
-
}
|
|
78
|
-
}, {
|
|
79
|
-
key: "authUrl",
|
|
80
|
-
value: function authUrl() {
|
|
81
|
-
return "".concat(this.hostname, "/").concat(this.id, "/connect");
|
|
82
|
-
}
|
|
83
|
-
}, {
|
|
84
|
-
key: "fileUrl",
|
|
85
|
-
value: function fileUrl(id) {
|
|
86
|
-
return "".concat(this.hostname, "/").concat(this.id, "/get/").concat(id);
|
|
87
|
-
}
|
|
88
|
-
}, {
|
|
89
|
-
key: "list",
|
|
90
|
-
value: function list(directory) {
|
|
91
|
-
return this.get("".concat(this.id, "/list/").concat(directory || ''));
|
|
92
|
-
}
|
|
93
|
-
}, {
|
|
94
|
-
key: "logout",
|
|
95
|
-
value: function logout() {
|
|
96
|
-
var _this3 = this;
|
|
97
|
-
return new Promise(function (resolve, reject) {
|
|
98
|
-
_this3.get("".concat(_this3.id, "/logout")).then(function (res) {
|
|
99
|
-
_this3.filerobot.getPlugin(_this3.pluginId).storage.removeItem(_this3.tokenKey).then(function () {
|
|
100
|
-
return resolve(res);
|
|
101
|
-
})["catch"](reject);
|
|
102
|
-
})["catch"](reject);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}], [{
|
|
106
|
-
key: "initPlugin",
|
|
107
|
-
value: function initPlugin(plugin, opts, defaultOpts) {
|
|
108
|
-
plugin.type = 'acquirer';
|
|
109
|
-
plugin.files = [];
|
|
110
|
-
if (defaultOpts) {
|
|
111
|
-
plugin.opts = _extends({}, defaultOpts, opts);
|
|
112
|
-
}
|
|
113
|
-
plugin.storage = plugin.opts.storage || tokenStorage;
|
|
114
|
-
}
|
|
115
|
-
}]);
|
|
116
|
-
}(RequestClient);
|
|
117
|
-
export default Provider;
|