@pageproof/sdk-pr 397.0.1639966264149 → 397.0.1644379353206
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +109 -0
- package/README.md +1 -0
- package/lib/api/Accounts.d.ts +9 -1
- package/lib/api/Accounts.js +1 -1
- package/lib/api/AccountsMFA.d.ts +28 -0
- package/lib/api/AccountsMFA.js +1 -0
- package/lib/api/Comments.d.ts +73 -24
- package/lib/api/Comments.js +1 -1
- package/lib/api/admin/TeamFeatures.d.ts +5 -1
- package/lib/api/admin/TeamFeatures.js +5 -1
- package/lib/models/Comment.d.ts +33 -4
- package/lib/models/Comment.js +1 -1
- package/lib/models/User.d.ts +6 -0
- package/lib/models/User.js +1 -1
- package/lib/models/index.d.ts +1 -2
- package/lib/models/index.js +1 -1
- package/lib/network/endpoints.json +15 -1
- package/lib/pageproof.js +1 -1
- package/lib/types/Pin.d.ts +33 -0
- package/lib/types/Pin.js +1 -0
- package/lib/util/exports.d.ts +6 -0
- package/lib/util/exports.js +1 -1
- package/lib/util/pins/parsePins.d.ts +1 -0
- package/lib/util/pins/parsePins.js +78 -0
- package/lib/util/pins/serializePins.d.ts +1 -0
- package/lib/util/pins/serializePins.js +51 -0
- package/lib/util/pins/utils.d.ts +3 -0
- package/lib/util/pins/utils.js +18 -0
- package/package.json +1 -1
- package/lib/models/Pin.d.ts +0 -43
- package/lib/models/Pin.js +0 -1
- package/lib/models/PinFill.d.ts +0 -16
- package/lib/models/PinFill.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,114 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.287
|
|
4
|
+
|
|
5
|
+
Released on the 9th of February 2022.
|
|
6
|
+
|
|
7
|
+
- [[PP-1644](https://goto.pageproof.dev/PP-1644)] Added support for customizing email link and button colors. See [TeamEmailFeatures](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/models/TeamEmailFeatures.js~TeamEmailFeatures.html) and [TeamFeatures.update](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/admin/TeamFeatures.js~TeamFeatures.html#instance-method-update).
|
|
8
|
+
|
|
9
|
+
## 2.0.0-beta.286
|
|
10
|
+
|
|
11
|
+
Released on the 2nd of February 2022.
|
|
12
|
+
|
|
13
|
+
- [[PP-1654](https://goto.pageproof.dev/PP-1654)] Added support for enterprise teams to reset their custom email address. See [TeamFeatures.setSenderEmail](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/admin/TeamFeatures.js~TeamFeatures.html#instance-method-setSenderEmail).
|
|
14
|
+
|
|
15
|
+
## 2.0.0-beta.285
|
|
16
|
+
|
|
17
|
+
Released on the 1st of February 2022.
|
|
18
|
+
|
|
19
|
+
_This release contains nothing new._
|
|
20
|
+
|
|
21
|
+
## 2.0.0-beta.284
|
|
22
|
+
|
|
23
|
+
Released on the 23rd of December 2021.
|
|
24
|
+
|
|
25
|
+
This release introduces support for comments with multiple pins. This means it's now possible to create a comment that has more than one pin (previously the limit). Because of this, we've made some changes that you'll want to know about, to ensure your transition to this version (and subsequent versions) are as seamless as possible.
|
|
26
|
+
|
|
27
|
+
We've removed the following things:
|
|
28
|
+
- The `Pin` and `PinFill` models have been removed. The objects you get by accessing pin fields now return a plain JavaScript object instead of an instance of the `Pin` class. The fields on this object are no different than before - but if you were previously checking the prototype of these objects, these checks will now produce a false-negative.
|
|
29
|
+
|
|
30
|
+
We're pretty confident that this change should have little to no impact on your integration with PageProof. And if you currently use the SDK sidecar, absolutely no impact whatsoever. This is highly edge-case.
|
|
31
|
+
|
|
32
|
+
We've deprecated a few model properties:
|
|
33
|
+
- The `Comment` model
|
|
34
|
+
- The `pin` property has been replaced by the new `pins` property. This property is an array of pins attached to the comment. As mentioned above, the objects you get from this array is a plain JavaScript object - but contains all the same properties. Accessing the deprecated `pin` property will yield the first pin attached to the comment - for backwards compatibility reasons only. The `pin` property will be removed in a later release.
|
|
35
|
+
|
|
36
|
+
> Change any code like `comment.pin` to `comment.pins[0]`. Ideally, also change your code to have support for multiple pins (this change may be more complex than the example).
|
|
37
|
+
- The `mediaTime` property has been replaced by the `time` property on the pin object. This change means it's possible for video and auto proofs to have pins added at different times along the timeline. This is not currently something we support in PageProof, but is making way for that functionality to be implemented in the future. Accessing the deprecated `mediaTime` property will yield the first pin's time - for backwards compatibility reasons only. The `mediaTime` property will be removed in a later release.
|
|
38
|
+
|
|
39
|
+
> Change any code like `comment.mediaTime` to `comment.pins[0].time`. And again, ideally you'd also want to change your code to have support for multiple pins.
|
|
40
|
+
- The `mediaDuration` property has been replaced by the `duration` property on the pin object. This change has been made for the same reasons as the change to the `mediaTime` property (above). Accessing the deprecated `mediaDuration` property will yield the first pin's duration - for backwards compatibility reasons only. The `mediaDuration` property will be removed in a later release.
|
|
41
|
+
|
|
42
|
+
> Change any code like `comment.mediaDuration` to `comment.pins[0].duration`. And again, ideally you'd also want to change your code to have support for multiple pins.
|
|
43
|
+
|
|
44
|
+
We've deprecated a few API options:
|
|
45
|
+
- The `Comments.create()` method
|
|
46
|
+
- The `pin` option has been replaced by the new `pins` option. This property is array of pins to attach to the comment. Providing this option behaves exactly as it did in earlier versions of the SDK, but it is recommended you switch to using the `pins` option, as we plan on removing the `pin` option in the future.
|
|
47
|
+
- The `mediaTime` option has been replaced by the `time` property on the pin object(s). Providing this option automatically assigns the first pin with the `time` property - but we recommend that you switch to manually specifying the `time` property, as we plan on removing the `mediaTime` option in the future.
|
|
48
|
+
- The `mediaDuration` option has been replaced by the `duration` property on the pin object(s). Providing this option automatically assigns the first pin with the `duration` property - but we recommend that you switch to manually specifying the `duration` property, as we plan on removing the `mediaDuration` option in the future.
|
|
49
|
+
|
|
50
|
+
### TL;DR
|
|
51
|
+
|
|
52
|
+
Here are a couple of code snippets of code that you may have in your PageProof integration code. If you're in a rush - here's a quick example of the changes you'll want to make.
|
|
53
|
+
|
|
54
|
+
**Creating comments**
|
|
55
|
+
|
|
56
|
+
Before (deprecated):
|
|
57
|
+
```js
|
|
58
|
+
await client.comments.create({
|
|
59
|
+
proofId: 'PR4G1XDX6W4QC579',
|
|
60
|
+
raw: 'Hello World',
|
|
61
|
+
pin: {
|
|
62
|
+
x: 0.024566473,
|
|
63
|
+
y: 0.756634520,
|
|
64
|
+
},
|
|
65
|
+
mediaTime: 17.3605,
|
|
66
|
+
mediaDuration: 1.5,
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
After (recommended, and the way forward):
|
|
71
|
+
```js
|
|
72
|
+
await client.comments.create({
|
|
73
|
+
proofId: 'PR4G1XDX6W4QC579',
|
|
74
|
+
raw: 'Hello World',
|
|
75
|
+
pins: [
|
|
76
|
+
{
|
|
77
|
+
x: 0.024566473,
|
|
78
|
+
y: 0.756634520,
|
|
79
|
+
time: 17.3605,
|
|
80
|
+
duration: 1.5,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Loading & accessing comment/pin info**
|
|
87
|
+
|
|
88
|
+
Before (deprecated):
|
|
89
|
+
```js
|
|
90
|
+
const comments = await client.comments.load('PR4G1XDX6W4QC579');
|
|
91
|
+
comments[0].pin.x === 0.024566473;
|
|
92
|
+
comments[0].pin.y === 0.756634520;
|
|
93
|
+
comments[0].mediaTime === 17.3605;
|
|
94
|
+
comments[0].mediaDuration === 1.5;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
After (recommended, and the way forward):
|
|
98
|
+
```js
|
|
99
|
+
const comments = await client.comments.load('PR4G1XDX6W4QC579');
|
|
100
|
+
comments[0].pins[0].x === 0.024566473;
|
|
101
|
+
comments[0].pins[0].y === 0.756634520;
|
|
102
|
+
comments[0].pins[0].time === 17.3605;
|
|
103
|
+
comments[0].pins[0].duration === 1.5;
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## 2.0.0-beta.283
|
|
107
|
+
|
|
108
|
+
Released on the 21th of December 2021.
|
|
109
|
+
|
|
110
|
+
- [[PP-1689](https://goto.pageproof.dev/PP-1689)] Added support for MFA (multi-factor authenticator). See [Accounts.login](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/Accounts.js~Accounts.html#instance-method-login).
|
|
111
|
+
|
|
3
112
|
|
|
4
113
|
## 2.0.0-beta.282
|
|
5
114
|
|
package/README.md
CHANGED
|
@@ -286,6 +286,7 @@ Name | Namespace | Description | Admin-only | Stability
|
|
|
286
286
|
--- | --- | --- | --- | ---
|
|
287
287
|
[Accounts API](./class/src/api/Accounts.js~Accounts.html) | `accounts` | Used to create accounts, activate and login. | No | Stable
|
|
288
288
|
[Accounts SSO API](./class/src/api/AccountsSSO.js~AccountsSSO.html) | `accounts.sso` | Used to login using a SSO provider. | No | Experimental
|
|
289
|
+
[Accounts MFA API](./class/src/api/AccountsMFA.js~AccountsMFA.html) | `accounts.mfa` | Used to activate, de-activate and enable user mfa login. | No | experimental
|
|
289
290
|
[Comments API](./class/src/api/Comments.js~Comments.html) | `comments` | Used to load comments. | No | Stable
|
|
290
291
|
[Dashboard API](./class/src/api/Dashboard.js~Dashboard.html) | `dashboard` | Used to load the authenticated user's dashboard & search for/filter proofs. | No | Stable
|
|
291
292
|
[Dashboard Groups API](./class/src/api/DashboardGroups.js~DashboardGroups.html) | `dashboard.groups` | Used to load proof groups | No | Experimental
|
package/lib/api/Accounts.d.ts
CHANGED
|
@@ -8,6 +8,12 @@ declare class Accounts extends API {
|
|
|
8
8
|
* @type {AccountsSSO}
|
|
9
9
|
*/
|
|
10
10
|
sso: AccountsSSO;
|
|
11
|
+
/**
|
|
12
|
+
* The Accounts MFA API.
|
|
13
|
+
*
|
|
14
|
+
* @type {AccountsMFA}
|
|
15
|
+
*/
|
|
16
|
+
mfa: AccountsMFA;
|
|
11
17
|
/** @private */
|
|
12
18
|
_generateCredentials(password: any): any;
|
|
13
19
|
/**
|
|
@@ -101,9 +107,10 @@ declare class Accounts extends API {
|
|
|
101
107
|
*
|
|
102
108
|
* @param {string} email The user's email address
|
|
103
109
|
* @param {string} password The user's secure password
|
|
110
|
+
* @param {string} [totp] The user's timed one time passcode produced from their authenticator app
|
|
104
111
|
* @returns {Promise<Session>}
|
|
105
112
|
*/
|
|
106
|
-
login(email: string, password: string, _decryptPrivateKey?: boolean): Promise<Session>;
|
|
113
|
+
login(email: string, password: string, totp?: string, _decryptPrivateKey?: boolean): Promise<Session>;
|
|
107
114
|
/**
|
|
108
115
|
* Resets the password for an account.
|
|
109
116
|
*
|
|
@@ -206,4 +213,5 @@ declare class Accounts extends API {
|
|
|
206
213
|
}
|
|
207
214
|
import API from "./API";
|
|
208
215
|
import AccountsSSO from "./AccountsSSO";
|
|
216
|
+
import AccountsMFA from "./AccountsMFA";
|
|
209
217
|
import Session from "../models/Session";
|
package/lib/api/Accounts.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _Session=require("../models/Session");var _Session2=_interopRequireDefault(_Session);var _AccountsSSO=require("./AccountsSSO");var _AccountsSSO2=_interopRequireDefault(_AccountsSSO);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 Accounts=function(_API){_inherits(Accounts,_API);function Accounts(client){_classCallCheck(this,Accounts);var _this=_possibleConstructorReturn(this,_API.call(this,client));_this.sso=new _AccountsSSO2.default(client);return _this}Accounts.prototype._generateCredentials=function _generateCredentials(password){var _this2=this;return this.client.crypto().generatePasswordHash(password).then(function(passwordHash){return Promise.all([passwordHash,_this2.client.crypto().generateKeyPair()])}).then(function(_ref){var passwordHash=_ref[0],keyPair=_ref[1];return Promise.all([passwordHash,keyPair,_this2.client.crypto().encryptPrivateKey(keyPair.privateKeyPEM,password)])})};Accounts.prototype.register=function register(email,password){var _this3=this;var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};if(typeof options==="string"){console.warn("Warning: Passing the user's activation code during account creation has been moved into an options object. For compatibility reasons, the legacy behaviour still functions as expected, but please update your code as this will be changed in a future version.");options={activationCode:options}}return this._generateCredentials(password).then(function(_ref2){var passwordHash=_ref2[0],keyPair=_ref2[1],privateKeyPEM$=_ref2[2];return Promise.all([keyPair,_this3.client.request("accounts.register",{email:email,password:passwordHash,privateKey:privateKeyPEM$,publicKey:keyPair.publicKeyPEM,referrer:options.referrer})])}).then(function(_ref3){var keyPair=_ref3[0];return Promise.all([keyPair,_this3.login(email,password,false)])}).then(function(_ref4){var keyPair=_ref4[0],session=_ref4[1];return Promise.all([keyPair,session,options.activationCode?_this3.activate(options.activationCode).catch(function(){return _this3.generateActivationCode()}):_this3.generateActivationCode()])}).then(function(_ref5){var keyPair=_ref5[0],session=_ref5[1];session.privateKeyPEM=keyPair.privateKeyPEM;return session})};Accounts.prototype.generateActivationCode=function generateActivationCode(){return this.client.request("accounts.generate-activation-code",{userId:this.client.session.userId})};Accounts.prototype.activate=function activate(activationCode){var _this4=this;return this.client.request("accounts.activate",{userId:this.client.session.userId,authCode:activationCode}).then(function(){_this4.client.session.user.hasActivated=true})};Accounts.prototype.login=function login(email,password){var _this5=this;var _decryptPrivateKey=arguments.length>
|
|
1
|
+
"use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _Session=require("../models/Session");var _Session2=_interopRequireDefault(_Session);var _AccountsSSO=require("./AccountsSSO");var _AccountsSSO2=_interopRequireDefault(_AccountsSSO);var _AccountsMFA=require("./AccountsMFA");var _AccountsMFA2=_interopRequireDefault(_AccountsMFA);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 Accounts=function(_API){_inherits(Accounts,_API);function Accounts(client){_classCallCheck(this,Accounts);var _this=_possibleConstructorReturn(this,_API.call(this,client));_this.sso=new _AccountsSSO2.default(client);_this.mfa=new _AccountsMFA2.default(client);return _this}Accounts.prototype._generateCredentials=function _generateCredentials(password){var _this2=this;return this.client.crypto().generatePasswordHash(password).then(function(passwordHash){return Promise.all([passwordHash,_this2.client.crypto().generateKeyPair()])}).then(function(_ref){var passwordHash=_ref[0],keyPair=_ref[1];return Promise.all([passwordHash,keyPair,_this2.client.crypto().encryptPrivateKey(keyPair.privateKeyPEM,password)])})};Accounts.prototype.register=function register(email,password){var _this3=this;var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};if(typeof options==="string"){console.warn("Warning: Passing the user's activation code during account creation has been moved into an options object. For compatibility reasons, the legacy behaviour still functions as expected, but please update your code as this will be changed in a future version.");options={activationCode:options}}return this._generateCredentials(password).then(function(_ref2){var passwordHash=_ref2[0],keyPair=_ref2[1],privateKeyPEM$=_ref2[2];return Promise.all([keyPair,_this3.client.request("accounts.register",{email:email,password:passwordHash,privateKey:privateKeyPEM$,publicKey:keyPair.publicKeyPEM,referrer:options.referrer})])}).then(function(_ref3){var keyPair=_ref3[0];return Promise.all([keyPair,_this3.login(email,password,undefined,false)])}).then(function(_ref4){var keyPair=_ref4[0],session=_ref4[1];return Promise.all([keyPair,session,options.activationCode?_this3.activate(options.activationCode).catch(function(){return _this3.generateActivationCode()}):_this3.generateActivationCode()])}).then(function(_ref5){var keyPair=_ref5[0],session=_ref5[1];session.privateKeyPEM=keyPair.privateKeyPEM;return session})};Accounts.prototype.generateActivationCode=function generateActivationCode(){return this.client.request("accounts.generate-activation-code",{userId:this.client.session.userId})};Accounts.prototype.activate=function activate(activationCode){var _this4=this;return this.client.request("accounts.activate",{userId:this.client.session.userId,authCode:activationCode}).then(function(){_this4.client.session.user.hasActivated=true})};Accounts.prototype.login=function login(email,password,totp){var _this5=this;var _decryptPrivateKey=arguments.length>3&&arguments[3]!==undefined?arguments[3]:true;return this.client.crypto().generatePasswordHash(password).then(function(passwordHash){return _this5.client.request("accounts.login",{email:email,password:passwordHash,totp:totp})}).then(function(response){var session=(new _Session2.default).fromSession(response.data);session.user.email=email;return session}).then(function(session){if(_decryptPrivateKey){return _this5.client.crypto().decryptPrivateKey(session.privateKeyPEM$,password).then(function(privateKeyPEM){session.privateKeyPEM=privateKeyPEM;return session})}return session}).then(function(session){_this5.client.setSession(session);return session})};Accounts.prototype.resetPassword=function resetPassword(_ref6){var _this6=this;var email=_ref6.email,code=_ref6.code,password=_ref6.password;return this._generateCredentials(password).then(function(_ref7){var passwordHash=_ref7[0],keyPair=_ref7[1],privateKeyPEM$=_ref7[2];return Promise.all([keyPair,_this6.client.request("accounts.reset-password",{email:email,secret:code,newPassword:passwordHash,newPrivateKey:privateKeyPEM$,newPublicKey:keyPair.publicKeyPEM})])}).then(function(_ref8){var keyPair=_ref8[0];return Promise.all([keyPair,_this6.login(email,password,undefined,false)])}).then(function(_ref9){var keyPair=_ref9[0],session=_ref9[1];session.privateKeyPEM=keyPair.privateKeyPEM;return session})};Accounts.prototype.forgotPassword=function forgotPassword(email){return this.client.request("accounts.forgot-password",{email:email})};Accounts.prototype.setPasswordRequest=function setPasswordRequest(email){return this.client.request("accounts.set-password-request",{email:email})};Accounts.prototype.setPassword=function setPassword(_ref10){var _this7=this;var email=_ref10.email,code=_ref10.code,password=_ref10.password;return this._generateCredentials(password).then(function(_ref11){var passwordHash=_ref11[0],keyPair=_ref11[1],privateKeyPEM$=_ref11[2];return Promise.all([keyPair,_this7.client.request("accounts.set-password",{email:email,secret:code,newPassword:passwordHash,newPrivateKey:privateKeyPEM$,newPublicKey:keyPair.publicKeyPEM})])}).then(function(_ref12){var keyPair=_ref12[0];return Promise.all([keyPair,_this7.login(email,password,undefined,false)])}).then(function(_ref13){var keyPair=_ref13[0],session=_ref13[1];session.privateKeyPEM=keyPair.privateKeyPEM;return session})};Accounts.prototype.logout=function logout(){var _this8=this;return this.client.request("accounts.logout").catch(function(err){_this8.client.setSession(null);return Promise.reject(err)}).then(function(){_this8.client.setSession(null)})};return Accounts}(_API3.default);exports.default=Accounts;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export default AccountsMFA;
|
|
2
|
+
declare class AccountsMFA extends API {
|
|
3
|
+
constructor(client: any);
|
|
4
|
+
/**
|
|
5
|
+
* Begins the setup for MFA (multi-factor authentication).
|
|
6
|
+
*
|
|
7
|
+
* @returns {Promise<{ secret: string, qrCodeImage: string }>}
|
|
8
|
+
*/
|
|
9
|
+
setup(): Promise<{
|
|
10
|
+
secret: string;
|
|
11
|
+
qrCodeImage: string;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Enables the pending MFA configuration by providing a TOTP code to verify the authenticator app setup was successful.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} totp The timed one time passcode the user has received from scanning the qr code via their authentication app
|
|
17
|
+
* @returns {Promise}
|
|
18
|
+
*/
|
|
19
|
+
enable(totp: string): Promise<any>;
|
|
20
|
+
/**
|
|
21
|
+
* Disables current user MFA (multi-factor-authentication) once the user has entered their password.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} password The users account password
|
|
24
|
+
* @returns {Promise}
|
|
25
|
+
*/
|
|
26
|
+
remove(password: string): Promise<any>;
|
|
27
|
+
}
|
|
28
|
+
import API from "./API";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);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 AccountsMFA=function(_API){_inherits(AccountsMFA,_API);function AccountsMFA(){_classCallCheck(this,AccountsMFA);return _possibleConstructorReturn(this,_API.apply(this,arguments))}AccountsMFA.prototype.setup=function setup(){return this.client.request("mfa.setup").then(function(response){return{secret:response.data.SetupSecret,qrCodeImage:response.data.SetupQrCode}})};AccountsMFA.prototype.enable=function enable(totp){return this.client.request("mfa.enable",{totp:totp})};AccountsMFA.prototype.remove=function remove(password){var _this2=this;return this.client.crypto().generatePasswordHash(password).then(function(passwordHash){return _this2.client.request("mfa.remove",{password:passwordHash})})};return AccountsMFA}(_API3.default);exports.default=AccountsMFA;
|
package/lib/api/Comments.d.ts
CHANGED
|
@@ -164,6 +164,21 @@ declare class Comments extends API {
|
|
|
164
164
|
* @returns {Promise<Array<Comment>>}
|
|
165
165
|
*/
|
|
166
166
|
load(_options: any): Promise<Comment[]>;
|
|
167
|
+
/**
|
|
168
|
+
* @typedef {object} CreateCommentOptions The options for creating a new comment
|
|
169
|
+
* @property {string} [raw] The comment text (plain text)
|
|
170
|
+
* @property {object} [tokens] The comment tokens (rich text)
|
|
171
|
+
* @property {string} [proofId] The proof ID the comment should be attached to
|
|
172
|
+
* @property {number} [pageNumber=1] For comments (not replies) - the page number the comment was placed on
|
|
173
|
+
* @property {Pin} [pin] For comments (not replies) - the comment's pin coordinates (deprecated: provide an array of pins instead)
|
|
174
|
+
* @property {Pin[]} [pins] For comments (not replies) - the comment's pin(s) coordinates
|
|
175
|
+
* @property {number} [mediaTime] For audio/video proofs - the time (in seconds) that the pin was placed (deprecated: set the time within the pin object)
|
|
176
|
+
* @property {number} [mediaDuration] For audio/video proofs - the duration (in seconds) that the pin spans (deprecated: set the duration within the pin object)
|
|
177
|
+
* @property {string} [parentCommentId] For replies - the parent comment ID
|
|
178
|
+
* @property {object} [metadata] For web proofs - additional metadata relating to the comment snapshot. It is recommended that you do not provide metadata through the SDK currently, as the format for the metadata is not documented (and is subject to change).
|
|
179
|
+
* @property {string} [state] For comments (not replies) - The state of the comment (currently only supports to-dos)
|
|
180
|
+
* @property {string} [creationToken] Only required if you're retrying (token can be extracted from the error object which is resolved (rejected, in this case) from the Promise)
|
|
181
|
+
*/
|
|
167
182
|
/**
|
|
168
183
|
* Creates a new comment (or reply).
|
|
169
184
|
*
|
|
@@ -184,10 +199,12 @@ declare class Comments extends API {
|
|
|
184
199
|
* await client.comments.create({
|
|
185
200
|
* proofId: 'PPTMHIVPYMB2XRTK',
|
|
186
201
|
* raw: 'Hello World!',
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
202
|
+
* pins: [
|
|
203
|
+
* {
|
|
204
|
+
* x: 0, // add the pin to the center of the proof
|
|
205
|
+
* y: 0,
|
|
206
|
+
* },
|
|
207
|
+
* ],
|
|
191
208
|
* });
|
|
192
209
|
*
|
|
193
210
|
* @example <caption>Single retry logic</caption>
|
|
@@ -195,7 +212,7 @@ declare class Comments extends API {
|
|
|
195
212
|
* await client.comments.create({
|
|
196
213
|
* proofId: 'PPTMHIVPYMB2XRTK',
|
|
197
214
|
* raw: 'Hello World!',
|
|
198
|
-
*
|
|
215
|
+
* pins: [{ x: 0, y: 0 }],
|
|
199
216
|
* creationToken: retryCreationToken,
|
|
200
217
|
* });
|
|
201
218
|
* }
|
|
@@ -215,27 +232,59 @@ declare class Comments extends API {
|
|
|
215
232
|
* }
|
|
216
233
|
*
|
|
217
234
|
* @since v2.0.0-beta.46
|
|
218
|
-
* @param {
|
|
219
|
-
* @param {string} [comment.raw] The raw comment text (rich text is not supported)
|
|
220
|
-
* @param {object} [comment.tokens] The comment tokens (with rich-text support). If you are creating legacy-style comments (just plain text) then use the "raw" option. Please note that while PageProof will continue to support plain text comments for the foreseeable future, it's recommended that you use the new "tokenized" comments.
|
|
221
|
-
* @param {string} comment.proofId The proof id the comment should be attached to
|
|
222
|
-
* @param {number} [comment.pageNumber=1] For comments (not replies) - the page number the comment should be attached to
|
|
223
|
-
* @param {Pin} [comment.pin] For comments (not replies) - the comment's pin coordinates
|
|
224
|
-
* @param {number} [comment.pin.x] The pin's x coordinate
|
|
225
|
-
* @param {number} [comment.pin.y] The pin's y coordinate
|
|
226
|
-
* @param {number} [comment.pin.x2] For boxes or lines - the pin's x2 coordinate
|
|
227
|
-
* @param {number} [comment.pin.y2] For boxes or lines - the pin's y2 coordinate
|
|
228
|
-
* @param {string} [comment.pin.fill.image] For pin fill images - the pin's fill image if pin is different then a dot or box type (like draw or text)
|
|
229
|
-
* @param {string} [comment.pin.fill.type] For pin fill images - the pin's fill image type
|
|
230
|
-
* @param {number} [comment.mediaTime] For video & audio - the start time
|
|
231
|
-
* @param {number} [comment.mediaDuration] For video & audio - the duration
|
|
232
|
-
* @param {string} [comment.parentCommentId] For replies - the parent comment id
|
|
233
|
-
* @param {object} [comment.metadata] For web proofs - additional metadata relating to the comment snapshot. It is recommended that you do not provide metadata through the SDK currently, as the format for the metadata is not documented (and is subject to change).
|
|
234
|
-
* @param {CommentState} [comment.state] For comments (not replies) - The state of the comment (currently only supports to-dos)
|
|
235
|
-
* @param {string} [comment.creationToken] Only required if you're retrying (token can be extracted from the error object which is resolved (rejected, in this case) from the Promise)
|
|
235
|
+
* @param {CreateCommentOptions} options The creation options
|
|
236
236
|
* @returns {Promise<Comment>}
|
|
237
237
|
*/
|
|
238
|
-
create({ raw, tokens, proofId, pageNumber, pin, mediaTime, mediaDuration, parentCommentId, metadata, state, creationToken: retryCreationToken, }:
|
|
238
|
+
create({ raw, tokens, proofId, pageNumber, pin, pins, mediaTime, mediaDuration, parentCommentId, metadata, state, creationToken: retryCreationToken, }: {
|
|
239
|
+
/**
|
|
240
|
+
* The comment text (plain text)
|
|
241
|
+
*/
|
|
242
|
+
raw?: string;
|
|
243
|
+
/**
|
|
244
|
+
* The comment tokens (rich text)
|
|
245
|
+
*/
|
|
246
|
+
tokens?: any;
|
|
247
|
+
/**
|
|
248
|
+
* The proof ID the comment should be attached to
|
|
249
|
+
*/
|
|
250
|
+
proofId?: string;
|
|
251
|
+
/**
|
|
252
|
+
* For comments (not replies) - the page number the comment was placed on
|
|
253
|
+
*/
|
|
254
|
+
pageNumber?: number;
|
|
255
|
+
/**
|
|
256
|
+
* For comments (not replies) - the comment's pin coordinates (deprecated: provide an array of pins instead)
|
|
257
|
+
*/
|
|
258
|
+
pin?: Pin;
|
|
259
|
+
/**
|
|
260
|
+
* For comments (not replies) - the comment's pin(s) coordinates
|
|
261
|
+
*/
|
|
262
|
+
pins?: Pin[];
|
|
263
|
+
/**
|
|
264
|
+
* For audio/video proofs - the time (in seconds) that the pin was placed (deprecated: set the time within the pin object)
|
|
265
|
+
*/
|
|
266
|
+
mediaTime?: number;
|
|
267
|
+
/**
|
|
268
|
+
* For audio/video proofs - the duration (in seconds) that the pin spans (deprecated: set the duration within the pin object)
|
|
269
|
+
*/
|
|
270
|
+
mediaDuration?: number;
|
|
271
|
+
/**
|
|
272
|
+
* For replies - the parent comment ID
|
|
273
|
+
*/
|
|
274
|
+
parentCommentId?: string;
|
|
275
|
+
/**
|
|
276
|
+
* For web proofs - additional metadata relating to the comment snapshot. It is recommended that you do not provide metadata through the SDK currently, as the format for the metadata is not documented (and is subject to change).
|
|
277
|
+
*/
|
|
278
|
+
metadata?: any;
|
|
279
|
+
/**
|
|
280
|
+
* For comments (not replies) - The state of the comment (currently only supports to-dos)
|
|
281
|
+
*/
|
|
282
|
+
state?: string;
|
|
283
|
+
/**
|
|
284
|
+
* Only required if you're retrying (token can be extracted from the error object which is resolved (rejected, in this case) from the Promise)
|
|
285
|
+
*/
|
|
286
|
+
creationToken?: string;
|
|
287
|
+
}): Promise<Comment>;
|
|
239
288
|
}
|
|
240
289
|
import API from "./API";
|
|
241
290
|
import Comment from "../models/Comment";
|
package/lib/api/Comments.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _Comment=require("../models/Comment");var _Comment2=_interopRequireDefault(_Comment);var _CommentState=require("../enum/CommentState");var _CommentState2=_interopRequireDefault(_CommentState);var _constants=require("../util/constants");var _sort=require("../util/sort");var _v=require("../util/comments/v2");var _extractMentions=require("../util/comments/extractMentions");var _extractMentions2=_interopRequireDefault(_extractMentions);var _parseComment=require("../util/comments/parseComment");var _parseComment2=_interopRequireDefault(_parseComment);var _creationToken=require("../util/creationToken");var _throttle=require("../util/throttle");var _throttle2=_interopRequireDefault(_throttle);var _getCommentState=require("../util/comments/getCommentState");var _getCommentState2=_interopRequireDefault(_getCommentState);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}function getCommentDataFromPages(pages){var comments=[];Object.keys(pages).forEach(function(pageNumber){pages[pageNumber].Comments.forEach(function(commentData){comments.push(commentData)})});return comments}var _sortPages=(0,_sort.sortObjectsByKey)("pageNumber");var _sortCreatedDateDESC=(0,_sort.sortObjectsByKey)("createdDate",true);var _sortCreatedDateASC=(0,_sort.sortObjectsByKey)("createdDate",false);var sortComments=(0,_sort.combineSort)(_sortPages,_sortCreatedDateDESC);var sortReplies=(0,_sort.combineSort)(_sortPages,_sortCreatedDateASC);function mapComments(commentsData){var comments=[];var replies=[];commentsData.forEach(function(commentData){var entity=(new _Comment2.default).fromComment(commentData);if(entity.parentCommentId){replies.push(entity)}else{comments.push(entity)}});comments.sort(sortComments);var commentIds=comments.map(function(c){return c.id});var sortByParentCommentIndex=(0,_sort.sortObjectsBy)(function(r){return commentIds.indexOf(r.parentCommentId)},true);replies.sort((0,_sort.combineSort)(sortReplies,sortByParentCommentIndex));return comments.concat(replies)}var Comments=function(_API){_inherits(Comments,_API);function Comments(){_classCallCheck(this,Comments);return _possibleConstructorReturn(this,_API.apply(this,arguments))}Comments.prototype._mark=function _mark(commentId,state,value){if(Object.keys(_CommentState2.default).map(function(key){return _CommentState2.default[key]}).indexOf(state)===-1){throw new Error('Cannot mark comment state "'+state+'".')}var TODO=_CommentState2.default.TODO,DONE=_CommentState2.default.DONE,UNMARKED=_CommentState2.default.UNMARKED;var data={commentId:commentId};switch(state){case UNMARKED:{data.change=0;data.done=0;break}case TODO:{data.change=value?1:0;data.done=0;break}case DONE:{data.done=value?1:0;break}}return this.client.request("comments.state.update",data).then(function(response){return(0,_getCommentState2.default)(response.data)})};Comments.prototype._markAll=function _markAll(proofId,commentIds,state,value){if(Object.keys(_CommentState2.default).map(function(key){return _CommentState2.default[key]}).indexOf(state)===-1){throw new Error('Cannot mark comment state "'+state+'".')}var TODO=_CommentState2.default.TODO,DONE=_CommentState2.default.DONE,UNMARKED=_CommentState2.default.UNMARKED;var data={proofId:proofId,commentIds:commentIds};switch(state){case UNMARKED:{data.change=0;data.done=0;break}case TODO:{data.change=value?1:0;data.done=0;break}case DONE:{data.done=value?1:0;break}}return this.client.request("comments.state.multiple-update",data).then(function(response){return response.data.map(function(comment){return{commentId:comment.CommentId,commentState:(0,_getCommentState2.default)(comment)}})})};Comments.prototype.mark=function mark(commentId,state){return this._mark(commentId,state,true)};Comments.prototype.unmark=function unmark(commentId,state){return this._mark(commentId,state,false)};Comments.prototype.markAll=function markAll(proofId,commentIds,state){return this._markAll(proofId,commentIds,state,true)};Comments.prototype.unmarkAll=function unmarkAll(proofId,commentIds,state){return this._markAll(proofId,commentIds,state,false)};Comments.prototype.delete=function _delete(commentId){return this.client.request("comments.delete",{commentId:commentId})};Comments.prototype.load=function load(_options){var _this2=this;var options=typeof _options==="string"?{proofId:_options}:_options;var proofId=options.proofId,_options$pageNumber=options.pageNumber,pageNumber=_options$pageNumber===undefined?null:_options$pageNumber,_options$sinceDate=options.sinceDate,sinceDate=_options$sinceDate===undefined?null:_options$sinceDate,_options$async=options.async,async=_options$async===undefined?false:_options$async,_options$decrypt=options.decrypt,decrypt=_options$decrypt===undefined?true:_options$decrypt,onDecryptComment=options.onDecryptComment,onDecryptComments=options.onDecryptComments,_options$onDecryptCom=options.onDecryptCommentsThrottleMs,onDecryptCommentsThrottleMs=_options$onDecryptCom===undefined?1e3:_options$onDecryptCom,onDecryptError=options.onDecryptError;var sinceDateISO=sinceDate?sinceDate.toISOString().match(_constants.ISO_REGEX)[0]:_constants.DEFAULT_ISO_DATE;var payload={proofId:proofId,page:pageNumber,timestamp:sinceDateISO};return this.client.request(pageNumber!==null?"comments.load-page":"comments.load-all",payload).then(function(response){var comments=mapComments(response.data.Pages?getCommentDataFromPages(response.data.Pages):response.data);var wait=Promise.resolve();if(decrypt){var scheduled=[];var pendingBatch=[];var scheduleOnDecryptComments=onDecryptComments?(0,_throttle2.default)(function(){if(pendingBatch.length){onDecryptComments(pendingBatch);pendingBatch=[]}},onDecryptCommentsThrottleMs):function(){};var cached=Promise.all(comments.map(function(comment){return _this2.client.cache.auto(_constants.COMMENT_CACHE_PREFIX+comment.comment$,function(resolve){scheduled.push({comment:comment,resolve:resolve})}).then(function(rawComment){if(rawComment){comment.fromRawComment(rawComment)}return comment})}));wait=wait.then(function(){return cached});wait=wait.then(function(){var decrypted=scheduled.map(function(_ref){var comment=_ref.comment,resolve=_ref.resolve;return _this2.client.crypto().decryptComment(comment.comment$,comment.envelope,_this2.client.keyPairs.getPrivateKeyPEMs()).then(function(rawComment){comment.fromRawComment(rawComment);resolve(rawComment);if(onDecryptComment){onDecryptComment(comment)}pendingBatch.push(comment);scheduleOnDecryptComments()}).catch(function(err){if(onDecryptError){onDecryptError(err,comment)}if(!async){return Promise.reject(err)}return undefined})});if(!async){return Promise.all(decrypted)}return null})}return wait.then(function(){return comments})})};Comments.prototype.create=function create(_ref2){var _this3=this;var raw=_ref2.raw,tokens=_ref2.tokens,proofId=_ref2.proofId,_ref2$pageNumber=_ref2.pageNumber,pageNumber=_ref2$pageNumber===undefined?1:_ref2$pageNumber,pin=_ref2.pin,mediaTime=_ref2.mediaTime,mediaDuration=_ref2.mediaDuration,parentCommentId=_ref2.parentCommentId,metadata=_ref2.metadata,state=_ref2.state,retryCreationToken=_ref2.creationToken;var mentions=[];var serialized=raw||(0,_v.serialize)(tokens);{var parsed=tokens||(0,_parseComment2.default)(raw);mentions.push.apply(mentions,(0,_extractMentions2.default)(parsed))}var creationToken=retryCreationToken||(0,_creationToken.generateCreationToken)();return this.client.crypto().encryptComment(serialized,this.client.keyPairs.getPublicKeyPEMs()).then(function(_ref3){var envelope=_ref3.envelope,comment$=_ref3.comment$;return{proofId:proofId,page:parentCommentId?undefined:pageNumber,envelope:envelope,encryptedComment:comment$,xy:
|
|
1
|
+
"use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _Comment=require("../models/Comment");var _Comment2=_interopRequireDefault(_Comment);var _CommentState=require("../enum/CommentState");var _CommentState2=_interopRequireDefault(_CommentState);var _constants=require("../util/constants");var _sort=require("../util/sort");var _v=require("../util/comments/v2");var _extractMentions=require("../util/comments/extractMentions");var _extractMentions2=_interopRequireDefault(_extractMentions);var _parseComment=require("../util/comments/parseComment");var _parseComment2=_interopRequireDefault(_parseComment);var _creationToken=require("../util/creationToken");var _throttle=require("../util/throttle");var _throttle2=_interopRequireDefault(_throttle);var _getCommentState=require("../util/comments/getCommentState");var _getCommentState2=_interopRequireDefault(_getCommentState);var _serializePins=require("../util/pins/serializePins");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}function getCommentDataFromPages(pages){var comments=[];Object.keys(pages).forEach(function(pageNumber){pages[pageNumber].Comments.forEach(function(commentData){comments.push(commentData)})});return comments}var _sortPages=(0,_sort.sortObjectsByKey)("pageNumber");var _sortCreatedDateDESC=(0,_sort.sortObjectsByKey)("createdDate",true);var _sortCreatedDateASC=(0,_sort.sortObjectsByKey)("createdDate",false);var sortComments=(0,_sort.combineSort)(_sortPages,_sortCreatedDateDESC);var sortReplies=(0,_sort.combineSort)(_sortPages,_sortCreatedDateASC);function mapComments(commentsData){var comments=[];var replies=[];commentsData.forEach(function(commentData){var entity=(new _Comment2.default).fromComment(commentData);if(entity.parentCommentId){replies.push(entity)}else{comments.push(entity)}});comments.sort(sortComments);var commentIds=comments.map(function(c){return c.id});var sortByParentCommentIndex=(0,_sort.sortObjectsBy)(function(r){return commentIds.indexOf(r.parentCommentId)},true);replies.sort((0,_sort.combineSort)(sortReplies,sortByParentCommentIndex));return comments.concat(replies)}var Comments=function(_API){_inherits(Comments,_API);function Comments(){_classCallCheck(this,Comments);return _possibleConstructorReturn(this,_API.apply(this,arguments))}Comments.prototype._mark=function _mark(commentId,state,value){if(Object.keys(_CommentState2.default).map(function(key){return _CommentState2.default[key]}).indexOf(state)===-1){throw new Error('Cannot mark comment state "'+state+'".')}var TODO=_CommentState2.default.TODO,DONE=_CommentState2.default.DONE,UNMARKED=_CommentState2.default.UNMARKED;var data={commentId:commentId};switch(state){case UNMARKED:{data.change=0;data.done=0;break}case TODO:{data.change=value?1:0;data.done=0;break}case DONE:{data.done=value?1:0;break}}return this.client.request("comments.state.update",data).then(function(response){return(0,_getCommentState2.default)(response.data)})};Comments.prototype._markAll=function _markAll(proofId,commentIds,state,value){if(Object.keys(_CommentState2.default).map(function(key){return _CommentState2.default[key]}).indexOf(state)===-1){throw new Error('Cannot mark comment state "'+state+'".')}var TODO=_CommentState2.default.TODO,DONE=_CommentState2.default.DONE,UNMARKED=_CommentState2.default.UNMARKED;var data={proofId:proofId,commentIds:commentIds};switch(state){case UNMARKED:{data.change=0;data.done=0;break}case TODO:{data.change=value?1:0;data.done=0;break}case DONE:{data.done=value?1:0;break}}return this.client.request("comments.state.multiple-update",data).then(function(response){return response.data.map(function(comment){return{commentId:comment.CommentId,commentState:(0,_getCommentState2.default)(comment)}})})};Comments.prototype.mark=function mark(commentId,state){return this._mark(commentId,state,true)};Comments.prototype.unmark=function unmark(commentId,state){return this._mark(commentId,state,false)};Comments.prototype.markAll=function markAll(proofId,commentIds,state){return this._markAll(proofId,commentIds,state,true)};Comments.prototype.unmarkAll=function unmarkAll(proofId,commentIds,state){return this._markAll(proofId,commentIds,state,false)};Comments.prototype.delete=function _delete(commentId){return this.client.request("comments.delete",{commentId:commentId})};Comments.prototype.load=function load(_options){var _this2=this;var options=typeof _options==="string"?{proofId:_options}:_options;var proofId=options.proofId,_options$pageNumber=options.pageNumber,pageNumber=_options$pageNumber===undefined?null:_options$pageNumber,_options$sinceDate=options.sinceDate,sinceDate=_options$sinceDate===undefined?null:_options$sinceDate,_options$async=options.async,async=_options$async===undefined?false:_options$async,_options$decrypt=options.decrypt,decrypt=_options$decrypt===undefined?true:_options$decrypt,onDecryptComment=options.onDecryptComment,onDecryptComments=options.onDecryptComments,_options$onDecryptCom=options.onDecryptCommentsThrottleMs,onDecryptCommentsThrottleMs=_options$onDecryptCom===undefined?1e3:_options$onDecryptCom,onDecryptError=options.onDecryptError;var sinceDateISO=sinceDate?sinceDate.toISOString().match(_constants.ISO_REGEX)[0]:_constants.DEFAULT_ISO_DATE;var payload={proofId:proofId,page:pageNumber,timestamp:sinceDateISO};return this.client.request(pageNumber!==null?"comments.load-page":"comments.load-all",payload).then(function(response){var comments=mapComments(response.data.Pages?getCommentDataFromPages(response.data.Pages):response.data);var wait=Promise.resolve();if(decrypt){var scheduled=[];var pendingBatch=[];var scheduleOnDecryptComments=onDecryptComments?(0,_throttle2.default)(function(){if(pendingBatch.length){onDecryptComments(pendingBatch);pendingBatch=[]}},onDecryptCommentsThrottleMs):function(){};var cached=Promise.all(comments.map(function(comment){return _this2.client.cache.auto(_constants.COMMENT_CACHE_PREFIX+comment.comment$,function(resolve){scheduled.push({comment:comment,resolve:resolve})}).then(function(rawComment){if(rawComment){comment.fromRawComment(rawComment)}return comment})}));wait=wait.then(function(){return cached});wait=wait.then(function(){var decrypted=scheduled.map(function(_ref){var comment=_ref.comment,resolve=_ref.resolve;return _this2.client.crypto().decryptComment(comment.comment$,comment.envelope,_this2.client.keyPairs.getPrivateKeyPEMs()).then(function(rawComment){comment.fromRawComment(rawComment);resolve(rawComment);if(onDecryptComment){onDecryptComment(comment)}pendingBatch.push(comment);scheduleOnDecryptComments()}).catch(function(err){if(onDecryptError){onDecryptError(err,comment)}if(!async){return Promise.reject(err)}return undefined})});if(!async){return Promise.all(decrypted)}return null})}return wait.then(function(){return comments})})};Comments.prototype.create=function create(_ref2){var _this3=this;var raw=_ref2.raw,tokens=_ref2.tokens,proofId=_ref2.proofId,_ref2$pageNumber=_ref2.pageNumber,pageNumber=_ref2$pageNumber===undefined?1:_ref2$pageNumber,pin=_ref2.pin,pins=_ref2.pins,mediaTime=_ref2.mediaTime,mediaDuration=_ref2.mediaDuration,parentCommentId=_ref2.parentCommentId,metadata=_ref2.metadata,state=_ref2.state,retryCreationToken=_ref2.creationToken;var mentions=[];var serialized=raw||(0,_v.serialize)(tokens);{var parsed=tokens||(0,_parseComment2.default)(raw);mentions.push.apply(mentions,(0,_extractMentions2.default)(parsed))}var pinList=[];var boxFill=void 0;if(pins){pinList=pinList.concat(pins)}else if(pin){pinList.push(pin)}var primaryPin=pinList[0];if(primaryPin){if(primaryPin.fill)boxFill=primaryPin.fill;if(mediaTime)primaryPin.time=mediaTime;if(mediaDuration)primaryPin.duration=mediaDuration}var creationToken=retryCreationToken||(0,_creationToken.generateCreationToken)();return this.client.crypto().encryptComment(serialized,this.client.keyPairs.getPublicKeyPEMs()).then(function(_ref3){var envelope=_ref3.envelope,comment$=_ref3.comment$;return{proofId:proofId,page:parentCommentId?undefined:pageNumber,envelope:envelope,encryptedComment:comment$,xy:(0,_serializePins.serializePins)(pinList),boxFillImage:boxFill?boxFill.image:undefined,boxFillType:boxFill?boxFill.type:undefined,parent:parentCommentId||undefined,mentions:mentions,metadata:metadata?JSON.stringify(metadata):"{}",creationToken:creationToken,change:state===_CommentState2.default.TODO?"1":undefined,done:state===_CommentState2.default.DONE?"1":undefined}}).then(function(requestData){return _this3.client.request("comments.create",requestData).then(function(response){return(new _Comment2.default).fromComment(response.data).fromRawComment(serialized)})}).catch(function(err){if(err){err.creationToken=creationToken}return Promise.reject(err)})};return Comments}(_API3.default);exports.default=Comments;
|
|
@@ -65,7 +65,11 @@ declare class TeamFeatures extends API {
|
|
|
65
65
|
* const admin = await client.admin();
|
|
66
66
|
* const features = admin.team.features.setSenderEmail('team@example.com');
|
|
67
67
|
*
|
|
68
|
-
* @
|
|
68
|
+
* @example <caption>Resetting the team sender email address back to the default</caption>
|
|
69
|
+
* const admin = await client.admin();
|
|
70
|
+
* const features = admin.team.features.setSenderEmail(null);
|
|
71
|
+
*
|
|
72
|
+
* @param {string|null} senderEmail The team sender email address.
|
|
69
73
|
* @returns {Promise<TeamSenderEmail>}
|
|
70
74
|
*/
|
|
71
75
|
setSenderEmail(senderEmail: string): Promise<TeamSenderEmail>;
|
|
@@ -116,8 +116,12 @@ var TeamFeatures = function (_API) {
|
|
|
116
116
|
* @example <caption>Setting the team sender email</caption>
|
|
117
117
|
* const admin = await client.admin();
|
|
118
118
|
* const features = admin.team.features.setSenderEmail('team@example.com');
|
|
119
|
+
*
|
|
120
|
+
* @example <caption>Resetting the team sender email address back to the default</caption>
|
|
121
|
+
* const admin = await client.admin();
|
|
122
|
+
* const features = admin.team.features.setSenderEmail(null);
|
|
119
123
|
*
|
|
120
|
-
* @param {string} senderEmail The team sender email address.
|
|
124
|
+
* @param {string|null} senderEmail The team sender email address.
|
|
121
125
|
* @returns {Promise<TeamSenderEmail>}
|
|
122
126
|
*/
|
|
123
127
|
|
package/lib/models/Comment.d.ts
CHANGED
|
@@ -17,9 +17,37 @@ declare class Comment {
|
|
|
17
17
|
*
|
|
18
18
|
* This field is null for replies, as replies do not have a location on the proof.
|
|
19
19
|
*
|
|
20
|
-
* @type {
|
|
21
|
-
*/
|
|
22
|
-
pin:
|
|
20
|
+
* @type {{ x: number, y: number, x2: number | null, y2: number | null, time: number | null, duration: number | null, fill: { type: string, image: string } | null } | null}
|
|
21
|
+
*/
|
|
22
|
+
pin: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
x2: number | null;
|
|
26
|
+
y2: number | null;
|
|
27
|
+
time: number | null;
|
|
28
|
+
duration: number | null;
|
|
29
|
+
fill: {
|
|
30
|
+
type: string;
|
|
31
|
+
image: string;
|
|
32
|
+
} | null;
|
|
33
|
+
} | null;
|
|
34
|
+
/**
|
|
35
|
+
* The pins associated with the comment (not replies).
|
|
36
|
+
*
|
|
37
|
+
* @type {{ x: number, y: number, x2: number | null, y2: number | null, time: number | null, duration: number | null, fill: { type: string, image: string } | null }[]}
|
|
38
|
+
*/
|
|
39
|
+
pins: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
x2: number | null;
|
|
43
|
+
y2: number | null;
|
|
44
|
+
time: number | null;
|
|
45
|
+
duration: number | null;
|
|
46
|
+
fill: {
|
|
47
|
+
type: string;
|
|
48
|
+
image: string;
|
|
49
|
+
} | null;
|
|
50
|
+
}[];
|
|
23
51
|
/**
|
|
24
52
|
* The user who created the comment.
|
|
25
53
|
*
|
|
@@ -125,6 +153,7 @@ declare class Comment {
|
|
|
125
153
|
*
|
|
126
154
|
* On all other kinds of proofs this field is set to `undefined`.
|
|
127
155
|
*
|
|
156
|
+
* @deprecated Please use the time property on the pin object. This property will be removed in a future release.
|
|
128
157
|
* @since v2.0.0-beta.37
|
|
129
158
|
* @type {number}
|
|
130
159
|
*/
|
|
@@ -134,6 +163,7 @@ declare class Comment {
|
|
|
134
163
|
*
|
|
135
164
|
* On all other kinds of proofs this field is set to `undefined`.
|
|
136
165
|
*
|
|
166
|
+
* @deprecated Please use the duration property on the pin object. This property will be removed in a future release.
|
|
137
167
|
* @since v2.0.0-beta.37
|
|
138
168
|
* @type {number}
|
|
139
169
|
*/
|
|
@@ -151,6 +181,5 @@ declare class Comment {
|
|
|
151
181
|
*/
|
|
152
182
|
fromRawComment(rawComment: string): Comment;
|
|
153
183
|
}
|
|
154
|
-
import Pin from "./Pin";
|
|
155
184
|
import User from "./User";
|
|
156
185
|
import File from "./File";
|
package/lib/models/Comment.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _User=require("./User");var _User2=_interopRequireDefault(_User);var
|
|
1
|
+
"use strict";exports.__esModule=true;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _File=require("./File");var _File2=_interopRequireDefault(_File);var _parseComment=require("../util/comments/parseComment");var _parseComment2=_interopRequireDefault(_parseComment);var _getCommentState=require("../util/comments/getCommentState");var _getCommentState2=_interopRequireDefault(_getCommentState);var _parsePins=require("../util/pins/parsePins");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")}}var commentSchema={id:"CommentId",proofId:"ProofId",pins:function pins(data){return(0,_parsePins.parsePins)(data.XY).map(function(pin,index){if(index===0&&data.BoxFillType){return _extends({},pin,{fill:data.BoxFillType&&{type:data.BoxFillType,image:data.BoxFillImage}})}return pin})},pin:function pin(){return this.pins[0]},user:function user(data){return(new _User2.default).fromUser(data)},comment$:"EncryptedComment",envelope:"Envelope",attachments:function attachments(data){if(data.Attachments){return data.Attachments.map(function(attachment){return(new _File2.default).fromCommentAttachment(_extends({CommentId:data.CommentId},attachment))})}return[]},agreeCount:function agreeCount(data){return data.Agrees.length},pageNumber:(0,_transform.number)("Page"),mediaTime:function mediaTime(){return this.pin&&this.pin.time},mediaDuration:function mediaDuration(){return this.pin&&this.pin.duration},createdDate:(0,_transform.date)("Timestamp"),updatedDate:(0,_transform.date)("Updated"),parentCommentId:(0,_transform.optional)("Parent"),metadata:(0,_transform.json)("Metadata",{}),state:function state(data){return(0,_getCommentState2.default)(data)}};var Comment=function(){function Comment(){_classCallCheck(this,Comment)}Comment.prototype.fromComment=function fromComment(commentData){(0,_transform2.default)(this,commentSchema,commentData);return this};Comment.prototype.fromRawComment=function fromRawComment(rawComment){var parsed=(0,_parseComment2.default)(rawComment);this.raw=rawComment;this.tokens=parsed;return this};return Comment}();exports.default=Comment;
|
package/lib/models/User.d.ts
CHANGED
|
@@ -107,6 +107,12 @@ declare class User {
|
|
|
107
107
|
* @type {string}
|
|
108
108
|
*/
|
|
109
109
|
teamId: string;
|
|
110
|
+
/**
|
|
111
|
+
* Whether the user is required to enter a TOTP (MFA) upon logging into PageProof.
|
|
112
|
+
*
|
|
113
|
+
* @type {boolean}
|
|
114
|
+
*/
|
|
115
|
+
hasTOTP: boolean;
|
|
110
116
|
/**
|
|
111
117
|
* @private
|
|
112
118
|
* @param {object} userJSON The serialised user object
|
package/lib/models/User.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);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")}}var userSchema={id:"UserId",name:"Name",email:"Email",hasActivated:"Activated",hasRegistered:"IsRegistered",hasAvatar:"HasAvatar",accountType:"AccountType",teamType:"TeamType",teamLogo:"Branding.LogoURL",registeredDate:(0,_transform.date)("Registered"),lastLoginDate:(0,_transform.date)("LastLogin"),lastUploadDate:(0,_transform.date)("LastUpload"),isAdmin:"IsDomainAdmin",features:"Features",teamId:"DomainId"};var User=function(){function User(){_classCallCheck(this,User)}User.prototype.fromJSON=function fromJSON(userJSON){(0,_transform2.default)(this,Object.keys(userSchema),userJSON);return this};User.prototype.fromUser=function fromUser(userData){(0,_transform2.default)(this,userSchema,userData);return this};return User}();exports.default=User;
|
|
1
|
+
"use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);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")}}var userSchema={id:"UserId",name:"Name",email:"Email",hasActivated:"Activated",hasRegistered:"IsRegistered",hasAvatar:"HasAvatar",accountType:"AccountType",teamType:"TeamType",teamLogo:"Branding.LogoURL",registeredDate:(0,_transform.date)("Registered"),lastLoginDate:(0,_transform.date)("LastLogin"),lastUploadDate:(0,_transform.date)("LastUpload"),isAdmin:"IsDomainAdmin",features:"Features",teamId:"DomainId",hasTOTP:"TotpEnabled"};var User=function(){function User(){_classCallCheck(this,User)}User.prototype.fromJSON=function fromJSON(userJSON){(0,_transform2.default)(this,Object.keys(userSchema),userJSON);return this};User.prototype.fromUser=function fromUser(userData){(0,_transform2.default)(this,userSchema,userData);return this};return User}();exports.default=User;
|
package/lib/models/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Comment from "./Comment";
|
|
2
2
|
import File from "./File";
|
|
3
|
-
import Pin from "./Pin";
|
|
4
3
|
import Proof from "./Proof";
|
|
5
4
|
import ProofGroup from "./ProofGroup";
|
|
6
5
|
import ProofVersion from "./ProofVersion";
|
|
@@ -9,4 +8,4 @@ import User from "./User";
|
|
|
9
8
|
import Workflow from "./Workflow";
|
|
10
9
|
import WorkflowStep from "./WorkflowStep";
|
|
11
10
|
import WorkflowUser from "./WorkflowUser";
|
|
12
|
-
export { Comment, File,
|
|
11
|
+
export { Comment, File, Proof, ProofGroup, ProofVersion, Session, User, Workflow, WorkflowStep, WorkflowUser };
|
package/lib/models/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;exports.WorkflowUser=exports.WorkflowStep=exports.Workflow=exports.User=exports.Session=exports.ProofVersion=exports.ProofGroup=exports.Proof=exports.
|
|
1
|
+
"use strict";exports.__esModule=true;exports.WorkflowUser=exports.WorkflowStep=exports.Workflow=exports.User=exports.Session=exports.ProofVersion=exports.ProofGroup=exports.Proof=exports.File=exports.Comment=undefined;var _Comment=require("./Comment");var _Comment2=_interopRequireDefault(_Comment);var _File=require("./File");var _File2=_interopRequireDefault(_File);var _Proof=require("./Proof");var _Proof2=_interopRequireDefault(_Proof);var _ProofGroup=require("./ProofGroup");var _ProofGroup2=_interopRequireDefault(_ProofGroup);var _ProofVersion=require("./ProofVersion");var _ProofVersion2=_interopRequireDefault(_ProofVersion);var _Session=require("./Session");var _Session2=_interopRequireDefault(_Session);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _Workflow=require("./Workflow");var _Workflow2=_interopRequireDefault(_Workflow);var _WorkflowStep=require("./WorkflowStep");var _WorkflowStep2=_interopRequireDefault(_WorkflowStep);var _WorkflowUser=require("./WorkflowUser");var _WorkflowUser2=_interopRequireDefault(_WorkflowUser);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.Comment=_Comment2.default;exports.File=_File2.default;exports.Proof=_Proof2.default;exports.ProofGroup=_ProofGroup2.default;exports.ProofVersion=_ProofVersion2.default;exports.Session=_Session2.default;exports.User=_User2.default;exports.Workflow=_Workflow2.default;exports.WorkflowStep=_WorkflowStep2.default;exports.WorkflowUser=_WorkflowUser2.default;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"accounts.login": {
|
|
9
9
|
"method": "POST",
|
|
10
10
|
"path": "/api/users/login",
|
|
11
|
-
"body": ["email", "password"],
|
|
11
|
+
"body": ["email", "password", "totp"],
|
|
12
12
|
"anonymous": true
|
|
13
13
|
},
|
|
14
14
|
"accounts.generate-activation-code": {
|
|
@@ -961,6 +961,20 @@
|
|
|
961
961
|
"body": ["email"],
|
|
962
962
|
"anonymous": true
|
|
963
963
|
},
|
|
964
|
+
"mfa.setup": {
|
|
965
|
+
"method": "POST",
|
|
966
|
+
"path": "/api/users/mfa/setup"
|
|
967
|
+
},
|
|
968
|
+
"mfa.enable": {
|
|
969
|
+
"method": "POST",
|
|
970
|
+
"path": "/api/users/mfa/enable",
|
|
971
|
+
"body": ["totp"]
|
|
972
|
+
},
|
|
973
|
+
"mfa.remove": {
|
|
974
|
+
"method": "POST",
|
|
975
|
+
"path": "/api/users/mfa/remove",
|
|
976
|
+
"body": ["password"]
|
|
977
|
+
},
|
|
964
978
|
"reminders.add": {
|
|
965
979
|
"version": 2,
|
|
966
980
|
"method": "POST",
|