@pageproof/sdk-pr 508.0.1701119996021 → 509.0.1700833745934

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.0-beta.313
4
+
5
+ Released on the 15th of November 2023.
6
+
7
+ - Bug fixes.
8
+
9
+ ## 2.0.0-beta.312
10
+
11
+ Released on the 9th of November 2023.
12
+
13
+ - Added experimental support for the "Uint8Array" Bluffer driver (which is well-suited for unsupported JavaScript runtimes).
14
+
3
15
  ## 2.0.0-beta.311
4
16
 
5
17
  Released on the 20th of October 2023.
package/README.md CHANGED
@@ -246,6 +246,10 @@ supported drivers are:
246
246
  And there is one more driver which is made available if you're running in an unknown/unsupported environment: "String".
247
247
  This driver uses JS strings to construct the home for large binary objects, but be warned, it is not optimised.
248
248
 
249
+ You can optionally enable the experimental "Uint8Array" driver, which, as the name suggests, uses the `Uint8Array` class
250
+ to construct the home for large binary objects. This driver is more suited for environments that aren't the typical web
251
+ browser or Node.js runtime.
252
+
249
253
  #### Custom Drivers
250
254
 
251
255
  If you need to implement your own custom Bluffer driver, you can set `Bluffer.driver` to a constructor Function. We do
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};var _superagent=require("superagent");var _superagent2=_interopRequireDefault(_superagent);var _superagentProxy=require("superagent-proxy");var _superagentProxy2=_interopRequireDefault(_superagentProxy);var _systemProxyUrl=require("system-proxy-url");var _IRequestAdapter2=require("./IRequestAdapter");var _IRequestAdapter3=_interopRequireDefault(_IRequestAdapter2);var _sleep=require("../util/sleep");var _sleep2=_interopRequireDefault(_sleep);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}(0,_superagentProxy2.default)(_superagent2.default);var debug=require("debug")("NodeRequestAdapter");var defaultOptions={proxy:true};var cachedAutoProxyUrls={};function getAutoProxyUrl(host){if(!cachedAutoProxyUrls[host]){cachedAutoProxyUrls[host]=(0,_systemProxyUrl.getProxyUrlSync)(host)}return cachedAutoProxyUrls[host]}var NodeRequestAdapter=function(_IRequestAdapter){_inherits(NodeRequestAdapter,_IRequestAdapter);function NodeRequestAdapter(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,NodeRequestAdapter);var _this=_possibleConstructorReturn(this,_IRequestAdapter.call(this));_this.options=_extends({},defaultOptions,options);return _this}NodeRequestAdapter.prototype.send=function send(request){var _this2=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var state=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{attempt:1};debug(request.method+" "+request.path+" (attempt: "+state.attempt+")");return new Promise(function(resolve,reject){var requestUrl=request.host+request.path+request.query;var proxyUrl=null;if(typeof _this2.options.proxy==="string"){proxyUrl=_this2.options.proxy}else if(_this2.options.proxy===true){proxyUrl=getAutoProxyUrl(request.host)}var method=request.method.toLowerCase();var headers=_extends({},request.headers);var chain=_superagent2.default[method](requestUrl).set(headers).send(request.body);if(proxyUrl){chain=chain.proxy(proxyUrl)}var body=void 0;chain.on("progress",function(event){if(event.total){var callback=event.direction==="download"?"onDownloadProgress":"onUploadProgress";if(callback in options){options[callback](event.progress)}}}).buffer(true).parse(function(response,cb){if(options.bluffer){var data=[];response.on("data",function(chunk){data.push(chunk)});response.on("end",function(){body=Buffer.concat(data);cb(null,response)})}else{response.setEncoding("utf-8");var _data="";response.on("data",function(chunk){_data+=chunk});response.on("end",function(){body=_data;cb(null,response)})}response.on("error",cb)}).end(function(err,response){if(err&&!response){if(err.errno&&method==="get"&&state.attempt<=5){state.attempt++;debug(request.method+" "+request.path+" failed with errno "+err.errno+", retrying");resolve((0,_sleep2.default)(1e3*state.attempt).then(function(){return _this2.send(request,options,state)}))}else{reject(err)}}else{debug(request.method+" "+request.path+" ("+response.statusCode+")");resolve({status:response.statusCode,headers:response.headers,body:body})}})})};return NodeRequestAdapter}(_IRequestAdapter3.default);exports.default=NodeRequestAdapter;
1
+ "use strict";exports.__esModule=true;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};var _superagent=require("superagent");var _superagent2=_interopRequireDefault(_superagent);var _superagentProxy=require("superagent-proxy");var _superagentProxy2=_interopRequireDefault(_superagentProxy);var _systemProxyUrl=require("system-proxy-url");var _IRequestAdapter2=require("./IRequestAdapter");var _IRequestAdapter3=_interopRequireDefault(_IRequestAdapter2);var _sleep=require("../util/sleep");var _sleep2=_interopRequireDefault(_sleep);var _objectToString=require("../util/objectToString");var _objectToString2=_interopRequireDefault(_objectToString);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}(0,_superagentProxy2.default)(_superagent2.default);var debug=require("debug")("NodeRequestAdapter");var defaultOptions={proxy:true};var cachedAutoProxyUrls={};function getAutoProxyUrl(host){if(!cachedAutoProxyUrls[host]){cachedAutoProxyUrls[host]=(0,_systemProxyUrl.getProxyUrlSync)(host)}return cachedAutoProxyUrls[host]}var NodeRequestAdapter=function(_IRequestAdapter){_inherits(NodeRequestAdapter,_IRequestAdapter);function NodeRequestAdapter(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,NodeRequestAdapter);var _this=_possibleConstructorReturn(this,_IRequestAdapter.call(this));_this.options=_extends({},defaultOptions,options);return _this}NodeRequestAdapter.prototype.send=function send(request){var _this2=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var state=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{attempt:1};debug(request.method+" "+request.path+" (attempt: "+state.attempt+")");return new Promise(function(resolve,reject){var requestUrl=request.host+request.path+request.query;var proxyUrl=null;if(typeof _this2.options.proxy==="string"){proxyUrl=_this2.options.proxy}else if(_this2.options.proxy===true){proxyUrl=getAutoProxyUrl(request.host)}var method=request.method.toLowerCase();var headers=_extends({},request.headers);var chain=_superagent2.default[method](requestUrl).set(headers).send((0,_objectToString2.default)(request.body)==="[object ArrayBuffer]"?Buffer.from(request.body):request.body);if(proxyUrl){chain=chain.proxy(proxyUrl)}var body=void 0;chain.on("progress",function(event){if(event.total){var callback=event.direction==="download"?"onDownloadProgress":"onUploadProgress";if(callback in options){options[callback](event.progress)}}}).buffer(true).parse(function(response,cb){if(options.bluffer){var data=[];response.on("data",function(chunk){data.push(chunk)});response.on("end",function(){body=Buffer.concat(data);cb(null,response)})}else{response.setEncoding("utf-8");var _data="";response.on("data",function(chunk){_data+=chunk});response.on("end",function(){body=_data;cb(null,response)})}response.on("error",cb)}).end(function(err,response){if(err&&!response){if(err.errno&&method==="get"&&state.attempt<=5){state.attempt++;debug(request.method+" "+request.path+" failed with errno "+err.errno+", retrying");resolve((0,_sleep2.default)(1e3*state.attempt).then(function(){return _this2.send(request,options,state)}))}else{reject(err)}}else{debug(request.method+" "+request.path+" ("+response.statusCode+")");resolve({status:response.statusCode,headers:response.headers,body:body})}})})};return NodeRequestAdapter}(_IRequestAdapter3.default);exports.default=NodeRequestAdapter;
@@ -24,6 +24,12 @@ declare class SyncCryptoAdapter extends ICryptoAdapter {
24
24
  * @returns {Promise<string>} The decrypted data
25
25
  */
26
26
  decryptData(version: number, data$: string, envelope$: string, privateKeyPEMs: string[]): Promise<string>;
27
+ /**
28
+ * @param {string} data$ The encrypted file block (and envelope)
29
+ * @param {string[]} privateKeyPEMs The user's private keys used to decrypt the embedded envelope
30
+ * @returns {Promise<string>} A base64 representation of the original block
31
+ */
32
+ decryptFileBlock(data$: string, privateKeyPEMs: string[]): Promise<string>;
27
33
  /**
28
34
  * @param {string} data$ The encrypted image (and envelope)
29
35
  * @param {string[]} privateKeyPEMs The user's private keys used to decrypt the embedded envelope
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var _ICryptoAdapter2=require("./ICryptoAdapter");var _ICryptoAdapter3=_interopRequireDefault(_ICryptoAdapter2);var _crypto=require("../crypto");var crypto=_interopRequireWildcard(_crypto);function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj.default=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var SyncCryptoAdapter=function(_ICryptoAdapter){_inherits(SyncCryptoAdapter,_ICryptoAdapter);function SyncCryptoAdapter(){_classCallCheck(this,SyncCryptoAdapter);return _possibleConstructorReturn(this,_ICryptoAdapter.apply(this,arguments))}SyncCryptoAdapter.prototype.decryptBytes=function decryptBytes(comment$,envelope$,privateKeyPEMs,before,after){return crypto.decryptBytes(comment$,envelope$,privateKeyPEMs,before,after)};SyncCryptoAdapter.prototype.decryptComment=function decryptComment(comment$,envelope,privateKeyPEMs){return crypto.decryptComment(comment$,envelope,privateKeyPEMs)};SyncCryptoAdapter.prototype.decryptData=function decryptData(version,data$,envelope$,privateKeyPEMs){return crypto.decryptData(version,data$,envelope$,privateKeyPEMs)};SyncCryptoAdapter.prototype.decryptImage=function decryptImage(data$,privateKeyPEMs){return crypto.decryptImage(data$,privateKeyPEMs)};SyncCryptoAdapter.prototype.decryptPrivateKey=function decryptPrivateKey(privateKey$,password){return crypto.decryptPrivateKey(privateKey$,password)};SyncCryptoAdapter.prototype.encryptFileBlock=function encryptFileBlock(keyIV,fileBlock,decodeBlock){return crypto.encryptFileBlock(keyIV,fileBlock,decodeBlock)};SyncCryptoAdapter.prototype.encryptPrivateKey=function encryptPrivateKey(privateKeyPEM,password){return crypto.encryptPrivateKey(privateKeyPEM,password)};SyncCryptoAdapter.prototype.envelopeSeal=function envelopeSeal(secret,publicKeyPEMs){return crypto.envelopeSeal(secret,publicKeyPEMs)};SyncCryptoAdapter.prototype.envelopeUnseal=function envelopeUnseal(envelope,privateKeyPEMs){return crypto.envelopeUnseal(envelope,privateKeyPEMs)};SyncCryptoAdapter.prototype.generateAuthorizationHeaders=function generateAuthorizationHeaders(method,path,session){return crypto.generateAuthorizationHeaders(method,path,session)};SyncCryptoAdapter.prototype.generateKeyIV=function generateKeyIV(){return crypto.generateKeyIV()};SyncCryptoAdapter.prototype.generateKeyPair=function generateKeyPair(){return crypto.generateKeyPair()};SyncCryptoAdapter.prototype.generatePasswordHash=function generatePasswordHash(password){return crypto.generatePasswordHash(password)};SyncCryptoAdapter.prototype.generateWrappedSymmetricKey=function generateWrappedSymmetricKey(serverPublicKeyPEM){return crypto.generateWrappedSymmetricKey(serverPublicKeyPEM)};SyncCryptoAdapter.prototype.decryptManagedPrivateKey=function decryptManagedPrivateKey(privateKey$,keyBase64){return crypto.decryptManagedPrivateKey(privateKey$,keyBase64)};SyncCryptoAdapter.prototype.encryptComment=function encryptComment(comment,publicKeyPEMs){return crypto.encryptComment(comment,publicKeyPEMs)};return SyncCryptoAdapter}(_ICryptoAdapter3.default);exports.default=SyncCryptoAdapter;
1
+ "use strict";exports.__esModule=true;var _ICryptoAdapter2=require("./ICryptoAdapter");var _ICryptoAdapter3=_interopRequireDefault(_ICryptoAdapter2);var _crypto=require("../crypto");var crypto=_interopRequireWildcard(_crypto);function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj.default=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var SyncCryptoAdapter=function(_ICryptoAdapter){_inherits(SyncCryptoAdapter,_ICryptoAdapter);function SyncCryptoAdapter(){_classCallCheck(this,SyncCryptoAdapter);return _possibleConstructorReturn(this,_ICryptoAdapter.apply(this,arguments))}SyncCryptoAdapter.prototype.decryptBytes=function decryptBytes(comment$,envelope$,privateKeyPEMs,before,after){return crypto.decryptBytes(comment$,envelope$,privateKeyPEMs,before,after)};SyncCryptoAdapter.prototype.decryptComment=function decryptComment(comment$,envelope,privateKeyPEMs){return crypto.decryptComment(comment$,envelope,privateKeyPEMs)};SyncCryptoAdapter.prototype.decryptData=function decryptData(version,data$,envelope$,privateKeyPEMs){return crypto.decryptData(version,data$,envelope$,privateKeyPEMs)};SyncCryptoAdapter.prototype.decryptFileBlock=function decryptFileBlock(data$,privateKeyPEMs){return crypto.decryptFileBlock(data$,privateKeyPEMs)};SyncCryptoAdapter.prototype.decryptImage=function decryptImage(data$,privateKeyPEMs){return crypto.decryptImage(data$,privateKeyPEMs)};SyncCryptoAdapter.prototype.decryptPrivateKey=function decryptPrivateKey(privateKey$,password){return crypto.decryptPrivateKey(privateKey$,password)};SyncCryptoAdapter.prototype.encryptFileBlock=function encryptFileBlock(keyIV,fileBlock,decodeBlock){return crypto.encryptFileBlock(keyIV,fileBlock,decodeBlock)};SyncCryptoAdapter.prototype.encryptPrivateKey=function encryptPrivateKey(privateKeyPEM,password){return crypto.encryptPrivateKey(privateKeyPEM,password)};SyncCryptoAdapter.prototype.envelopeSeal=function envelopeSeal(secret,publicKeyPEMs){return crypto.envelopeSeal(secret,publicKeyPEMs)};SyncCryptoAdapter.prototype.envelopeUnseal=function envelopeUnseal(envelope,privateKeyPEMs){return crypto.envelopeUnseal(envelope,privateKeyPEMs)};SyncCryptoAdapter.prototype.generateAuthorizationHeaders=function generateAuthorizationHeaders(method,path,session){return crypto.generateAuthorizationHeaders(method,path,session)};SyncCryptoAdapter.prototype.generateKeyIV=function generateKeyIV(){return crypto.generateKeyIV()};SyncCryptoAdapter.prototype.generateKeyPair=function generateKeyPair(){return crypto.generateKeyPair()};SyncCryptoAdapter.prototype.generatePasswordHash=function generatePasswordHash(password){return crypto.generatePasswordHash(password)};SyncCryptoAdapter.prototype.generateWrappedSymmetricKey=function generateWrappedSymmetricKey(serverPublicKeyPEM){return crypto.generateWrappedSymmetricKey(serverPublicKeyPEM)};SyncCryptoAdapter.prototype.decryptManagedPrivateKey=function decryptManagedPrivateKey(privateKey$,keyBase64){return crypto.decryptManagedPrivateKey(privateKey$,keyBase64)};SyncCryptoAdapter.prototype.encryptComment=function encryptComment(comment,publicKeyPEMs){return crypto.encryptComment(comment,publicKeyPEMs)};return SyncCryptoAdapter}(_ICryptoAdapter3.default);exports.default=SyncCryptoAdapter;
@@ -46,11 +46,10 @@ declare class Briefs extends API {
46
46
  * @param {string} name The name of the brief
47
47
  * @param {array} [tags] array of tags
48
48
  * @param {File} [file] The brief file, for assigning fileId to brief
49
- * @param {boolean} [isPublic] Whether the brief is publicly accessible
50
49
  * @param {string} [messageToRecipient] message for recipient of brief, it is not needed at the moment at time of creation of Brief. but keeping it for now until it gets removed from API endpoint for brief creation
51
50
  * @returns {Promise<Brief>}
52
51
  */
53
- create({ name, file, isPublic, tags, dueDate, }: string): Promise<Brief>;
52
+ create({ name, file, tags, dueDate, }: string): Promise<Brief>;
54
53
  /**
55
54
  * Updates brief with edited title, tags, dueDate and added recipient, message for recipient and starts it by default
56
55
  *
package/lib/api/Briefs.js CHANGED
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _Proof=require("../models/Proof");var _Proof2=_interopRequireDefault(_Proof);var _FileStatus=require("../enum/FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _constants=require("../util/constants");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var Briefs=function(_API){_inherits(Briefs,_API);function Briefs(){_classCallCheck(this,Briefs);return _possibleConstructorReturn(this,_API.apply(this,arguments))}Briefs.prototype.setTags=function setTags(briefId,tags){return this.client.request("proofs.set-tags",{relatedId:briefId,tag:tags.join(",")})};Briefs.prototype.deleteTag=function deleteTag(briefId,tag){return this.client.request("proofs.tag-delete",{relatedId:briefId,tag:tag})};Briefs.prototype.setFile=function setFile(briefId,fileId){var _this2=this;return this.client.request("proofs.set-file",{proofId:briefId,fileId:fileId}).then(function(){return _this2.client.request("proofs.distribute-file",{proofId:briefId})})};Briefs.prototype.create=function create(_ref){var _this3=this;var name=_ref.name,file=_ref.file,isPublic=_ref.isPublic,_ref$tags=_ref.tags,tags=_ref$tags===undefined?[]:_ref$tags,_ref$dueDate=_ref.dueDate,dueDate=_ref$dueDate===undefined?new Date(Date.now()+3*_constants.DAY_IN_MS):_ref$dueDate;return this.client.request("briefs.create",{title:name,isPublic:isPublic,messageToRecipient:"",dueDate:dueDate.toISOString(),tag:tags.join(",")}).then(function(response){var brief=(new _Proof2.default).fromProof(response.data.Brief);return Promise.all([brief,file&&_this3.setFile(brief.id,file.id)])}).then(function(_ref2){var brief=_ref2[0];if(file){brief.fileId=file.id;brief.fileStatus=_FileStatus2.default.UPLOADING}brief.calculateState();return brief})};Briefs.prototype.update=function update(_ref3){var _this4=this;var briefId=_ref3.briefId,data=_ref3.data,_ref3$start=_ref3.start,start=_ref3$start===undefined?false:_ref3$start;return this.client.request("briefs.update",{briefId:briefId,title:data.title,messageToRecipient:data.messageToRecipient,dueDate:data.dueDate?data.dueDate.toISOString():"",tag:data.tags?data.tags.join(","):"",recipient:data.recipient,editorId:data.editorId,editorMessage:data.editorMessage,isPublic:data.isPublic}).then(function(response){var brief=(new _Proof2.default).fromProof(response.data.Brief);return brief}).then(function(brief){return Promise.resolve(start&&_this4.start(brief.id)).then(function(){return brief})})};Briefs.prototype.delete=function _delete(briefId){return this.client.request("proofs.delete",{proofId:briefId})};Briefs.prototype.start=function start(briefId){return this.client.request("briefs.start",{briefId:briefId})};return Briefs}(_API3.default);exports.default=Briefs;
1
+ "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _Proof=require("../models/Proof");var _Proof2=_interopRequireDefault(_Proof);var _FileStatus=require("../enum/FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _constants=require("../util/constants");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var Briefs=function(_API){_inherits(Briefs,_API);function Briefs(){_classCallCheck(this,Briefs);return _possibleConstructorReturn(this,_API.apply(this,arguments))}Briefs.prototype.setTags=function setTags(briefId,tags){return this.client.request("proofs.set-tags",{relatedId:briefId,tag:tags.join(",")})};Briefs.prototype.deleteTag=function deleteTag(briefId,tag){return this.client.request("proofs.tag-delete",{relatedId:briefId,tag:tag})};Briefs.prototype.setFile=function setFile(briefId,fileId){var _this2=this;return this.client.request("proofs.set-file",{proofId:briefId,fileId:fileId}).then(function(){return _this2.client.request("proofs.distribute-file",{proofId:briefId})})};Briefs.prototype.create=function create(_ref){var _this3=this;var name=_ref.name,file=_ref.file,_ref$tags=_ref.tags,tags=_ref$tags===undefined?[]:_ref$tags,_ref$dueDate=_ref.dueDate,dueDate=_ref$dueDate===undefined?new Date(Date.now()+3*_constants.DAY_IN_MS):_ref$dueDate;return this.client.request("briefs.create",{title:name,messageToRecipient:"",dueDate:dueDate.toISOString(),tag:tags.join(",")}).then(function(response){var brief=(new _Proof2.default).fromProof(response.data.Brief);return Promise.all([brief,file&&_this3.setFile(brief.id,file.id)])}).then(function(_ref2){var brief=_ref2[0];if(file){brief.fileId=file.id;brief.fileStatus=_FileStatus2.default.UPLOADING}brief.calculateState();return brief})};Briefs.prototype.update=function update(_ref3){var _this4=this;var briefId=_ref3.briefId,data=_ref3.data,_ref3$start=_ref3.start,start=_ref3$start===undefined?false:_ref3$start;return this.client.request("briefs.update",{briefId:briefId,title:data.title,messageToRecipient:data.messageToRecipient,dueDate:data.dueDate?data.dueDate.toISOString():"",tag:data.tags?data.tags.join(","):"",recipient:data.recipient,editorId:data.editorId,editorMessage:data.editorMessage}).then(function(response){var brief=(new _Proof2.default).fromProof(response.data.Brief);return brief}).then(function(brief){return Promise.resolve(start&&_this4.start(brief.id)).then(function(){return brief})})};Briefs.prototype.delete=function _delete(briefId){return this.client.request("proofs.delete",{proofId:briefId})};Briefs.prototype.start=function start(briefId){return this.client.request("briefs.start",{briefId:briefId})};return Briefs}(_API3.default);exports.default=Briefs;
package/lib/api/Files.js CHANGED
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _File=require("../models/File");var _File2=_interopRequireDefault(_File);var _FileStatus=require("../enum/FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _ImportProvider=require("../enum/ImportProvider");var _ImportProvider2=_interopRequireDefault(_ImportProvider);var _streamBlocks=require("../util/streamBlocks");var _streamBlocks2=_interopRequireDefault(_streamBlocks);var _bluffer=require("../bluffer");var _bluffer2=_interopRequireDefault(_bluffer);var _getContentLength=require("../util/getContentLength");var _getContentLength2=_interopRequireDefault(_getContentLength);var _constants=require("../util/constants");var _throttle=require("../util/throttle");var _throttle2=_interopRequireDefault(_throttle);var _concurrent=require("../util/concurrent");var _concurrent2=_interopRequireDefault(_concurrent);var _sleep=require("../util/sleep");var _sleep2=_interopRequireDefault(_sleep);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}function parseFilename(filename){var extensionIndex=filename.lastIndexOf(".");var name=filename.substring(0,extensionIndex);var extension=filename.substring(extensionIndex+1);return{name:name,extension:extension}}function containPercentage(percent,left,right){var total=1-(left+right);return total*percent+left}var Files=function(_API){_inherits(Files,_API);function Files(){_classCallCheck(this,Files);return _possibleConstructorReturn(this,_API.apply(this,arguments))}Files.prototype.generateToken=function generateToken(assignedTo,assignedType){if(assignedTo&&!assignedType){return Promise.reject(Error('The "assignedType" option is required when specifying the "assignedTo" option.'))}if(!assignedTo&&assignedType){return Promise.reject(Error('The "assignedTo" option is required when specifying the "assignedType" option.'))}return this.client.request("files.legacy.generate-token",{relatedId:assignedTo,fileType:assignedType}).then(function(response){return response.data.Token})};Files.prototype.setCanDownload=function setCanDownload(fileId,canDownload){return this.client.request("files.can-download.update",{fileId:fileId,downloadOriginal:canDownload?1:0})};Files.prototype._waitFileProcessed=function _waitFileProcessed(id){var _this2=this;return new Promise(function(resolve,reject){var checkTimeout=null;var timeoutTimeout=null;var check=function check(){_this2.details(id).then(function(file){checkTimeout=null;switch(file.status){case _FileStatus2.default.OK:{resolve(file);break}case _FileStatus2.default.ERROR:{reject(new Error("File "+id+" encountered a processing error: "+file.message));break}default:{checkTimeout=setTimeout(check,5e3);break}}if(!checkTimeout||file.status===_FileStatus2.default.RIPPING){clearTimeout(timeoutTimeout)}}).catch(reject)};check();timeoutTimeout=setTimeout(function(){clearTimeout(checkTimeout);reject(new Error("File did not finish processing within specified duration."))},3e4)})};Files.prototype._createWebsiteFile=function _createWebsiteFile(url){var _this3=this;return this._generateKeyIVEnvelope().then(function(_ref){var envelope=_ref.envelope;return _this3.client.request("files.import.web",{url:url,envelope:envelope})}).then(function(response){return response.data})};Files.prototype._importFileFromUrl=function _importFileFromUrl(_ref2){var _this4=this;var name=_ref2.name,url=_ref2.url,provider=_ref2.provider,auth=_ref2.auth,download=_ref2.download;var endpoint=provider;if(provider===_ImportProvider2.default.NONE){endpoint="generic"}var _parseFilename=parseFilename(name),filename=_parseFilename.name,extension=_parseFilename.extension;return this._generateKeyIVEnvelope().then(function(_ref3){var envelope=_ref3.envelope;return _this4.client.request("files.import."+endpoint,{extn:extension,filename:filename,url:url,envelope:envelope,accessToken:auth,storeOriginal:download})}).then(function(response){return response.data})};Files.prototype.import=function _import(_ref4){var _this5=this;var name=_ref4.name,url=_ref4.url,_ref4$provider=_ref4.provider,provider=_ref4$provider===undefined?_ImportProvider2.default.NONE:_ref4$provider,auth=_ref4.auth,_ref4$download=_ref4.download,download=_ref4$download===undefined?false:_ref4$download,_ref4$process=_ref4.process,process=_ref4$process===undefined?false:_ref4$process;var providerSupported=Object.keys(_ImportProvider2.default).some(function(key){return _ImportProvider2.default[key]===provider});if(!providerSupported){return Promise.reject(new Error('Unsupported provider "'+provider+'"'))}return(provider===_ImportProvider2.default.WEBSITE?this._createWebsiteFile(url):this._importFileFromUrl({name:name,url:url,provider:provider,auth:auth,download:download})).then(function(token){if(process){return _this5._waitFileProcessed(token)}else{var file=new _File2.default;file.id=token;return file}})};Files.prototype.email=function email(){return this.client.request("files.create-email").then(function(response){return response.data})};Files.prototype._generateKeyIVEnvelope=function _generateKeyIVEnvelope(){var _this6=this;return this.client.crypto().generateKeyIV().then(function(keyIV){return Promise.all([keyIV,_this6.client.crypto().envelopeSeal(keyIV.keyIV,_this6.client.keyPairs.getPublicKeyPEMs())])}).then(function(_ref5){var keyIV=_ref5[0],envelope=_ref5[1];return{keyIV:keyIV,envelope:envelope}})};Files.prototype.upload=function upload(){return this.upload__v2.apply(this,arguments)};Files.prototype.upload__v2=function upload__v2(files){var _this7=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var _options$concurrent=options.concurrent,concurrency=_options$concurrent===undefined?6:_options$concurrent,opts=_objectWithoutProperties(options,["concurrent"]);var scheduleChunk=(0,_concurrent2.default)(concurrency);var scheduleDone=(0,_concurrent2.default)(1);var doneFiles=[];var multipleFiles=Array.isArray(files);var filesList=multipleFiles?files:[files];var done=function done(result){doneFiles.push(result);return scheduleDone(function(){if(doneFiles.length){var _doneFiles=doneFiles.slice();doneFiles.length=0;return _this7.client.request("files.v2.upload-complete",{files:_doneFiles})}return null})};return this.client.request("files.v2.generate-credentials",{supports:{providers:["abs","custom"]},files:filesList.map(function(file){var name=void 0;var extension=void 0;if(file.extension){var _ref6=[file.name,file.extension];name=_ref6[0];extension=_ref6[1]}else{var parsed=parseFilename(file.name);var _ref7=[parsed.name,parsed.extension];name=_ref7[0];extension=_ref7[1]}var size=(0,_getContentLength2.default)(file.contents);var chunks=Math.ceil(size/_constants.BYTES_PER_BLOCK);if(file.onProgress){file.onProgress(0)}return{name:name,extension:extension,chunks:chunks,size:size,fileTypeOverride:file.fileTypeOverride,hash:null,adobeExportData:file.adobeExportData?JSON.stringify(file.adobeExportData):null,assignedTo:file.assignedTo,assignedType:file.assignedType,canDownload:typeof file.download!=="undefined"?!!file.download:true}})}).then(function(response){return Promise.all(filesList.map(function(file,index){var definition=response.data[index];if(file.onProgress){file.onProgress(1)}var entity=new _File2.default;entity.id=definition.FileId;if(file.onFileDetails){file.onFileDetails(entity)}return _this7._upload__v2(file,definition,opts,scheduleChunk,done).then(function(){return entity})}))}).then(function(results){return multipleFiles?results:results[0]})};Files.prototype._upload__v2=function _upload__v2(file,definition,options,schedule,done){var _this8=this;return this._generateKeyIVEnvelope().then(function(_ref8){var keyIV=_ref8.keyIV,envelope=_ref8.envelope;return new Promise(function(resolve,reject){var fileId=definition.FileId,uploadCredentials=definition.UploadCredentials;var bluffer=new _bluffer2.default;var complete=false;var index=0;var blocks=(0,_streamBlocks2.default)(file.contents,function(b){return bluffer.readBase64(b)});var tasks=[];var count=Math.ceil((0,_getContentLength2.default)(file.contents)/_constants.BYTES_PER_BLOCK);var percent=new Array(count);var lastPercent=1;var onUploadProgress=function onUploadProgress(){};var onProgress=file.onProgress;if(onProgress){onUploadProgress=function onUploadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);var totalPercent=containPercentage(percent.reduce(function(a,b){return a+(b||0)},0)/count/100,.01,.01)*100;if(typeof options.progressDecimalPlaces!=="undefined"){totalPercent=+totalPercent.toFixed(options.progressDecimalPlaces)}if(lastPercent!==totalPercent){onProgress(totalPercent);lastPercent=totalPercent}}}function handle(block,blockIndex){var task=encryptAndUpload(block,blockIndex);tasks.push(task);return task}var abs=function abs(block,blockIndex){return _this8.client.rawRequest({method:"PUT",host:uploadCredentials.url,path:"/"+fileId+"/"+blockIndex,query:uploadCredentials.sas,body:block,headers:{"x-ms-blob-type":"BlockBlob"}},{onUploadProgress:onUploadProgress.bind(null,blockIndex)})};var custom=function custom(block,blockIndex){var values={"file.id":fileId,"chunk.index":blockIndex};var interpolate=function interpolate(str){var map=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(a){return a};return str.replace(/\{([\w\.]+)\}/g,function(_,key){return map(values[key])})};var interpolatedHeaders={};Object.keys(uploadCredentials.headers).forEach(function(name){var value=interpolate(uploadCredentials.headers[name]);interpolatedHeaders[interpolate(name)]=value});return _this8.client.rawRequest({method:uploadCredentials.method,host:interpolate(uploadCredentials.host),path:interpolate(uploadCredentials.path,encodeURIComponent),query:interpolate(uploadCredentials.query,encodeURIComponent),body:block,headers:interpolatedHeaders},{onUploadProgress:onUploadProgress.bind(null,blockIndex)})};var uploadData={abs:abs,custom:custom}[uploadCredentials.type];var encryptAndUpload=function encryptAndUpload(block,blockIndex){return _this8.client.crypto().encryptFileBlock(keyIV,block,true).then(function(block$_){return bluffer.createBase64(block$_)}).then(function(block$){var retries=0;var chunkRetryLimit=typeof options.chunkRetryLimit!=="undefined"?options.chunkRetryLimit:3;function attemptUploadData(){return uploadData(block$,blockIndex).then(function(response){if([200,201].indexOf(response.status)===-1){if(retries<chunkRetryLimit){retries++;if(options.chunkRetryDelay){return(0,_sleep2.default)(options.chunkRetryDelay).then(attemptUploadData)}return attemptUploadData()}else{var err=new Error("Failed to upload block #"+blockIndex+" (retried "+retries+" times).");reject(err);complete=true;throw err}}return response})}return attemptUploadData()})};var finish=function finish(){return done({fileId:fileId,envelope:envelope}).then(function(){if(onProgress)onProgress(100)})};function next(){if(complete){return}schedule(function(){return blocks().then(function(data){if(data){next();return handle(data,index++)}else if(!complete){complete=true;var final=Promise.all(tasks).then(finish);resolve(final)}})})}next();if(file.async!==false){resolve()}})})};Files.prototype.upload__legacy=function upload__legacy(_ref9){var _this9=this;var name=_ref9.name,contents=_ref9.contents,adobeExportData=_ref9.adobeExportData,assignedTo=_ref9.assignedTo,assignedType=_ref9.assignedType,_ref9$download=_ref9.download,download=_ref9$download===undefined?false:_ref9$download,_ref9$async=_ref9.async,async=_ref9$async===undefined?true:_ref9$async,onProgress=_ref9.onProgress,onError=_ref9.onError;return this.generateToken(assignedTo,assignedType).then(function(token){return Promise.all([token,_this9._generateKeyIVEnvelope()])}).then(function(_ref10){var token=_ref10[0],_ref10$=_ref10[1],keyIV=_ref10$.keyIV,envelope=_ref10$.envelope;var process=_this9._upload__legacy({name:name,contents:contents,adobeExportData:adobeExportData,download:download,token:token,keyIV:keyIV,envelope:envelope,onProgress:onProgress,onError:onError});if(async){process=Promise.resolve()}return process.then(function(){return token})}).then(function(token){var file=new _File2.default;file.id=token;return file})};Files.prototype._upload__legacy=function _upload__legacy(_ref11){var _this10=this;var name=_ref11.name,contents=_ref11.contents,adobeExportData=_ref11.adobeExportData,download=_ref11.download,token=_ref11.token,keyIV=_ref11.keyIV,envelope=_ref11.envelope,onProgress=_ref11.onProgress;return new Promise(function(resolve){var concurrent=4;var _parseFilename2=parseFilename(name),filename=_parseFilename2.name,extension=_parseFilename2.extension;var blocks=(0,_streamBlocks2.default)(contents);var chain=Promise.resolve();var index=0;var end=false;var count=Math.ceil((0,_getContentLength2.default)(contents)/_constants.BYTES_PER_BLOCK);var percent=new Array(count);var onUploadProgress=function onUploadProgress(){};if(onProgress){onUploadProgress=function onUploadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);onProgress(percent.reduce(function(a,b){return a+(b||0)},0)/count*.99)}}var process=function process(block,blockIndex){return _this10.client.crypto().encryptFileBlock(keyIV,block).then(function(block$){return _this10.client.request("files.legacy.upload-block",{block:blockIndex,part:1,token:token,data:block$},{onUploadProgress:onUploadProgress.bind(null,blockIndex)})})};function next(){blocks().then(function(block){if(end)return;if(block===null){end=true;resolve(chain.then(complete))}else{var handle=process(block,index++);chain=chain.then(function(){return handle});handle.then(next)}})}var complete=function complete(){return _this10.client.request("files.legacy.upload-complete",{block:0,blockCount:index,part:0,token:token,extn:extension,pages:1,filename:filename,storeoriginal:download?1:0,adobeExportData:adobeExportData?JSON.stringify(adobeExportData):null,envelope:envelope}).then(function(){return onProgress&&onProgress(100)})};while(concurrent--){next()}})};Files.prototype.download=function download(_options){var _this11=this;var options=typeof _options==="string"?{fileId:_options}:_options;var fileId=options.fileId,onFileDetails=options.onFileDetails;return this.details(fileId).then(function(file){if(!options.silent){if(!file.downloadable){throw new Error("File "+fileId+" is not downloadable.")}if(file.status!==_FileStatus2.default.OK){throw new Error("File "+fileId+" cannot be download. The file may still be uploading, processing or has errored.")}if(!file.blocks){throw new Error("File "+fileId+" is empty.")}}if(onFileDetails){onFileDetails(file)}return _this11._downloadFile(file,options)})};Files.prototype._downloadFile=function _downloadFile(file,options){var _this12=this;return new Promise(function(resolve){var concurrent=4;var bluffer=new _bluffer2.default;var count=file.blocks;var blocks=new Array(count);var chain=Promise.resolve();var onData=options.onData||function onData(block,index){blocks[index]=block};var onDownloadProgress=function onDownloadProgress(){};if(options.onProgress){var percent=new Array(count);onDownloadProgress=function onDownloadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);options.onProgress(percent.reduce(function(a,b){return a+(b||0)},0)/count*.99)}}var process=function process(blockIndex){return _this12.client.request("files.download-block",{proofId:file.assignedTo,fileId:file.id,block:blockIndex+1,s:options.silent?1:undefined},{onDownloadProgress:onDownloadProgress.bind(null,blockIndex)}).then(function(response){return _this12.client.crypto().decryptFileBlock(response.data,_this12.client.keyPairs.getPrivateKeyPEMs()).then(function(blockBase64){return bluffer.createBase64(blockBase64)})})};var index=0;var end=false;function next(){if(end)return;if(index<blocks.length){var blockIndex=index++;var block=process(blockIndex);chain=chain.then(function(){return block.then(function(data){return onData(data,blockIndex,count)})});block.then(next)}else{end=true;resolve(chain.then(complete))}}var complete=function complete(){if(options.onProgress){options.onProgress(100)}if(!options.onData){return bluffer.combine.apply(bluffer,blocks)}return null};while(concurrent--){next()}})};Files.prototype.details=function details(fileId){return this.client.request("files.details",{fileId:fileId}).then(function(response){return(new _File2.default).fromFile(response.data)})};Files.prototype.thumbnail=function thumbnail(fileId){var _this13=this;return this.client.cache.auto(_constants.THUMBNAIL_CACHE_PREFIX+fileId,function(){return _this13._thumbnail(fileId)})};Files.prototype._thumbnail=function _thumbnail(fileId){var _this14=this;return this.client.request("files.thumbnail",{fileId:fileId}).then(function(response){return _this14.client.crypto().decryptImage(response.data,_this14.client.keyPairs.getPrivateKeyPEMs())}).then(function(imageBase64){var bluffer=new _bluffer2.default;return bluffer.createBase64(imageBase64)})};Files.prototype.preview=function preview(fileId){var _this15=this;var pageNumber=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;var quality=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"low";return this.client.cache.auto(_constants.PREVIEW_CACHE_PREFIX+fileId+pageNumber+quality,function(){return _this15._preview(fileId,pageNumber,quality)})};Files.prototype._preview=function _preview(fileId,pageNumber,quality){var _this16=this;return this.client.request("files.preview",{fileId:fileId,pageNumber:pageNumber,quality:{low:"lo",high:"hi"}[quality]||quality}).then(function(response){return _this16.client.crypto().decryptImage(response.data,_this16.client.keyPairs.getPrivateKeyPEMs())}).then(function(imageBase64){var bluffer=new _bluffer2.default;return bluffer.createBase64(imageBase64)})};Files.prototype.thumbnails=function thumbnails(fileIds,_ref12){var _this17=this;var _ref12$async=_ref12.async,async=_ref12$async===undefined?false:_ref12$async,onLoadThumbnail=_ref12.onLoadThumbnail,onLoadThumbnails=_ref12.onLoadThumbnails,_ref12$onLoadThumbnai=_ref12.onLoadThumbnailsThrottleMs,onLoadThumbnailsThrottleMs=_ref12$onLoadThumbnai===undefined?1e3:_ref12$onLoadThumbnai,onLoadError=_ref12.onLoadError;var scheduled=[];var pendingBatch={};var scheduleOnLoadThumbnails=onLoadThumbnails?(0,_throttle2.default)(function(){if(Object.keys(pendingBatch).length){onLoadThumbnails(pendingBatch);pendingBatch={}}},onLoadThumbnailsThrottleMs):function(){};return Promise.all(fileIds.map(function(fileId){return _this17.client.cache.auto(_constants.THUMBNAIL_CACHE_PREFIX+fileId,function(resolve){scheduled.push({fileId:fileId,resolve:resolve})}).then(function(thumbnail){var _ref13;return thumbnail&&(_ref13={},_ref13[fileId]=thumbnail,_ref13)})})).then(function(entries){var more=Promise.all(scheduled.map(function(_ref14){var fileId=_ref14.fileId,resolve=_ref14.resolve;return _this17._thumbnail(fileId).then(function(thumbnail){var _ref15;resolve(thumbnail);if(onLoadThumbnail){var _onLoadThumbnail;onLoadThumbnail((_onLoadThumbnail={},_onLoadThumbnail[fileId]=thumbnail,_onLoadThumbnail))}pendingBatch[fileId]=thumbnail;scheduleOnLoadThumbnails();return _ref15={},_ref15[fileId]=thumbnail,_ref15}).catch(function(err){if(onLoadError){onLoadError(err,fileId)}if(!async){return Promise.reject(err)}return{}})}));if(async){return entries}else{return more.then(function(moreEntries){return[].concat(entries,moreEntries)})}}).then(function(entries){return Object.assign.apply(Object,[{}].concat(entries))})};Files.prototype.duplicate=function duplicate(id){return this.client.request("files.duplicate",{id:id}).then(function(response){return response.data.file})};return Files}(_API3.default);exports.default=Files;
1
+ "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _File=require("../models/File");var _File2=_interopRequireDefault(_File);var _FileStatus=require("../enum/FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _ImportProvider=require("../enum/ImportProvider");var _ImportProvider2=_interopRequireDefault(_ImportProvider);var _streamBlocks=require("../util/streamBlocks");var _streamBlocks2=_interopRequireDefault(_streamBlocks);var _bluffer=require("../bluffer");var _bluffer2=_interopRequireDefault(_bluffer);var _constants=require("../util/constants");var _throttle=require("../util/throttle");var _throttle2=_interopRequireDefault(_throttle);var _concurrent=require("../util/concurrent");var _concurrent2=_interopRequireDefault(_concurrent);var _sleep=require("../util/sleep");var _sleep2=_interopRequireDefault(_sleep);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}function parseFilename(filename){var extensionIndex=filename.lastIndexOf(".");var name=filename.substring(0,extensionIndex);var extension=filename.substring(extensionIndex+1);return{name:name,extension:extension}}function containPercentage(percent,left,right){var total=1-(left+right);return total*percent+left}var Files=function(_API){_inherits(Files,_API);function Files(){_classCallCheck(this,Files);return _possibleConstructorReturn(this,_API.apply(this,arguments))}Files.prototype.generateToken=function generateToken(assignedTo,assignedType){if(assignedTo&&!assignedType){return Promise.reject(Error('The "assignedType" option is required when specifying the "assignedTo" option.'))}if(!assignedTo&&assignedType){return Promise.reject(Error('The "assignedTo" option is required when specifying the "assignedType" option.'))}return this.client.request("files.legacy.generate-token",{relatedId:assignedTo,fileType:assignedType}).then(function(response){return response.data.Token})};Files.prototype.setCanDownload=function setCanDownload(fileId,canDownload){return this.client.request("files.can-download.update",{fileId:fileId,downloadOriginal:canDownload?1:0})};Files.prototype._waitFileProcessed=function _waitFileProcessed(id){var _this2=this;return new Promise(function(resolve,reject){var checkTimeout=null;var timeoutTimeout=null;var check=function check(){_this2.details(id).then(function(file){checkTimeout=null;switch(file.status){case _FileStatus2.default.OK:{resolve(file);break}case _FileStatus2.default.ERROR:{reject(new Error("File "+id+" encountered a processing error: "+file.message));break}default:{checkTimeout=setTimeout(check,5e3);break}}if(!checkTimeout||file.status===_FileStatus2.default.RIPPING){clearTimeout(timeoutTimeout)}}).catch(reject)};check();timeoutTimeout=setTimeout(function(){clearTimeout(checkTimeout);reject(new Error("File did not finish processing within specified duration."))},3e4)})};Files.prototype._createWebsiteFile=function _createWebsiteFile(url){var _this3=this;return this._generateKeyIVEnvelope().then(function(_ref){var envelope=_ref.envelope;return _this3.client.request("files.import.web",{url:url,envelope:envelope})}).then(function(response){return response.data})};Files.prototype._importFileFromUrl=function _importFileFromUrl(_ref2){var _this4=this;var name=_ref2.name,url=_ref2.url,provider=_ref2.provider,auth=_ref2.auth,download=_ref2.download;var endpoint=provider;if(provider===_ImportProvider2.default.NONE){endpoint="generic"}var _parseFilename=parseFilename(name),filename=_parseFilename.name,extension=_parseFilename.extension;return this._generateKeyIVEnvelope().then(function(_ref3){var envelope=_ref3.envelope;return _this4.client.request("files.import."+endpoint,{extn:extension,filename:filename,url:url,envelope:envelope,accessToken:auth,storeOriginal:download})}).then(function(response){return response.data})};Files.prototype.import=function _import(_ref4){var _this5=this;var name=_ref4.name,url=_ref4.url,_ref4$provider=_ref4.provider,provider=_ref4$provider===undefined?_ImportProvider2.default.NONE:_ref4$provider,auth=_ref4.auth,_ref4$download=_ref4.download,download=_ref4$download===undefined?false:_ref4$download,_ref4$process=_ref4.process,process=_ref4$process===undefined?false:_ref4$process;var providerSupported=Object.keys(_ImportProvider2.default).some(function(key){return _ImportProvider2.default[key]===provider});if(!providerSupported){return Promise.reject(new Error('Unsupported provider "'+provider+'"'))}return(provider===_ImportProvider2.default.WEBSITE?this._createWebsiteFile(url):this._importFileFromUrl({name:name,url:url,provider:provider,auth:auth,download:download})).then(function(token){if(process){return _this5._waitFileProcessed(token)}else{var file=new _File2.default;file.id=token;return file}})};Files.prototype.email=function email(){return this.client.request("files.create-email").then(function(response){return response.data})};Files.prototype._generateKeyIVEnvelope=function _generateKeyIVEnvelope(){var _this6=this;return this.client.crypto().generateKeyIV().then(function(keyIV){return Promise.all([keyIV,_this6.client.crypto().envelopeSeal(keyIV.keyIV,_this6.client.keyPairs.getPublicKeyPEMs())])}).then(function(_ref5){var keyIV=_ref5[0],envelope=_ref5[1];return{keyIV:keyIV,envelope:envelope}})};Files.prototype.upload=function upload(){return this.upload__v2.apply(this,arguments)};Files.prototype.upload__v2=function upload__v2(files){var _this7=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var _options$concurrent=options.concurrent,concurrency=_options$concurrent===undefined?6:_options$concurrent,opts=_objectWithoutProperties(options,["concurrent"]);var scheduleChunk=(0,_concurrent2.default)(concurrency);var scheduleDone=(0,_concurrent2.default)(1);var doneFiles=[];var multipleFiles=Array.isArray(files);var filesList=multipleFiles?files:[files];var done=function done(result){doneFiles.push(result);return scheduleDone(function(){if(doneFiles.length){var _doneFiles=doneFiles.slice();doneFiles.length=0;return _this7.client.request("files.v2.upload-complete",{files:_doneFiles})}return null})};var bluffer=new _bluffer2.default;return this.client.request("files.v2.generate-credentials",{supports:{providers:["abs","custom"]},files:filesList.map(function(file){var name=void 0;var extension=void 0;if(file.extension){var _ref6=[file.name,file.extension];name=_ref6[0];extension=_ref6[1]}else{var parsed=parseFilename(file.name);var _ref7=[parsed.name,parsed.extension];name=_ref7[0];extension=_ref7[1]}var size=bluffer.size(file.contents);var chunks=Math.ceil(size/_constants.BYTES_PER_BLOCK);if(file.onProgress){file.onProgress(0)}return{name:name,extension:extension,chunks:chunks,size:size,fileTypeOverride:file.fileTypeOverride,hash:null,adobeExportData:file.adobeExportData?JSON.stringify(file.adobeExportData):null,assignedTo:file.assignedTo,assignedType:file.assignedType,canDownload:typeof file.download!=="undefined"?!!file.download:true}})}).then(function(response){return Promise.all(filesList.map(function(file,index){var definition=response.data[index];if(file.onProgress){file.onProgress(1)}var entity=new _File2.default;entity.id=definition.FileId;if(file.onFileDetails){file.onFileDetails(entity)}return _this7._upload__v2(file,definition,opts,scheduleChunk,done).then(function(){return entity})}))}).then(function(results){return multipleFiles?results:results[0]})};Files.prototype._upload__v2=function _upload__v2(file,definition,options,schedule,done){var _this8=this;return this._generateKeyIVEnvelope().then(function(_ref8){var keyIV=_ref8.keyIV,envelope=_ref8.envelope;return new Promise(function(resolve,reject){var fileId=definition.FileId,uploadCredentials=definition.UploadCredentials;var bluffer=new _bluffer2.default;var complete=false;var index=0;var blocks=(0,_streamBlocks2.default)(file.contents,function(b){return bluffer.readBase64(b)});var tasks=[];var count=Math.ceil(bluffer.size(file.contents)/_constants.BYTES_PER_BLOCK);var percent=new Array(count);var lastPercent=1;var onUploadProgress=function onUploadProgress(){};var onProgress=file.onProgress;if(onProgress){onUploadProgress=function onUploadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);var totalPercent=containPercentage(percent.reduce(function(a,b){return a+(b||0)},0)/count/100,.01,.01)*100;if(typeof options.progressDecimalPlaces!=="undefined"){totalPercent=+totalPercent.toFixed(options.progressDecimalPlaces)}if(lastPercent!==totalPercent){onProgress(totalPercent);lastPercent=totalPercent}}}function handle(block,blockIndex){var task=encryptAndUpload(block,blockIndex);tasks.push(task);return task}var abs=function abs(block,blockIndex){return _this8.client.rawRequest({method:"PUT",host:uploadCredentials.url,path:"/"+fileId+"/"+blockIndex,query:uploadCredentials.sas,body:block,headers:{"x-ms-blob-type":"BlockBlob"}},{onUploadProgress:onUploadProgress.bind(null,blockIndex)})};var custom=function custom(block,blockIndex){var values={"file.id":fileId,"chunk.index":blockIndex};var interpolate=function interpolate(str){var map=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(a){return a};return str.replace(/\{([\w\.]+)\}/g,function(_,key){return map(values[key])})};var interpolatedHeaders={};Object.keys(uploadCredentials.headers).forEach(function(name){var value=interpolate(uploadCredentials.headers[name]);interpolatedHeaders[interpolate(name)]=value});return _this8.client.rawRequest({method:uploadCredentials.method,host:interpolate(uploadCredentials.host),path:interpolate(uploadCredentials.path,encodeURIComponent),query:interpolate(uploadCredentials.query,encodeURIComponent),body:block,headers:interpolatedHeaders},{onUploadProgress:onUploadProgress.bind(null,blockIndex)})};var uploadData={abs:abs,custom:custom}[uploadCredentials.type];var encryptAndUpload=function encryptAndUpload(block,blockIndex){return _this8.client.crypto().encryptFileBlock(keyIV,block,true).then(function(block$_){return bluffer.createBase64(block$_)}).then(function(block$){return bluffer.readArrayBuffer(block$)}).then(function(block$){var retries=0;var chunkRetryLimit=typeof options.chunkRetryLimit!=="undefined"?options.chunkRetryLimit:3;function attemptUploadData(){return uploadData(block$,blockIndex).then(function(response){if([200,201].indexOf(response.status)===-1){if(retries<chunkRetryLimit){retries++;if(options.chunkRetryDelay){return(0,_sleep2.default)(options.chunkRetryDelay).then(attemptUploadData)}return attemptUploadData()}else{var err=new Error("Failed to upload block #"+blockIndex+" (retried "+retries+" times).");reject(err);complete=true;throw err}}return response})}return attemptUploadData()})};var finish=function finish(){return done({fileId:fileId,envelope:envelope}).then(function(){if(onProgress)onProgress(100)})};function next(){if(complete){return}schedule(function(){return blocks().then(function(data){if(data){next();return handle(data,index++)}else if(!complete){complete=true;var final=Promise.all(tasks).then(finish);resolve(final)}})})}next();if(file.async!==false){resolve()}})})};Files.prototype.upload__legacy=function upload__legacy(_ref9){var _this9=this;var name=_ref9.name,contents=_ref9.contents,adobeExportData=_ref9.adobeExportData,assignedTo=_ref9.assignedTo,assignedType=_ref9.assignedType,_ref9$download=_ref9.download,download=_ref9$download===undefined?false:_ref9$download,_ref9$async=_ref9.async,async=_ref9$async===undefined?true:_ref9$async,onProgress=_ref9.onProgress,onError=_ref9.onError;return this.generateToken(assignedTo,assignedType).then(function(token){return Promise.all([token,_this9._generateKeyIVEnvelope()])}).then(function(_ref10){var token=_ref10[0],_ref10$=_ref10[1],keyIV=_ref10$.keyIV,envelope=_ref10$.envelope;var process=_this9._upload__legacy({name:name,contents:contents,adobeExportData:adobeExportData,download:download,token:token,keyIV:keyIV,envelope:envelope,onProgress:onProgress,onError:onError});if(async){process=Promise.resolve()}return process.then(function(){return token})}).then(function(token){var file=new _File2.default;file.id=token;return file})};Files.prototype._upload__legacy=function _upload__legacy(_ref11){var _this10=this;var name=_ref11.name,contents=_ref11.contents,adobeExportData=_ref11.adobeExportData,download=_ref11.download,token=_ref11.token,keyIV=_ref11.keyIV,envelope=_ref11.envelope,onProgress=_ref11.onProgress;return new Promise(function(resolve){var concurrent=4;var _parseFilename2=parseFilename(name),filename=_parseFilename2.name,extension=_parseFilename2.extension;var blocks=(0,_streamBlocks2.default)(contents);var chain=Promise.resolve();var index=0;var end=false;var bluffer=new _bluffer2.default;var count=Math.ceil(bluffer.size(contents)/_constants.BYTES_PER_BLOCK);var percent=new Array(count);var onUploadProgress=function onUploadProgress(){};if(onProgress){onUploadProgress=function onUploadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);onProgress(percent.reduce(function(a,b){return a+(b||0)},0)/count*.99)}}var process=function process(block,blockIndex){return _this10.client.crypto().encryptFileBlock(keyIV,block).then(function(block$){return _this10.client.request("files.legacy.upload-block",{block:blockIndex,part:1,token:token,data:block$},{onUploadProgress:onUploadProgress.bind(null,blockIndex)})})};function next(){blocks().then(function(block){if(end)return;if(block===null){end=true;resolve(chain.then(complete))}else{var handle=process(block,index++);chain=chain.then(function(){return handle});handle.then(next)}})}var complete=function complete(){return _this10.client.request("files.legacy.upload-complete",{block:0,blockCount:index,part:0,token:token,extn:extension,pages:1,filename:filename,storeoriginal:download?1:0,adobeExportData:adobeExportData?JSON.stringify(adobeExportData):null,envelope:envelope}).then(function(){return onProgress&&onProgress(100)})};while(concurrent--){next()}})};Files.prototype.download=function download(_options){var _this11=this;var options=typeof _options==="string"?{fileId:_options}:_options;var fileId=options.fileId,onFileDetails=options.onFileDetails;return this.details(fileId).then(function(file){if(!options.silent){if(!file.downloadable){throw new Error("File "+fileId+" is not downloadable.")}if(file.status!==_FileStatus2.default.OK){throw new Error("File "+fileId+" cannot be download. The file may still be uploading, processing or has errored.")}if(!file.blocks){throw new Error("File "+fileId+" is empty.")}}if(onFileDetails){onFileDetails(file)}return _this11._downloadFile(file,options)})};Files.prototype._downloadFile=function _downloadFile(file,options){var _this12=this;return new Promise(function(resolve){var concurrent=4;var bluffer=new _bluffer2.default;var count=file.blocks;var blocks=new Array(count);var chain=Promise.resolve();var onData=options.onData||function onData(block,index){blocks[index]=block};var onDownloadProgress=function onDownloadProgress(){};if(options.onProgress){var percent=new Array(count);onDownloadProgress=function onDownloadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);options.onProgress(percent.reduce(function(a,b){return a+(b||0)},0)/count*.99)}}var process=function process(blockIndex){return _this12.client.request("files.download-block",{proofId:file.assignedTo,fileId:file.id,block:blockIndex+1,s:options.silent?1:undefined},{onDownloadProgress:onDownloadProgress.bind(null,blockIndex)}).then(function(response){return _this12.client.crypto().decryptFileBlock(response.data,_this12.client.keyPairs.getPrivateKeyPEMs()).then(function(blockBase64){return bluffer.createBase64(blockBase64)})})};var index=0;var end=false;function next(){if(end)return;if(index<blocks.length){var blockIndex=index++;var block=process(blockIndex);chain=chain.then(function(){return block.then(function(data){return onData(data,blockIndex,count)})});block.then(next)}else{end=true;resolve(chain.then(complete))}}var complete=function complete(){if(options.onProgress){options.onProgress(100)}if(!options.onData){return bluffer.combine.apply(bluffer,blocks)}return null};while(concurrent--){next()}})};Files.prototype.details=function details(fileId){return this.client.request("files.details",{fileId:fileId}).then(function(response){return(new _File2.default).fromFile(response.data)})};Files.prototype.thumbnail=function thumbnail(fileId){var _this13=this;return this.client.cache.auto(_constants.THUMBNAIL_CACHE_PREFIX+fileId,function(){return _this13._thumbnail(fileId)})};Files.prototype._thumbnail=function _thumbnail(fileId){var _this14=this;return this.client.request("files.thumbnail",{fileId:fileId}).then(function(response){return _this14.client.crypto().decryptImage(response.data,_this14.client.keyPairs.getPrivateKeyPEMs())}).then(function(imageBase64){var bluffer=new _bluffer2.default;return bluffer.createBase64(imageBase64)})};Files.prototype.preview=function preview(fileId){var _this15=this;var pageNumber=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;var quality=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"low";return this.client.cache.auto(_constants.PREVIEW_CACHE_PREFIX+fileId+pageNumber+quality,function(){return _this15._preview(fileId,pageNumber,quality)})};Files.prototype._preview=function _preview(fileId,pageNumber,quality){var _this16=this;return this.client.request("files.preview",{fileId:fileId,pageNumber:pageNumber,quality:{low:"lo",high:"hi"}[quality]||quality}).then(function(response){return _this16.client.crypto().decryptImage(response.data,_this16.client.keyPairs.getPrivateKeyPEMs())}).then(function(imageBase64){var bluffer=new _bluffer2.default;return bluffer.createBase64(imageBase64)})};Files.prototype.thumbnails=function thumbnails(fileIds,_ref12){var _this17=this;var _ref12$async=_ref12.async,async=_ref12$async===undefined?false:_ref12$async,onLoadThumbnail=_ref12.onLoadThumbnail,onLoadThumbnails=_ref12.onLoadThumbnails,_ref12$onLoadThumbnai=_ref12.onLoadThumbnailsThrottleMs,onLoadThumbnailsThrottleMs=_ref12$onLoadThumbnai===undefined?1e3:_ref12$onLoadThumbnai,onLoadError=_ref12.onLoadError;var scheduled=[];var pendingBatch={};var scheduleOnLoadThumbnails=onLoadThumbnails?(0,_throttle2.default)(function(){if(Object.keys(pendingBatch).length){onLoadThumbnails(pendingBatch);pendingBatch={}}},onLoadThumbnailsThrottleMs):function(){};return Promise.all(fileIds.map(function(fileId){return _this17.client.cache.auto(_constants.THUMBNAIL_CACHE_PREFIX+fileId,function(resolve){scheduled.push({fileId:fileId,resolve:resolve})}).then(function(thumbnail){var _ref13;return thumbnail&&(_ref13={},_ref13[fileId]=thumbnail,_ref13)})})).then(function(entries){var more=Promise.all(scheduled.map(function(_ref14){var fileId=_ref14.fileId,resolve=_ref14.resolve;return _this17._thumbnail(fileId).then(function(thumbnail){var _ref15;resolve(thumbnail);if(onLoadThumbnail){var _onLoadThumbnail;onLoadThumbnail((_onLoadThumbnail={},_onLoadThumbnail[fileId]=thumbnail,_onLoadThumbnail))}pendingBatch[fileId]=thumbnail;scheduleOnLoadThumbnails();return _ref15={},_ref15[fileId]=thumbnail,_ref15}).catch(function(err){if(onLoadError){onLoadError(err,fileId)}if(!async){return Promise.reject(err)}return{}})}));if(async){return entries}else{return more.then(function(moreEntries){return[].concat(entries,moreEntries)})}}).then(function(entries){return Object.assign.apply(Object,[{}].concat(entries))})};Files.prototype.duplicate=function duplicate(id){return this.client.request("files.duplicate",{id:id}).then(function(response){return response.data.file})};return Files}(_API3.default);exports.default=Files;
@@ -26,12 +26,6 @@ declare class Team extends API {
26
26
  * @type {TeamPreferences}
27
27
  */
28
28
  preferences: TeamPreferences;
29
- /**
30
- * The Admin Custom Webhooks API.
31
- *
32
- * @type {TeamCustomWebhooks}
33
- */
34
- customWebhooks: TeamCustomWebhooks;
35
29
  /**
36
30
  * The Admin Team SCIM API.
37
31
  *
@@ -63,7 +57,6 @@ import TeamUsers from "./TeamUsers";
63
57
  import TeamDashboard from "./TeamDashboard";
64
58
  import TeamFeatures from "./TeamFeatures";
65
59
  import TeamPreferences from "./TeamPreferences";
66
- import TeamCustomWebhooks from "./TeamCustomWebhooks";
67
60
  import TeamSCIM from "./TeamSCIM";
68
61
  import Integrations from "../Integrations";
69
62
  import TeamCustomTools from "./TeamCustomTools";
@@ -22,10 +22,6 @@ var _TeamPreferences = require('./TeamPreferences');
22
22
 
23
23
  var _TeamPreferences2 = _interopRequireDefault(_TeamPreferences);
24
24
 
25
- var _TeamCustomWebhooks = require('./TeamCustomWebhooks');
26
-
27
- var _TeamCustomWebhooks2 = _interopRequireDefault(_TeamCustomWebhooks);
28
-
29
25
  var _TeamSCIM = require('./TeamSCIM');
30
26
 
31
27
  var _TeamSCIM2 = _interopRequireDefault(_TeamSCIM);
@@ -75,16 +71,15 @@ var Team = function (_API) {
75
71
 
76
72
 
77
73
  /**
78
- * The Admin Team Preferences API.
74
+ * The Admin Team Features API.
79
75
  *
80
- * @type {TeamPreferences}
76
+ * @type {TeamFeatures}
81
77
  */
82
78
 
83
-
84
79
  /**
85
- * The Admin Team Dashboard API.
80
+ * The Admin Team Users API.
86
81
  *
87
- * @type {TeamDashboard}
82
+ * @type {TeamUsers}
88
83
  */
89
84
  function Team(client) {
90
85
  _classCallCheck(this, Team);
@@ -96,7 +91,6 @@ var Team = function (_API) {
96
91
  _this.dashboard = new _TeamDashboard2.default(client);
97
92
  _this.features = new _TeamFeatures2.default(client);
98
93
  _this.preferences = new _TeamPreferences2.default(client);
99
- _this.customWebhooks = new _TeamCustomWebhooks2.default(client);
100
94
  _this.scim = new _TeamSCIM2.default(client);
101
95
  _this.workflows = new _TeamWorkflows2.default(client);
102
96
  _this.integrations = new _Integrations2.default(client, 'team');
@@ -120,22 +114,16 @@ var Team = function (_API) {
120
114
 
121
115
 
122
116
  /**
123
- * The Admin Custom Webhooks API.
117
+ * The Admin Team Preferences API.
124
118
  *
125
- * @type {TeamCustomWebhooks}
119
+ * @type {TeamPreferences}
126
120
  */
127
121
 
128
122
 
129
123
  /**
130
- * The Admin Team Features API.
131
- *
132
- * @type {TeamFeatures}
133
- */
134
-
135
- /**
136
- * The Admin Team Users API.
124
+ * The Admin Team Dashboard API.
137
125
  *
138
- * @type {TeamUsers}
126
+ * @type {TeamDashboard}
139
127
  */
140
128
 
141
129
 
@@ -0,0 +1,71 @@
1
+ export default Uint8ArrayBluffer;
2
+ /** @private */
3
+ declare class Uint8ArrayBluffer {
4
+ /**
5
+ * Creates a Uint8Array from a binary string.
6
+ *
7
+ * @param {string} text
8
+ * @returns {Promise<Uint8Array>}
9
+ */
10
+ create(text: string): Promise<Uint8Array>;
11
+ /**
12
+ * Creates a Uint8Array from a base64 encoded string. Effectively decoding it.
13
+ *
14
+ * @param {string} base64
15
+ * @return {Promise<Uint8Array>}
16
+ */
17
+ createBase64(base64: string): Promise<Uint8Array>;
18
+ /**
19
+ * Creates a Uint8Array from an ArrayBuffer.
20
+ *
21
+ * @param {ArrayBuffer} ab
22
+ * @returns {Promise<Uint8Array>}
23
+ */
24
+ createArrayBuffer(ab: ArrayBuffer): Promise<Uint8Array>;
25
+ /**
26
+ * Combines two Uint8Arrays to create a new Uint8Array containing the two.
27
+ *
28
+ * @param {Uint8Array} blufferA
29
+ * @param {Uint8Array} blufferB
30
+ * @param {Array<Uint8Array>} bluffers
31
+ * @returns {Promise<Uint8Array>}
32
+ */
33
+ combine(...bluffers: Uint8Array[]): Promise<Uint8Array>;
34
+ /**
35
+ * Creates a new Uint8Array containing a slice of the original Uint8Array.
36
+ *
37
+ * @param {Uint8Array} bluffer
38
+ * @param {number} start
39
+ * @param {number} end
40
+ * @returns {Promise<Uint8Array>}
41
+ */
42
+ slice(bluffer: Uint8Array, start: number, end: number): Promise<Uint8Array>;
43
+ /**
44
+ * Extracts the contents of a Uint8Array as a binary string.
45
+ *
46
+ * @param {Uint8Array} bluffer
47
+ * @returns {Promise<string>}
48
+ */
49
+ read(bluffer: Uint8Array): Promise<string>;
50
+ /**
51
+ * Extracts the contents of a Uint8Array as a base64 string.
52
+ *
53
+ * @param {Uint8Array} bluffer
54
+ * @returns {Promise<string>}
55
+ */
56
+ readBase64(bluffer: Uint8Array): Promise<string>;
57
+ /**
58
+ * Extracts the contents of a Uint8Array as an ArrayBuffer.
59
+ *
60
+ * @param {Uint8Array} bluffer
61
+ * @returns {Promise<ArrayBuffer>}
62
+ */
63
+ readArrayBuffer(bluffer: Uint8Array): Promise<ArrayBuffer>;
64
+ /**
65
+ * Gets the length/size (in bytes) of the Uint8Array.
66
+ *
67
+ * @param {Uint8Array} bluffer
68
+ * @returns {number}
69
+ */
70
+ size(bluffer: Uint8Array): number;
71
+ }
@@ -0,0 +1 @@
1
+ "use strict";exports.__esModule=true;var _base64Js=require("base64-js");var _base64Js2=_interopRequireDefault(_base64Js);var _arrayBufferToString=require("../util/arrayBufferToString");var _arrayBufferToString2=_interopRequireDefault(_arrayBufferToString);var _stringToArrayBuffer=require("../util/stringToArrayBuffer");var _stringToArrayBuffer2=_interopRequireDefault(_stringToArrayBuffer);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function uaToAb(arr){return arr.byteLength!==arr.buffer.byteLength?arr.buffer.slice(arr.byteOffset,arr.byteOffset+arr.byteLength):arr.buffer}function abToUa(ab){return new Uint8Array(ab)}function uaToStr(arr){return(0,_arrayBufferToString2.default)(uaToAb(arr))}function strToUa(str){return abToUa((0,_stringToArrayBuffer2.default)(str))}function combineUas(arrs){var buffer=new Uint8Array(arrs.reduce(function(total,bluffer){return total+bluffer.byteLength},0));for(var i=0,offset=0;i<arrs.length;i++){buffer.set(arrs[i],offset);offset+=arrs[i].byteLength}return buffer}var Uint8ArrayBluffer=function(){function Uint8ArrayBluffer(){_classCallCheck(this,Uint8ArrayBluffer)}Uint8ArrayBluffer.prototype.create=function create(text){return Promise.resolve(strToUa(text))};Uint8ArrayBluffer.prototype.createBase64=function createBase64(base64){return Promise.resolve(_base64Js2.default.toByteArray(base64))};Uint8ArrayBluffer.prototype.createArrayBuffer=function createArrayBuffer(ab){return Promise.resolve(abToUa(ab))};Uint8ArrayBluffer.prototype.combine=function combine(){for(var _len=arguments.length,bluffers=Array(_len),_key=0;_key<_len;_key++){bluffers[_key]=arguments[_key]}return Promise.resolve(combineUas(bluffers))};Uint8ArrayBluffer.prototype.slice=function slice(bluffer,start,end){return Promise.resolve(bluffer.slice(start,end))};Uint8ArrayBluffer.prototype.read=function read(bluffer){return Promise.resolve(uaToStr(bluffer))};Uint8ArrayBluffer.prototype.readBase64=function readBase64(bluffer){return Promise.resolve(_base64Js2.default.fromByteArray(bluffer))};Uint8ArrayBluffer.prototype.readArrayBuffer=function readArrayBuffer(bluffer){return Promise.resolve(uaToAb(bluffer))};Uint8ArrayBluffer.prototype.size=function size(bluffer){return bluffer.byteLength};return Uint8ArrayBluffer}();exports.default=Uint8ArrayBluffer;
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var debug=require("debug")("bluffer");function Bluffer(){if(typeof Bluffer.driver==="function"){var Driver=Bluffer.driver;return new Driver}else if(typeof Bluffer.driver==="string"){var _Driver=void 0;switch(Bluffer.driver){case"Blob":{_Driver=require("./BlobBluffer").default;break}case"Buffer":{_Driver=require("./BufferBluffer").default;break}case"String":{_Driver=require("./StringBluffer").default;break}default:{throw new Error('Unknown Bluffer driver "'+Bluffer.driver+'".')}}if(_Driver){return new _Driver}else{throw new Error('Bluffer driver "'+Bluffer.driver+'" not found.')}}else{throw new Error('Bluffer.driver must be either "Blob", "Bluffer", or "String" or a custom constructor.')}}Bluffer.driver="String";if(typeof Buffer!=="undefined"){Bluffer.driver="Buffer"}else if(typeof Blob!=="undefined"){Bluffer.driver="Blob"}else{debug("The current JavaScript environment does not support native Bluffer, falling back to using StringBluffer.");Bluffer.driver="String"}exports.default=Bluffer;
1
+ "use strict";exports.__esModule=true;var debug=require("debug")("bluffer");function Bluffer(){if(typeof Bluffer.driver==="function"){var Driver=Bluffer.driver;return new Driver}else if(typeof Bluffer.driver==="string"){var _Driver=void 0;switch(Bluffer.driver){case"Blob":{_Driver=require("./BlobBluffer").default;break}case"Buffer":{_Driver=require("./BufferBluffer").default;break}case"String":{_Driver=require("./StringBluffer").default;break}case"Uint8Array":{_Driver=require("./Uint8ArrayBluffer").default;break}default:{throw new Error('Unknown Bluffer driver "'+Bluffer.driver+'".')}}if(_Driver){return new _Driver}else{throw new Error('Bluffer driver "'+Bluffer.driver+'" not found.')}}else{throw new Error('Bluffer.driver must be either "Blob", "Bluffer", "Uint8Array" (experimental), or "String" or a custom constructor.')}}Bluffer.driver="String";if(typeof Buffer!=="undefined"){Bluffer.driver="Buffer"}else if(typeof Blob!=="undefined"){Bluffer.driver="Blob"}else{debug("The current JavaScript environment does not support native Bluffer, falling back to using StringBluffer.");Bluffer.driver="String"}exports.default=Bluffer;
@@ -165,11 +165,6 @@
165
165
  "path": "/api/admin/group",
166
166
  "chain": ["groupId"]
167
167
  },
168
- "admin.team.custom-webhooks.create": {
169
- "method": "POST",
170
- "path": "/api/admin/teams/custom-webhooks/create",
171
- "body": ["event", "url"]
172
- },
173
168
  "users.by-id": {
174
169
  "method": "GET",
175
170
  "path": "/api/users",
@@ -820,12 +815,12 @@
820
815
  "briefs.create": {
821
816
  "method": "POST",
822
817
  "path": "/api/briefs/create",
823
- "body": ["title", "messageToRecipient", "dueDate", "tag", "isPublic"]
818
+ "body": ["title", "messageToRecipient", "dueDate", "tag"]
824
819
  },
825
820
  "briefs.update": {
826
821
  "method": "POST",
827
822
  "path": "/api/briefs/update",
828
- "body": ["briefId", "title", "messageToRecipient", "dueDate", "tag", "recipient", "editorId", "editorMessage", "isPublic"]
823
+ "body": ["briefId", "title", "messageToRecipient", "dueDate", "tag", "recipient", "editorId", "editorMessage"]
829
824
  },
830
825
  "admin.team.users.enabled": {
831
826
  "method": "GET",