@pageproof/sdk-pr 600.0.1756970152956 → 601.0.1755682916092
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/lib/adapters/ICryptoAdapter.d.ts +0 -21
- package/lib/adapters/ICryptoAdapter.js +1 -1
- package/lib/adapters/SchedulerCryptoAdapter.d.ts +0 -18
- package/lib/adapters/SchedulerCryptoAdapter.js +1 -1
- package/lib/adapters/SyncCryptoAdapter.d.ts +0 -18
- package/lib/adapters/SyncCryptoAdapter.js +1 -1
- package/lib/api/AccountsSSO.d.ts +1 -37
- package/lib/api/AccountsSSO.js +1 -1
- package/lib/api/Files.d.ts +29 -0
- package/lib/api/Files.js +1 -1
- package/lib/crypto/index.d.ts +1 -4
- package/lib/crypto/index.js +1 -1
- package/lib/network/endpoints.json +11 -15
- package/lib/pageproof.js +1 -1
- package/lib/sync-crypto-adapter.js +1 -1
- package/lib/worker-crypto-adapter.js +1 -1
- package/lib/{worker.607a03dc.js → worker.959d0daf.js} +2 -2
- package/package.json +1 -1
- package/lib/crypto/authServerEncryption.d.ts +0 -21
- package/lib/crypto/authServerEncryption.js +0 -1
- package/lib/types/IsolatedLoginStatusResult.d.ts +0 -22
- package/lib/types/IsolatedLoginStatusResult.js +0 -1
- package/lib/util/isolatedAuthCert.d.ts +0 -2
- package/lib/util/isolatedAuthCert.js +0 -1
|
@@ -139,25 +139,4 @@ declare class ICryptoAdapter {
|
|
|
139
139
|
* @returns {Promise<string>} The encrypted block, base64 encoded
|
|
140
140
|
*/
|
|
141
141
|
encryptCommentImportFile(): Promise<string>;
|
|
142
|
-
/**
|
|
143
|
-
* @abstract
|
|
144
|
-
* @param {string} sessionToken The session token to encrypt
|
|
145
|
-
* @param {Object} nonce The nonce object containing key and IV
|
|
146
|
-
* @returns {Promise<string>} The encrypted session token (base64 encoded)
|
|
147
|
-
*/
|
|
148
|
-
encryptSessionToken(): Promise<string>;
|
|
149
|
-
/**
|
|
150
|
-
* @abstract
|
|
151
|
-
* @param {string} encryptedToken The encrypted session token (base64 encoded)
|
|
152
|
-
* @param {string} privateKeyPEM The private key PEM string
|
|
153
|
-
* @returns {Promise<string>} The decrypted session token
|
|
154
|
-
*/
|
|
155
|
-
decryptSessionToken(): Promise<string>;
|
|
156
|
-
/**
|
|
157
|
-
* @abstract
|
|
158
|
-
* @param {Object} encryptedData The encrypted session data (hybrid payload object)
|
|
159
|
-
* @param {string} privateKeyPEM The private key PEM string
|
|
160
|
-
* @returns {Promise<string>} The decrypted session data
|
|
161
|
-
*/
|
|
162
|
-
decryptSessionData(): Promise<string>;
|
|
163
142
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _class,_temp;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function notImplementedStub(name){return new Error(name+" is not implemented on ICryptoAdapter.")}var ICryptoAdapter=(_temp=_class=function(){function ICryptoAdapter(){_classCallCheck(this,ICryptoAdapter)}ICryptoAdapter.prototype.decryptBytes=function decryptBytes(){throw notImplementedStub("decryptBytes(comment$: string, envelope$: string, privateKeyPEMs: string[], before: string[], after: string[]): Promise<string>")};ICryptoAdapter.prototype.decryptComment=function decryptComment(){throw notImplementedStub("decryptComment(comment$: string, envelope: string, privateKeyPEMs: string[]): Promise<string>")};ICryptoAdapter.prototype.decryptData=function decryptData(){throw notImplementedStub("decryptData(version: number, data$: string, envelope$: string, privateKeyPEMs: string[]): Promise<string>")};ICryptoAdapter.prototype.decryptFileBlock=function decryptFileBlock(){throw notImplementedStub("decryptFileBlock(data$: string, privateKeyPEMs: string[]): Promise<string>")};ICryptoAdapter.prototype.decryptImage=function decryptImage(){throw notImplementedStub("decryptImage(data$: string, privateKeyPEMs: string[]): Promise<string>")};ICryptoAdapter.prototype.decryptPrivateKey=function decryptPrivateKey(){throw notImplementedStub("decryptPrivateKey(privateKey$: string, password: string): Promise<string>")};ICryptoAdapter.prototype.encryptFileBlock=function encryptFileBlock(){throw notImplementedStub("encryptFileBlock(keyIV: {key: string, iv: string}, fileBlockBase64: string): Promise<string>")};ICryptoAdapter.prototype.encryptPrivateKey=function encryptPrivateKey(){throw notImplementedStub("encryptPrivateKey(privateKeyPEM: string, password: string): Promise<string>")};ICryptoAdapter.prototype.envelopeSeal=function envelopeSeal(){throw notImplementedStub("envelopeSeal(secret: string, publicKeyPEMs: Array<string>): Promise<string>")};ICryptoAdapter.prototype.envelopeUnseal=function envelopeUnseal(){throw notImplementedStub("envelopeUnseal(envelope: string, privateKeyPEMs: string[]): Promise<string>")};ICryptoAdapter.prototype.generateAuthorizationHeaders=function generateAuthorizationHeaders(){throw notImplementedStub("generateAuthorizationHeaders(method: string, path: string, session: Session): Promise<Object<string, string>>")};ICryptoAdapter.prototype.generateKeyIV=function generateKeyIV(){throw notImplementedStub("generateKeyIV(): Promise<{KeyIV}>")};ICryptoAdapter.prototype.generateKeyPair=function generateKeyPair(){throw notImplementedStub("generateKeyPair(): Promise<{KeyPair}>")};ICryptoAdapter.prototype.generatePasswordHash=function generatePasswordHash(){throw notImplementedStub("generatePasswordHash(password: string): Promise<string>")};ICryptoAdapter.prototype.generateWrappedSymmetricKey=function generateWrappedSymmetricKey(){throw notImplementedStub("generateWrappedSymmetricKey(serverPublicKeyPEM: string): Promise<WrappedSymmetricKey>")};ICryptoAdapter.prototype.decryptManagedPrivateKey=function decryptManagedPrivateKey(){throw notImplementedStub("decryptManagedPrivateKey(privateKey$: string, keyBase64: string): Promise<string>")};ICryptoAdapter.prototype.encryptComment=function encryptComment(){throw notImplementedStub("encryptComment(comment: string, publicKeyPEMs: Array<string>): Promise<EncryptedComment>")};ICryptoAdapter.prototype.generateCommentImportKey=function generateCommentImportKey(){throw notImplementedStub("generateCommentImportKey(serverPublicKeyPEM: string): Promise<{ key: string, key$: string }>")};ICryptoAdapter.prototype.encryptCommentImportFile=function encryptCommentImportFile(){throw notImplementedStub("encryptCommentImportFile(key: string, fileBase64: string): Promise<string>")};
|
|
1
|
+
"use strict";exports.__esModule=true;var _class,_temp;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function notImplementedStub(name){return new Error(name+" is not implemented on ICryptoAdapter.")}var ICryptoAdapter=(_temp=_class=function(){function ICryptoAdapter(){_classCallCheck(this,ICryptoAdapter)}ICryptoAdapter.prototype.decryptBytes=function decryptBytes(){throw notImplementedStub("decryptBytes(comment$: string, envelope$: string, privateKeyPEMs: string[], before: string[], after: string[]): Promise<string>")};ICryptoAdapter.prototype.decryptComment=function decryptComment(){throw notImplementedStub("decryptComment(comment$: string, envelope: string, privateKeyPEMs: string[]): Promise<string>")};ICryptoAdapter.prototype.decryptData=function decryptData(){throw notImplementedStub("decryptData(version: number, data$: string, envelope$: string, privateKeyPEMs: string[]): Promise<string>")};ICryptoAdapter.prototype.decryptFileBlock=function decryptFileBlock(){throw notImplementedStub("decryptFileBlock(data$: string, privateKeyPEMs: string[]): Promise<string>")};ICryptoAdapter.prototype.decryptImage=function decryptImage(){throw notImplementedStub("decryptImage(data$: string, privateKeyPEMs: string[]): Promise<string>")};ICryptoAdapter.prototype.decryptPrivateKey=function decryptPrivateKey(){throw notImplementedStub("decryptPrivateKey(privateKey$: string, password: string): Promise<string>")};ICryptoAdapter.prototype.encryptFileBlock=function encryptFileBlock(){throw notImplementedStub("encryptFileBlock(keyIV: {key: string, iv: string}, fileBlockBase64: string): Promise<string>")};ICryptoAdapter.prototype.encryptPrivateKey=function encryptPrivateKey(){throw notImplementedStub("encryptPrivateKey(privateKeyPEM: string, password: string): Promise<string>")};ICryptoAdapter.prototype.envelopeSeal=function envelopeSeal(){throw notImplementedStub("envelopeSeal(secret: string, publicKeyPEMs: Array<string>): Promise<string>")};ICryptoAdapter.prototype.envelopeUnseal=function envelopeUnseal(){throw notImplementedStub("envelopeUnseal(envelope: string, privateKeyPEMs: string[]): Promise<string>")};ICryptoAdapter.prototype.generateAuthorizationHeaders=function generateAuthorizationHeaders(){throw notImplementedStub("generateAuthorizationHeaders(method: string, path: string, session: Session): Promise<Object<string, string>>")};ICryptoAdapter.prototype.generateKeyIV=function generateKeyIV(){throw notImplementedStub("generateKeyIV(): Promise<{KeyIV}>")};ICryptoAdapter.prototype.generateKeyPair=function generateKeyPair(){throw notImplementedStub("generateKeyPair(): Promise<{KeyPair}>")};ICryptoAdapter.prototype.generatePasswordHash=function generatePasswordHash(){throw notImplementedStub("generatePasswordHash(password: string): Promise<string>")};ICryptoAdapter.prototype.generateWrappedSymmetricKey=function generateWrappedSymmetricKey(){throw notImplementedStub("generateWrappedSymmetricKey(serverPublicKeyPEM: string): Promise<WrappedSymmetricKey>")};ICryptoAdapter.prototype.decryptManagedPrivateKey=function decryptManagedPrivateKey(){throw notImplementedStub("decryptManagedPrivateKey(privateKey$: string, keyBase64: string): Promise<string>")};ICryptoAdapter.prototype.encryptComment=function encryptComment(){throw notImplementedStub("encryptComment(comment: string, publicKeyPEMs: Array<string>): Promise<EncryptedComment>")};ICryptoAdapter.prototype.generateCommentImportKey=function generateCommentImportKey(){throw notImplementedStub("generateCommentImportKey(serverPublicKeyPEM: string): Promise<{ key: string, key$: string }>")};ICryptoAdapter.prototype.encryptCommentImportFile=function encryptCommentImportFile(){throw notImplementedStub("encryptCommentImportFile(key: string, fileBase64: string): Promise<string>")};return ICryptoAdapter}(),_class.__adapter__="ICryptoAdapter",_temp);exports.default=ICryptoAdapter;
|
|
@@ -118,24 +118,6 @@ declare class SchedulerCryptoAdapter extends ICryptoAdapter {
|
|
|
118
118
|
* @returns {Promise<string>} The encrypted block, base64 encoded
|
|
119
119
|
*/
|
|
120
120
|
encryptCommentImportFile(key: string, fileBase64: string): Promise<string>;
|
|
121
|
-
/**
|
|
122
|
-
* @param {string} sessionToken The session token to encrypt
|
|
123
|
-
* @param {Object} nonce The nonce object containing key and IV
|
|
124
|
-
* @returns {Promise<string>} The encrypted session token (base64 encoded)
|
|
125
|
-
*/
|
|
126
|
-
encryptSessionToken(sessionToken: string, nonce: any): Promise<string>;
|
|
127
|
-
/**
|
|
128
|
-
* @param {string} encryptedToken The encrypted session token (base64 encoded)
|
|
129
|
-
* @param {string} privateKeyPEM The private key PEM string
|
|
130
|
-
* @returns {Promise<string>} The decrypted session token
|
|
131
|
-
*/
|
|
132
|
-
decryptSessionToken(encryptedToken: string, privateKeyPEM: string): Promise<string>;
|
|
133
|
-
/**
|
|
134
|
-
* @param {Object} encryptedData The encrypted session data (hybrid payload object)
|
|
135
|
-
* @param {string} privateKeyPEM The private key PEM string
|
|
136
|
-
* @returns {Promise<string>} The decrypted session data
|
|
137
|
-
*/
|
|
138
|
-
decryptSessionData(encryptedData: any, privateKeyPEM: string): Promise<string>;
|
|
139
121
|
}
|
|
140
122
|
import ICryptoAdapter from "./ICryptoAdapter";
|
|
141
123
|
import Scheduler from "../util/Scheduler";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _Scheduler=require("../util/Scheduler");var _Scheduler2=_interopRequireDefault(_Scheduler);var _ICryptoAdapter2=require("./ICryptoAdapter");var _ICryptoAdapter3=_interopRequireDefault(_ICryptoAdapter2);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 SchedulerCryptoAdapter=function(_ICryptoAdapter){_inherits(SchedulerCryptoAdapter,_ICryptoAdapter);function SchedulerCryptoAdapter(options){_classCallCheck(this,SchedulerCryptoAdapter);var _this=_possibleConstructorReturn(this,_ICryptoAdapter.call(this));_this.scheduler=new _Scheduler2.default(options);return _this}SchedulerCryptoAdapter.prototype.decryptBytes=function decryptBytes(comment$,envelope$,privateKeyPEMs,before,after){return this.scheduler.send({type:"decryptBytes",args:[comment$,envelope$,privateKeyPEMs,before,after]})};SchedulerCryptoAdapter.prototype.decryptComment=function decryptComment(comment$,envelope,privateKeyPEMs){return this.scheduler.send({type:"decryptComment",args:[comment$,envelope,privateKeyPEMs]})};SchedulerCryptoAdapter.prototype.decryptData=function decryptData(version,data$,envelope$,privateKeyPEMs){return this.scheduler.send({type:"decryptData",args:[version,data$,envelope$,privateKeyPEMs]})};SchedulerCryptoAdapter.prototype.decryptFileBlock=function decryptFileBlock(data$,privateKeyPEMs){return this.scheduler.send({type:"decryptFileBlock",args:[data$,privateKeyPEMs]})};SchedulerCryptoAdapter.prototype.decryptImage=function decryptImage(data$,privateKeyPEMs){return this.scheduler.send({type:"decryptImage",args:[data$,privateKeyPEMs]})};SchedulerCryptoAdapter.prototype.decryptPrivateKey=function decryptPrivateKey(privateKey$,password){return this.scheduler.send({type:"decryptPrivateKey",args:[privateKey$,password]})};SchedulerCryptoAdapter.prototype.encryptFileBlock=function encryptFileBlock(keyIV,fileBlock,decodeBlock){return this.scheduler.send({type:"encryptFileBlock",args:[keyIV,fileBlock,decodeBlock]})};SchedulerCryptoAdapter.prototype.encryptPrivateKey=function encryptPrivateKey(privateKeyPEM,password){return this.scheduler.send({type:"encryptPrivateKey",args:[privateKeyPEM,password]})};SchedulerCryptoAdapter.prototype.envelopeSeal=function envelopeSeal(secret,publicKeyPEMs){return this.scheduler.send({type:"envelopeSeal",args:[secret,publicKeyPEMs]})};SchedulerCryptoAdapter.prototype.envelopeUnseal=function envelopeUnseal(envelope,privateKeyPEMs){return this.scheduler.send({type:"envelopeUnseal",args:[envelope,privateKeyPEMs]})};SchedulerCryptoAdapter.prototype.generateAuthorizationHeaders=function generateAuthorizationHeaders(method,path,session){return this.scheduler.send({type:"generateAuthorizationHeaders",args:[method,path,session]})};SchedulerCryptoAdapter.prototype.generateKeyIV=function generateKeyIV(){return this.scheduler.send({type:"generateKeyIV"})};SchedulerCryptoAdapter.prototype.generateKeyPair=function generateKeyPair(){return this.scheduler.send({type:"generateKeyPair"})};SchedulerCryptoAdapter.prototype.generatePasswordHash=function generatePasswordHash(password){return this.scheduler.send({type:"generatePasswordHash",args:[password]})};SchedulerCryptoAdapter.prototype.generateWrappedSymmetricKey=function generateWrappedSymmetricKey(serverPublicKeyPEM){return this.scheduler.send({type:"generateWrappedSymmetricKey",args:[serverPublicKeyPEM]})};SchedulerCryptoAdapter.prototype.decryptManagedPrivateKey=function decryptManagedPrivateKey(privateKey$,keyBase64){return this.scheduler.send({type:"decryptManagedPrivateKey",args:[privateKey$,keyBase64]})};SchedulerCryptoAdapter.prototype.encryptComment=function encryptComment(comment,publicKeyPEMs){return this.scheduler.send({type:"encryptComment",args:[comment,publicKeyPEMs]})};SchedulerCryptoAdapter.prototype.generateCommentImportKey=function generateCommentImportKey(serverPublicKeyPEM){return this.scheduler.send({type:"generateCommentImportKey",args:[serverPublicKeyPEM]})};SchedulerCryptoAdapter.prototype.encryptCommentImportFile=function encryptCommentImportFile(key,fileBase64){return this.scheduler.send({type:"encryptCommentImportFile",args:[key,fileBase64]})};
|
|
1
|
+
"use strict";exports.__esModule=true;var _Scheduler=require("../util/Scheduler");var _Scheduler2=_interopRequireDefault(_Scheduler);var _ICryptoAdapter2=require("./ICryptoAdapter");var _ICryptoAdapter3=_interopRequireDefault(_ICryptoAdapter2);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 SchedulerCryptoAdapter=function(_ICryptoAdapter){_inherits(SchedulerCryptoAdapter,_ICryptoAdapter);function SchedulerCryptoAdapter(options){_classCallCheck(this,SchedulerCryptoAdapter);var _this=_possibleConstructorReturn(this,_ICryptoAdapter.call(this));_this.scheduler=new _Scheduler2.default(options);return _this}SchedulerCryptoAdapter.prototype.decryptBytes=function decryptBytes(comment$,envelope$,privateKeyPEMs,before,after){return this.scheduler.send({type:"decryptBytes",args:[comment$,envelope$,privateKeyPEMs,before,after]})};SchedulerCryptoAdapter.prototype.decryptComment=function decryptComment(comment$,envelope,privateKeyPEMs){return this.scheduler.send({type:"decryptComment",args:[comment$,envelope,privateKeyPEMs]})};SchedulerCryptoAdapter.prototype.decryptData=function decryptData(version,data$,envelope$,privateKeyPEMs){return this.scheduler.send({type:"decryptData",args:[version,data$,envelope$,privateKeyPEMs]})};SchedulerCryptoAdapter.prototype.decryptFileBlock=function decryptFileBlock(data$,privateKeyPEMs){return this.scheduler.send({type:"decryptFileBlock",args:[data$,privateKeyPEMs]})};SchedulerCryptoAdapter.prototype.decryptImage=function decryptImage(data$,privateKeyPEMs){return this.scheduler.send({type:"decryptImage",args:[data$,privateKeyPEMs]})};SchedulerCryptoAdapter.prototype.decryptPrivateKey=function decryptPrivateKey(privateKey$,password){return this.scheduler.send({type:"decryptPrivateKey",args:[privateKey$,password]})};SchedulerCryptoAdapter.prototype.encryptFileBlock=function encryptFileBlock(keyIV,fileBlock,decodeBlock){return this.scheduler.send({type:"encryptFileBlock",args:[keyIV,fileBlock,decodeBlock]})};SchedulerCryptoAdapter.prototype.encryptPrivateKey=function encryptPrivateKey(privateKeyPEM,password){return this.scheduler.send({type:"encryptPrivateKey",args:[privateKeyPEM,password]})};SchedulerCryptoAdapter.prototype.envelopeSeal=function envelopeSeal(secret,publicKeyPEMs){return this.scheduler.send({type:"envelopeSeal",args:[secret,publicKeyPEMs]})};SchedulerCryptoAdapter.prototype.envelopeUnseal=function envelopeUnseal(envelope,privateKeyPEMs){return this.scheduler.send({type:"envelopeUnseal",args:[envelope,privateKeyPEMs]})};SchedulerCryptoAdapter.prototype.generateAuthorizationHeaders=function generateAuthorizationHeaders(method,path,session){return this.scheduler.send({type:"generateAuthorizationHeaders",args:[method,path,session]})};SchedulerCryptoAdapter.prototype.generateKeyIV=function generateKeyIV(){return this.scheduler.send({type:"generateKeyIV"})};SchedulerCryptoAdapter.prototype.generateKeyPair=function generateKeyPair(){return this.scheduler.send({type:"generateKeyPair"})};SchedulerCryptoAdapter.prototype.generatePasswordHash=function generatePasswordHash(password){return this.scheduler.send({type:"generatePasswordHash",args:[password]})};SchedulerCryptoAdapter.prototype.generateWrappedSymmetricKey=function generateWrappedSymmetricKey(serverPublicKeyPEM){return this.scheduler.send({type:"generateWrappedSymmetricKey",args:[serverPublicKeyPEM]})};SchedulerCryptoAdapter.prototype.decryptManagedPrivateKey=function decryptManagedPrivateKey(privateKey$,keyBase64){return this.scheduler.send({type:"decryptManagedPrivateKey",args:[privateKey$,keyBase64]})};SchedulerCryptoAdapter.prototype.encryptComment=function encryptComment(comment,publicKeyPEMs){return this.scheduler.send({type:"encryptComment",args:[comment,publicKeyPEMs]})};SchedulerCryptoAdapter.prototype.generateCommentImportKey=function generateCommentImportKey(serverPublicKeyPEM){return this.scheduler.send({type:"generateCommentImportKey",args:[serverPublicKeyPEM]})};SchedulerCryptoAdapter.prototype.encryptCommentImportFile=function encryptCommentImportFile(key,fileBase64){return this.scheduler.send({type:"encryptCommentImportFile",args:[key,fileBase64]})};return SchedulerCryptoAdapter}(_ICryptoAdapter3.default);exports.default=SchedulerCryptoAdapter;
|
|
@@ -101,23 +101,5 @@ declare class SyncCryptoAdapter extends ICryptoAdapter {
|
|
|
101
101
|
* @returns {Promise<EncryptedComment>} The encrypted comment and envelope
|
|
102
102
|
*/
|
|
103
103
|
encryptComment(comment: string, publicKeyPEMs: string[]): Promise<EncryptedComment>;
|
|
104
|
-
/**
|
|
105
|
-
* @param {string} sessionToken The session token to encrypt
|
|
106
|
-
* @param {Object} nonce The nonce object containing key and IV
|
|
107
|
-
* @returns {Promise<string>} The encrypted session token (base64 encoded)
|
|
108
|
-
*/
|
|
109
|
-
encryptSessionToken(sessionToken: string, nonce: any): Promise<string>;
|
|
110
|
-
/**
|
|
111
|
-
* @param {string} encryptedToken The encrypted session token (base64 encoded)
|
|
112
|
-
* @param {string} privateKeyPEM The private key PEM string
|
|
113
|
-
* @returns {Promise<string>} The decrypted session token
|
|
114
|
-
*/
|
|
115
|
-
decryptSessionToken(encryptedToken: string, privateKeyPEM: string): Promise<string>;
|
|
116
|
-
/**
|
|
117
|
-
* @param {Object} encryptedData The encrypted session data (hybrid payload object)
|
|
118
|
-
* @param {string} privateKeyPEM The private key PEM string
|
|
119
|
-
* @returns {Promise<string>} The decrypted session data
|
|
120
|
-
*/
|
|
121
|
-
decryptSessionData(encryptedData: any, privateKeyPEM: string): Promise<string>;
|
|
122
104
|
}
|
|
123
105
|
import ICryptoAdapter from "./ICryptoAdapter";
|
|
@@ -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.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)};
|
|
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;
|
package/lib/api/AccountsSSO.d.ts
CHANGED
|
@@ -5,12 +5,6 @@ export default AccountsSSO;
|
|
|
5
5
|
* SSO is a PageProof for Enterprise offering, but is not yet included for SDK licenses. Logging in
|
|
6
6
|
* via SSO creates sessions that can only be used in the PageProof web-app. If you need SSO, please
|
|
7
7
|
* contact us and we will assist you where we can.
|
|
8
|
-
*
|
|
9
|
-
* For device authentication flows using isolated login:
|
|
10
|
-
* - Set the ISOLATED_AUTH_PRIVATE_KEY environment variable to your RSA private certificate (PEM format, base64 encoded) - Provided by PageProof
|
|
11
|
-
* - The sessionToken from getIsolatedLoginStatus() will be automatically decrypted
|
|
12
|
-
* - The session data from getIsolatedLoginSession() will be automatically decrypted
|
|
13
|
-
* - Uses CryptoAlgorithm.RSA_OAEP for simple RSA or CryptoAlgorithm.RSA_AES_GCM for hybrid encryption
|
|
14
8
|
*/
|
|
15
9
|
declare class AccountsSSO extends API {
|
|
16
10
|
constructor(client: any);
|
|
@@ -28,37 +22,7 @@ declare class AccountsSSO extends API {
|
|
|
28
22
|
* @private
|
|
29
23
|
* @returns {Promise}
|
|
30
24
|
*/
|
|
31
|
-
initiateLogin(email: any
|
|
32
|
-
/**
|
|
33
|
-
* Polls the status of a login using the device flow where authentication is completed via an isolated browser session.
|
|
34
|
-
* If the authentication has been completed, a session token is returned which can be used to retrieve the session data.
|
|
35
|
-
* The session token is only returned once, further polling will not return a session token.
|
|
36
|
-
* The session token is decrypted using the private key, then encrypted using the nonce provided by the server.
|
|
37
|
-
*
|
|
38
|
-
* This method requires a base64 encoded private key to be set in the `ISOLATED_AUTH_PRIVATE_KEY` environment variable.
|
|
39
|
-
* The key is provided by PageProof and is pre-registered against your source id.
|
|
40
|
-
*
|
|
41
|
-
* @private
|
|
42
|
-
* @param {string} email
|
|
43
|
-
* @param {string} sessionId - The session id of the login as a UUID
|
|
44
|
-
* @param {string} source - The source id of your application
|
|
45
|
-
* @returns {Promise<IsolatedLoginStatusResult>}
|
|
46
|
-
*/
|
|
47
|
-
getIsolatedLoginStatus(email: string, sessionId: string, applicationId: any): Promise<IsolatedLoginStatusResult>;
|
|
48
|
-
/**
|
|
49
|
-
* Retrieves the session data for an isolated login.
|
|
50
|
-
* A session token is required to retrieve the session data. This is obtained from the {@link AccountsSSO#getIsolatedLoginStatus} method.
|
|
51
|
-
*
|
|
52
|
-
* This method requires a base64 encoded private key to be set in the `ISOLATED_AUTH_PRIVATE_KEY` environment variable.
|
|
53
|
-
* The key is provided by PageProof and is pre-registered against your source id.
|
|
54
|
-
*
|
|
55
|
-
* @private
|
|
56
|
-
* @param {string} sessionId - The session id of the login as a UUID
|
|
57
|
-
* @param {string} source - The source id of your application
|
|
58
|
-
* @param {string} encryptedSessionToken - The nonce-encrypted session token, obtained from the {@link AccountsSSO#getIsolatedLoginStatus} method
|
|
59
|
-
* @returns {Promise<Session>}
|
|
60
|
-
*/
|
|
61
|
-
getIsolatedLoginSession(sessionId: string, applicationId: any, encryptedSessionToken: string): Promise<Session>;
|
|
25
|
+
initiateLogin(email: any): Promise<any>;
|
|
62
26
|
}
|
|
63
27
|
import API from "./API";
|
|
64
28
|
import Session from "../models/Session";
|
package/lib/api/AccountsSSO.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var
|
|
1
|
+
"use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _Session=require("../models/Session");var _Session2=_interopRequireDefault(_Session);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 AccountsSSO=function(_API){_inherits(AccountsSSO,_API);function AccountsSSO(){_classCallCheck(this,AccountsSSO);return _possibleConstructorReturn(this,_API.apply(this,arguments))}AccountsSSO.prototype.getSession=function getSession(){var _this2=this;return this.client.request("sso.get-public-key").then(function(response){return response.data.ServerPublicKey}).then(function(serverPublicKey){return _this2.client.crypto().generateWrappedSymmetricKey(serverPublicKey)}).then(function(_ref){var key=_ref.key,key$=_ref.key$;return Promise.all([key,_this2.client.request("sso.get-session",{nonce:key$})])}).then(function(_ref2){var key=_ref2[0],response=_ref2[1];var session=(new _Session2.default).fromSession(response.data);return Promise.all([session,_this2.client.crypto().decryptManagedPrivateKey(session.privateKeyPEM$,key)])}).then(function(_ref3){var session=_ref3[0],privateKeyPEM=_ref3[1];session.privateKeyPEM=privateKeyPEM;return session})};AccountsSSO.prototype.getLoginOptions=function getLoginOptions(email){return this.client.request("sso.get-login-options",{email:email}).then(function(response){return response.data})};AccountsSSO.prototype.initiateLogin=function initiateLogin(email){return this.client.request("sso.initiate-login",{email:email}).then(function(response){return response.data})};return AccountsSSO}(_API3.default);exports.default=AccountsSSO;
|
package/lib/api/Files.d.ts
CHANGED
|
@@ -391,6 +391,35 @@ declare class Files extends API {
|
|
|
391
391
|
* @returns {Promise<FileV2>}
|
|
392
392
|
*/
|
|
393
393
|
duplicate(id: string): Promise<FileV2>;
|
|
394
|
+
/**
|
|
395
|
+
* Downloads one or more external files from URLs
|
|
396
|
+
*
|
|
397
|
+
* @example <caption>Download a single file from an external URL</caption>
|
|
398
|
+
* const fileBlob = await client.files.downloadExternalFile('https://example.com/file.pdf');
|
|
399
|
+
*
|
|
400
|
+
* @example <caption>Download multiple files</caption>
|
|
401
|
+
* const fileBlobs = await client.files.downloadExternalFile([
|
|
402
|
+
* 'https://example.com/file1.pdf',
|
|
403
|
+
* 'https://example.com/file2.png'
|
|
404
|
+
* ]);
|
|
405
|
+
*
|
|
406
|
+
* @param {string|string[]} urls The URL(s) of the file(s) to download
|
|
407
|
+
* @returns {Promise<Blob|Buffer|Array<Blob|Buffer>>} The downloaded file(s) as blob(s)/buffer(s)
|
|
408
|
+
*/
|
|
409
|
+
downloadExternalFile(urls: string | string[]): Promise<Blob | Buffer | (Blob | Buffer)[]>;
|
|
410
|
+
/**
|
|
411
|
+
* Downloads and compresses multiple external files into a ZIP
|
|
412
|
+
*
|
|
413
|
+
* @example <caption>Download and compress multiple files</caption>
|
|
414
|
+
* const zipBlob = await client.files.compressExternalFiles([
|
|
415
|
+
* 'https://example.com/file1.pdf',
|
|
416
|
+
* 'https://example.com/file2.png'
|
|
417
|
+
* ]);
|
|
418
|
+
*
|
|
419
|
+
* @param {string[]} urls Array of file URLs to download and compress
|
|
420
|
+
* @returns {Promise<Blob|Buffer>} The compressed ZIP file as a blob or buffer
|
|
421
|
+
*/
|
|
422
|
+
compressExternalFiles(urls: string[]): Promise<Blob | Buffer>;
|
|
394
423
|
}
|
|
395
424
|
import API from "./API";
|
|
396
425
|
import File from "../models/File";
|
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 _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);var _fileValidation=require("../util/fileValidation");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 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=(0,_fileValidation.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 filesWithParsedNames=void 0;try{filesWithParsedNames=(0,_fileValidation.prepareFilesForUpload)(filesList)}catch(error){return Promise.reject(error)}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:filesWithParsedNames.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 _ref7=[file.parsedFilename.name,file.parsedFilename.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(filesWithParsedNames.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;var parsedFilename=void 0;try{parsedFilename=(0,_fileValidation.parseFilename)(name)}catch(error){return Promise.reject(error)}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({parsedFilename:parsedFilename,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 parsedFilename=_ref11.parsedFilename,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 filename=parsedFilename.name,extension=parsedFilename.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;
|
|
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);var _fileValidation=require("../util/fileValidation");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 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=(0,_fileValidation.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 filesWithParsedNames=void 0;try{filesWithParsedNames=(0,_fileValidation.prepareFilesForUpload)(filesList)}catch(error){return Promise.reject(error)}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:filesWithParsedNames.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 _ref7=[file.parsedFilename.name,file.parsedFilename.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(filesWithParsedNames.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;var parsedFilename=void 0;try{parsedFilename=(0,_fileValidation.parseFilename)(name)}catch(error){return Promise.reject(error)}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({parsedFilename:parsedFilename,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 parsedFilename=_ref11.parsedFilename,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 filename=parsedFilename.name,extension=parsedFilename.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})};Files.prototype.downloadExternalFile=function downloadExternalFile(urls){var _this18=this;if(Array.isArray(urls)){return Promise.all(urls.map(function(url){return _this18.downloadExternalFile(url)}))}var encodedUrl=encodeURIComponent(urls);return this.client.request("files.download-external-file",{encodedUrls:encodedUrl},{bluffer:true}).then(function(response){return response.data})};Files.prototype.compressExternalFiles=function compressExternalFiles(urls){var encodedUrls=urls.map(function(url){return encodeURIComponent(url)}).join(",");return this.client.request("files.compress-external-files",{encodedUrls:encodedUrls},{bluffer:true}).then(function(response){return response.data})};return Files}(_API3.default);exports.default=Files;
|
package/lib/crypto/index.d.ts
CHANGED
|
@@ -17,7 +17,4 @@ import encryptComment from "./encryptComment";
|
|
|
17
17
|
import decryptBytes from "./decryptBytes";
|
|
18
18
|
import generateCommentImportKey from "./generateCommentImportKey";
|
|
19
19
|
import encryptCommentImportFile from "./encryptCommentImportFile";
|
|
20
|
-
|
|
21
|
-
import { decryptSessionToken } from "./authServerEncryption";
|
|
22
|
-
import { decryptSessionData } from "./authServerEncryption";
|
|
23
|
-
export { decryptComment, decryptData, decryptFileBlock, decryptImage, decryptPrivateKey, encryptFileBlock, encryptPrivateKey, envelopeSeal, envelopeUnseal, generateAuthorizationHeaders, generateKeyIV, generateKeyPair, generatePasswordHash, generateWrappedSymmetricKey, decryptManagedPrivateKey, encryptComment, decryptBytes, generateCommentImportKey, encryptCommentImportFile, encryptSessionToken, decryptSessionToken, decryptSessionData };
|
|
20
|
+
export { decryptComment, decryptData, decryptFileBlock, decryptImage, decryptPrivateKey, encryptFileBlock, encryptPrivateKey, envelopeSeal, envelopeUnseal, generateAuthorizationHeaders, generateKeyIV, generateKeyPair, generatePasswordHash, generateWrappedSymmetricKey, decryptManagedPrivateKey, encryptComment, decryptBytes, generateCommentImportKey, encryptCommentImportFile };
|
package/lib/crypto/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;exports.
|
|
1
|
+
"use strict";exports.__esModule=true;exports.encryptCommentImportFile=exports.generateCommentImportKey=exports.decryptBytes=exports.encryptComment=exports.decryptManagedPrivateKey=exports.generateWrappedSymmetricKey=exports.generatePasswordHash=exports.generateKeyPair=exports.generateKeyIV=exports.generateAuthorizationHeaders=exports.envelopeUnseal=exports.envelopeSeal=exports.encryptPrivateKey=exports.encryptFileBlock=exports.decryptPrivateKey=exports.decryptImage=exports.decryptFileBlock=exports.decryptData=exports.decryptComment=undefined;var _decryptComment=require("./decryptComment");var _decryptComment2=_interopRequireDefault(_decryptComment);var _decryptData=require("./decryptData");var _decryptData2=_interopRequireDefault(_decryptData);var _decryptFileBlock=require("./decryptFileBlock");var _decryptFileBlock2=_interopRequireDefault(_decryptFileBlock);var _decryptImage=require("./decryptImage");var _decryptImage2=_interopRequireDefault(_decryptImage);var _decryptPrivateKey=require("./decryptPrivateKey");var _decryptPrivateKey2=_interopRequireDefault(_decryptPrivateKey);var _encryptFileBlock=require("./encryptFileBlock");var _encryptFileBlock2=_interopRequireDefault(_encryptFileBlock);var _encryptPrivateKey=require("./encryptPrivateKey");var _encryptPrivateKey2=_interopRequireDefault(_encryptPrivateKey);var _envelopes=require("./envelopes");var _generateAuthorizationHeaders=require("./generateAuthorizationHeaders");var _generateAuthorizationHeaders2=_interopRequireDefault(_generateAuthorizationHeaders);var _generateKeyIV=require("./generateKeyIV");var _generateKeyIV2=_interopRequireDefault(_generateKeyIV);var _generateKeyPair=require("./generateKeyPair");var _generateKeyPair2=_interopRequireDefault(_generateKeyPair);var _generatePasswordHash=require("./generatePasswordHash");var _generatePasswordHash2=_interopRequireDefault(_generatePasswordHash);var _generateWrappedSymmetricKey=require("./generateWrappedSymmetricKey");var _generateWrappedSymmetricKey2=_interopRequireDefault(_generateWrappedSymmetricKey);var _decryptManagedPrivateKey=require("./decryptManagedPrivateKey");var _decryptManagedPrivateKey2=_interopRequireDefault(_decryptManagedPrivateKey);var _encryptComment=require("./encryptComment");var _encryptComment2=_interopRequireDefault(_encryptComment);var _decryptBytes=require("./decryptBytes");var _decryptBytes2=_interopRequireDefault(_decryptBytes);var _generateCommentImportKey=require("./generateCommentImportKey");var _generateCommentImportKey2=_interopRequireDefault(_generateCommentImportKey);var _encryptCommentImportFile=require("./encryptCommentImportFile");var _encryptCommentImportFile2=_interopRequireDefault(_encryptCommentImportFile);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.decryptComment=_decryptComment2.default;exports.decryptData=_decryptData2.default;exports.decryptFileBlock=_decryptFileBlock2.default;exports.decryptImage=_decryptImage2.default;exports.decryptPrivateKey=_decryptPrivateKey2.default;exports.encryptFileBlock=_encryptFileBlock2.default;exports.encryptPrivateKey=_encryptPrivateKey2.default;exports.envelopeSeal=_envelopes.envelopeSeal;exports.envelopeUnseal=_envelopes.envelopeUnseal;exports.generateAuthorizationHeaders=_generateAuthorizationHeaders2.default;exports.generateKeyIV=_generateKeyIV2.default;exports.generateKeyPair=_generateKeyPair2.default;exports.generatePasswordHash=_generatePasswordHash2.default;exports.generateWrappedSymmetricKey=_generateWrappedSymmetricKey2.default;exports.decryptManagedPrivateKey=_decryptManagedPrivateKey2.default;exports.encryptComment=_encryptComment2.default;exports.decryptBytes=_decryptBytes2.default;exports.generateCommentImportKey=_generateCommentImportKey2.default;exports.encryptCommentImportFile=_encryptCommentImportFile2.default;
|
|
@@ -489,6 +489,16 @@
|
|
|
489
489
|
"chain": ["proofId", "fileId", "block"],
|
|
490
490
|
"query": ["s"]
|
|
491
491
|
},
|
|
492
|
+
"files.compress-external-files": {
|
|
493
|
+
"method": "GET",
|
|
494
|
+
"path": "/api/media/compressExternalFiles",
|
|
495
|
+
"chain": ["encodedUrls"]
|
|
496
|
+
},
|
|
497
|
+
"files.download-external-file": {
|
|
498
|
+
"method": "GET",
|
|
499
|
+
"path": "/api/media/downloadExternalFile",
|
|
500
|
+
"chain": ["encodedUrls"]
|
|
501
|
+
},
|
|
492
502
|
"files.thumbnail": {
|
|
493
503
|
"method": "GET",
|
|
494
504
|
"path": "/api/media/getimage/thumb",
|
|
@@ -999,21 +1009,7 @@
|
|
|
999
1009
|
"version": 2,
|
|
1000
1010
|
"method": "POST",
|
|
1001
1011
|
"path": "/sso/initiate_login",
|
|
1002
|
-
"body": ["email"
|
|
1003
|
-
"anonymous": true
|
|
1004
|
-
},
|
|
1005
|
-
"sso.get-isolated-login-status": {
|
|
1006
|
-
"version": 2,
|
|
1007
|
-
"method": "POST",
|
|
1008
|
-
"path": "/sso/isolated/status",
|
|
1009
|
-
"body": ["email", "sessionId", "applicationId"],
|
|
1010
|
-
"anonymous": true
|
|
1011
|
-
},
|
|
1012
|
-
"sso.get-isolated-login-session": {
|
|
1013
|
-
"version": 2,
|
|
1014
|
-
"method": "POST",
|
|
1015
|
-
"path": "/sso/isolated/session",
|
|
1016
|
-
"body": ["sessionId", "applicationId", "encryptedSessionToken", "nonce"],
|
|
1012
|
+
"body": ["email"],
|
|
1017
1013
|
"anonymous": true
|
|
1018
1014
|
},
|
|
1019
1015
|
"mfa.setup": {
|