@pageproof/sdk-pr 280.0.1602104047768 → 280.0.1602108148595

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.
@@ -36,13 +36,13 @@ declare class Encryption extends API {
36
36
  * Note: When manually specifying an encryption version (by hard coding it), it's important you understand the implications that has on how the file is encrypted.
37
37
  *
38
38
  * @example <caption>Generating a file encryption key (using the default encryption version)</caption>
39
- * const { encryptionVersion, envelope } = await client.encryption.generateFileEncryptionKey();
39
+ * const { encryptionVersion, envelope } = await client.encryption.generateFileEnvelope();
40
40
  * console.log(encryptionVersion); // eg. "0001"
41
41
  *
42
42
  * @param {string} [encryptionVersion] The encryption version used when encrypting the file
43
43
  * @returns {Promise<{ encryptionVersion: string, envelope: string | null, keyIV: { key: string, iv: string } | null }>}
44
44
  */
45
- generateFileEncryptionKey(encryptionVersion?: string): Promise<{
45
+ generateFileEnvelope(encryptionVersion?: string): Promise<{
46
46
  encryptionVersion: string;
47
47
  envelope: string;
48
48
  keyIV: {
@@ -173,26 +173,26 @@ declare class Encryption extends API {
173
173
  iv: string;
174
174
  }, data: Blob | Buffer): Blob | Buffer;
175
175
  /**
176
- * Encrypts a extracted text (for a file).
176
+ * Encrypts a chunk of extracted text (for a file).
177
177
  *
178
- * @param {string} encryptionVersion The encryption version used to encrypt the extracted text.
179
- * @param {string|{ key: string, iv: string }|null} envelopeOrKeyIV The envelope (or key IV object) used to encrypt the extracted text.
180
- * @param {Buffer|Blob} data The raw (un-encrypted) extracted text data.
178
+ * @param {string} encryptionVersion The encryption version used to encrypt the chunk of extracted text.
179
+ * @param {string|{ key: string, iv: string }|null} envelopeOrKeyIV The envelope (or key IV object) used to encrypt the chunk of extracted text.
180
+ * @param {Buffer|Blob} data The raw (un-encrypted) chunk of extracted text data.
181
181
  * @returns {Buffer|Blob}
182
182
  */
183
- encryptFileExtractedText(encryptionVersion: string, envelopeOrKeyIV: string | {
183
+ encryptFileExtractedTextPerChunk(encryptionVersion: string, envelopeOrKeyIV: string | {
184
184
  key: string;
185
185
  iv: string;
186
186
  }, data: Blob | Buffer): Blob | Buffer;
187
187
  /**
188
- * Decrypts a extracted text (for a file).
188
+ * Decrypts a chunk of extracted text (for a file).
189
189
  *
190
- * @param {string} encryptionVersion The encryption version used to decrypt the extracted text.
191
- * @param {string|{ key: string, iv: string }|null} envelopeOrKeyIV The envelope (or key IV object) used to decrypt the extracted text.
192
- * @param {Buffer|Blob} data The encrypted extracted text data.
190
+ * @param {string} encryptionVersion The encryption version used to decrypt the chunk of extracted text.
191
+ * @param {string|{ key: string, iv: string }|null} envelopeOrKeyIV The envelope (or key IV object) used to decrypt the chunk of extracted text.
192
+ * @param {Buffer|Blob} data The encrypted chunk of extracted text data.
193
193
  * @returns {Buffer|Blob}
194
194
  */
195
- decryptFileExtractedText(encryptionVersion: string, envelopeOrKeyIV: string | {
195
+ decryptFileExtractedTextPerChunk(encryptionVersion: string, envelopeOrKeyIV: string | {
196
196
  key: string;
197
197
  iv: string;
198
198
  }, data: Blob | Buffer): Blob | Buffer;
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _bluffer=require("../bluffer");var _bluffer2=_interopRequireDefault(_bluffer);var _encryptionVersions=require("../util/encryptionVersions.json");var _encryptionVersions2=_interopRequireDefault(_encryptionVersions);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 Encryption=function(_API){_inherits(Encryption,_API);function Encryption(){_classCallCheck(this,Encryption);return _possibleConstructorReturn(this,_API.apply(this,arguments))}Encryption.prototype.decrypt=function decrypt(_ref){var _this2=this;var version=_ref.version,data=_ref.data,envelope=_ref.envelope;var bluffer=new _bluffer2.default;var content=typeof data==="string"?bluffer.create(data):Promise.resolve(data);return content.then(function(content$){return bluffer.read(content$).then(function(data$){return _this2.client.crypto().decryptData(version,data$,envelope,_this2.client.session.privateKeyPEM).then(function(decrypted){return bluffer.create(decrypted)})})})};Encryption.prototype.generateFileEncryptionKey=function generateFileEncryptionKey(){var _this3=this;var encryptionVersion=arguments.length>0&&arguments[0]!==undefined?arguments[0]:_constants.DEFAULT_FILE_ENCRYPTION_VERSION;if(encryptionVersion==="0000"){return Promise.resolve({encryptionVersion:"0000",envelope:null,keyIV:null})}return this.client.crypto().generateKeyIV().then(function(keyIV){return Promise.all([{key:keyIV.key,iv:keyIV.iv},_this3.client.crypto().envelopeSeal(keyIV.keyIV,[_this3.client.session.serverPublicKeyPEM,_this3.client.session.publicKeyPEM],false)])}).then(function(_ref2){var keyIV=_ref2[0],envelope=_ref2[1];return{encryptionVersion:encryptionVersion,envelope:envelope,keyIV:keyIV}})};Encryption.prototype._transformFile=function _transformFile(direction,variant,data,envelopeOrKeyIV,encryptionVersion){var _this4=this;var bluffer=new _bluffer2.default;return bluffer.readBase64(data).then(function(base64Data){return _this4.client.crypto().transformFile(direction,variant,base64Data,"base64",envelopeOrKeyIV,_this4.client.session.privateKeyPEM,_encryptionVersions2.default,encryptionVersion)}).then(function(base64Output){return bluffer.createBase64(base64Output)})};Encryption.prototype.encryptFileThumbnail=function encryptFileThumbnail(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","thumbnail",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFileThumbnail=function decryptFileThumbnail(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","thumbnail",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.encryptFileSpriteSheet=function encryptFileSpriteSheet(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","sprite_sheet",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFileSpriteSheet=function decryptFileSpriteSheet(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","sprite_sheet",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.encryptFilePreviewLow=function encryptFilePreviewLow(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","preview_low",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFilePreviewLow=function decryptFilePreviewLow(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","preview_low",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.encryptFilePreviewHigh=function encryptFilePreviewHigh(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","preview_high",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFilePreviewHigh=function decryptFilePreviewHigh(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","preview_high",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.encryptFileContentsPerChunk=function encryptFileContentsPerChunk(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","contents_per_chunk",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFileContentsPerChunk=function decryptFileContentsPerChunk(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","contents_per_chunk",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.encryptFileExtractedText=function encryptFileExtractedText(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","extracted_text",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFileExtractedText=function decryptFileExtractedText(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","extracted_text",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.encryptFileUploadPerChunk=function encryptFileUploadPerChunk(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","upload_per_chunk",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFileUploadPerChunk=function decryptFileUploadPerChunk(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","upload_per_chunk",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.encryptFileRendition=function encryptFileRendition(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","rendition",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFileRendition=function decryptFileRendition(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","rendition",data,envelopeOrKeyIV,encryptionVersion)};return Encryption}(_API3.default);exports.default=Encryption;
1
+ "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _bluffer=require("../bluffer");var _bluffer2=_interopRequireDefault(_bluffer);var _encryptionVersions=require("../util/encryptionVersions.json");var _encryptionVersions2=_interopRequireDefault(_encryptionVersions);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 Encryption=function(_API){_inherits(Encryption,_API);function Encryption(){_classCallCheck(this,Encryption);return _possibleConstructorReturn(this,_API.apply(this,arguments))}Encryption.prototype.decrypt=function decrypt(_ref){var _this2=this;var version=_ref.version,data=_ref.data,envelope=_ref.envelope;var bluffer=new _bluffer2.default;var content=typeof data==="string"?bluffer.create(data):Promise.resolve(data);return content.then(function(content$){return bluffer.read(content$).then(function(data$){return _this2.client.crypto().decryptData(version,data$,envelope,_this2.client.session.privateKeyPEM).then(function(decrypted){return bluffer.create(decrypted)})})})};Encryption.prototype.generateFileEnvelope=function generateFileEnvelope(){var _this3=this;var encryptionVersion=arguments.length>0&&arguments[0]!==undefined?arguments[0]:_constants.DEFAULT_FILE_ENCRYPTION_VERSION;if(encryptionVersion==="0000"){return Promise.resolve({encryptionVersion:"0000",envelope:null,keyIV:null})}return this.client.crypto().generateKeyIV().then(function(keyIV){return Promise.all([{key:keyIV.key,iv:keyIV.iv},_this3.client.crypto().envelopeSeal(keyIV.keyIV,[_this3.client.session.serverPublicKeyPEM,_this3.client.session.publicKeyPEM],false)])}).then(function(_ref2){var keyIV=_ref2[0],envelope=_ref2[1];return{encryptionVersion:encryptionVersion,envelope:envelope,keyIV:keyIV}})};Encryption.prototype._transformFile=function _transformFile(direction,variant,data,envelopeOrKeyIV,encryptionVersion){var _this4=this;var bluffer=new _bluffer2.default;return bluffer.readBase64(data).then(function(base64Data){return _this4.client.crypto().transformFile(direction,variant,base64Data,"base64",envelopeOrKeyIV,_this4.client.session.privateKeyPEM,_encryptionVersions2.default,encryptionVersion)}).then(function(base64Output){return bluffer.createBase64(base64Output)})};Encryption.prototype.encryptFileThumbnail=function encryptFileThumbnail(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","thumbnail",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFileThumbnail=function decryptFileThumbnail(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","thumbnail",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.encryptFileSpriteSheet=function encryptFileSpriteSheet(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","sprite_sheet",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFileSpriteSheet=function decryptFileSpriteSheet(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","sprite_sheet",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.encryptFilePreviewLow=function encryptFilePreviewLow(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","preview_low",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFilePreviewLow=function decryptFilePreviewLow(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","preview_low",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.encryptFilePreviewHigh=function encryptFilePreviewHigh(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","preview_high",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFilePreviewHigh=function decryptFilePreviewHigh(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","preview_high",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.encryptFileContentsPerChunk=function encryptFileContentsPerChunk(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","contents_per_chunk",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFileContentsPerChunk=function decryptFileContentsPerChunk(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","contents_per_chunk",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.encryptFileExtractedTextPerChunk=function encryptFileExtractedTextPerChunk(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","extracted_text_per_chunk",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFileExtractedTextPerChunk=function decryptFileExtractedTextPerChunk(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","extracted_text_per_chunk",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.encryptFileUploadPerChunk=function encryptFileUploadPerChunk(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","upload_per_chunk",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFileUploadPerChunk=function decryptFileUploadPerChunk(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","upload_per_chunk",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.encryptFileRendition=function encryptFileRendition(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("in","rendition",data,envelopeOrKeyIV,encryptionVersion)};Encryption.prototype.decryptFileRendition=function decryptFileRendition(encryptionVersion,envelopeOrKeyIV,data){return this._transformFile("out","rendition",data,envelopeOrKeyIV,encryptionVersion)};return Encryption}(_API3.default);exports.default=Encryption;