opengate-js 13.0.0 → 13.2.0
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/bower.json +1 -1
- package/dist/{opengate-api-bower-13.0.0.js → opengate-api-bower-13.2.0.js} +1189 -236
- package/dist/opengate-api-bower-13.2.0.js.map +1 -0
- package/dist/opengate-api-bower-13.2.0.min.js +62 -0
- package/dist/opengate-api-bower-13.2.0.min.js.map +1 -0
- package/dist/src/users/Users.js +64 -7
- package/dist/src/users/Users.js.map +1 -1
- package/dist/src/util/searchingFields/IotFields.js +2 -1
- package/dist/src/util/searchingFields/IotFields.js.map +1 -1
- package/docs/ast/source/users/Users.js.json +21752 -13474
- package/docs/ast/source/util/searchingFields/IotFields.js.json +556 -392
- package/docs/class/src/users/Users.js~User.html +336 -19
- package/docs/coverage.json +8 -6
- package/docs/dump.json +686 -490
- package/docs/file/src/users/Users.js.html +58 -4
- package/docs/file/src/util/searchingFields/IotFields.js.html +2 -1
- package/docs/package.json +4 -3
- package/docs/script/search_index.js +18 -0
- package/docs/source.html +237 -237
- package/features/features/provision/users/update_password.feature +11 -0
- package/features/features/provision/users/update_user.feature +3 -0
- package/features/step_definitions/when_step_definitions.js +29 -0
- package/features/support/create_provision_model.js +3 -1
- package/package.json +4 -3
- package/scripts/compile_sources.js +2 -2
- package/src/users/Users.js +58 -4
- package/src/util/searchingFields/IotFields.js +2 -1
- package/dist/opengate-api-bower-13.0.0.js.map +0 -1
- package/dist/opengate-api-bower-13.0.0.min.js +0 -47
- package/dist/opengate-api-bower-13.0.0.min.js.map +0 -1
|
@@ -291,8 +291,10 @@
|
|
|
291
291
|
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">'use strict';
|
|
292
292
|
|
|
293
293
|
import BaseProvision from '../provision/BaseProvision';
|
|
294
|
-
import q from 'q';
|
|
295
294
|
import _ from 'lodash';
|
|
295
|
+
import { version as uuidVersion } from 'uuid';
|
|
296
|
+
import { validate as uuidValidate } from 'uuid';
|
|
297
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
296
298
|
|
|
297
299
|
const _length_name = 100;
|
|
298
300
|
const _length_surname = 100;
|
|
@@ -362,6 +364,19 @@ export default class User extends BaseProvision {
|
|
|
362
364
|
return this;
|
|
363
365
|
}
|
|
364
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Set the apiKey attribute. Only on update user
|
|
369
|
+
* @param {string} apiKey - required field
|
|
370
|
+
* @return {User}
|
|
371
|
+
*/
|
|
372
|
+
withApiKey(apiKey) {
|
|
373
|
+
if(!this._validateUUID(apiKey)){
|
|
374
|
+
throw new Error({ message: "OGAPI_USER_UPDATE_APIKEY_PARAMETER_INVALID", parameter: 'apiKey' });
|
|
375
|
+
}
|
|
376
|
+
this._apiKey = apiKey;
|
|
377
|
+
return this;
|
|
378
|
+
}
|
|
379
|
+
|
|
365
380
|
/**
|
|
366
381
|
* Set the workgroup attribute
|
|
367
382
|
* @param {string} workgroup - required field
|
|
@@ -509,9 +524,6 @@ export default class User extends BaseProvision {
|
|
|
509
524
|
* @private
|
|
510
525
|
*/
|
|
511
526
|
_composeUpdateElement() {
|
|
512
|
-
if (this._password) {
|
|
513
|
-
throw new Error('OGAPI_PASSWORD_NOT_ALLOWED');
|
|
514
|
-
}
|
|
515
527
|
if (this._email === undefined)
|
|
516
528
|
throw new Error('OGAPI_USER_UPDATE_PARAMETER_MUST_BE_DEFINED');
|
|
517
529
|
|
|
@@ -527,6 +539,8 @@ export default class User extends BaseProvision {
|
|
|
527
539
|
countryCode: this._countryCode || undefined,
|
|
528
540
|
langCode: this._langCode || undefined,
|
|
529
541
|
timezone: this._timezone || undefined,
|
|
542
|
+
apiKey: this._apiKey || undefined,
|
|
543
|
+
password: this._password || undefined,
|
|
530
544
|
"2FaType": this._twoFaType || undefined
|
|
531
545
|
}
|
|
532
546
|
};
|
|
@@ -563,6 +577,42 @@ export default class User extends BaseProvision {
|
|
|
563
577
|
return this._doNorthPut(this._buildURL(), data);
|
|
564
578
|
}
|
|
565
579
|
|
|
580
|
+
_validateUUID(UUID){
|
|
581
|
+
return uuidValidate(UUID) && uuidVersion(UUID) === 4
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* This invoke a request to OpenGate North API and the callback is managed by promises
|
|
585
|
+
* This function updates a apiKey of a user
|
|
586
|
+
* @return {Promise}
|
|
587
|
+
* @param {String} apiKey - required field
|
|
588
|
+
* @property {function (result:object, statusCode:number)} then - When request it is OK
|
|
589
|
+
* @property {function (error:string)} catch - When request it is NOK
|
|
590
|
+
* @example
|
|
591
|
+
* ogapi.usersBuilder().withEmail(example@example.es).withPassword(oldPassword).changeApiKey(newPassword);
|
|
592
|
+
*/
|
|
593
|
+
changeApiKey(apiKey) {
|
|
594
|
+
this._apiKey = apiKey;
|
|
595
|
+
if (_.isEmpty(this._email) || _.isEmpty(this._password) || _.isEmpty(this._apiKey)) {
|
|
596
|
+
throw new Error('OGAPI_USER_UPDATE_APIKEY_PARAMETER_MUST_BE_DEFINED');
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
if(!this._validateUUID(apiKey)){
|
|
600
|
+
throw new Error({ message: "OGAPI_USER_UPDATE_APIKEY_PARAMETER_INVALID", parameter: 'apiKey' });
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
var data = {
|
|
604
|
+
user: {
|
|
605
|
+
apiKey: this._apiKey
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
this._setExtraHeaders({
|
|
610
|
+
'X-ApiPass': this._password
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
return this._doNorthPut(this._buildURL(), data);
|
|
614
|
+
}
|
|
615
|
+
|
|
566
616
|
/**
|
|
567
617
|
* This invoke a request to OpenGate North API and the callback is managed by promises
|
|
568
618
|
* This function request for new password when the user forgets it.
|
|
@@ -645,6 +695,10 @@ export default class User extends BaseProvision {
|
|
|
645
695
|
|
|
646
696
|
return this._doNorthPost(url, data, true)
|
|
647
697
|
}
|
|
698
|
+
|
|
699
|
+
generateApiKey(){
|
|
700
|
+
return uuidv4()
|
|
701
|
+
}
|
|
648
702
|
}</code></pre>
|
|
649
703
|
|
|
650
704
|
</div>
|
|
@@ -576,7 +576,8 @@ export const IOT_FIELDS = {
|
|
|
576
576
|
"alarmAttentionNote": "alarm.attentionNote",
|
|
577
577
|
"alarmClosureDate": "alarm.closureDate",
|
|
578
578
|
"alarmClosureUser": "alarm.closureUser",
|
|
579
|
-
"alarmClosureNote": "alarm.closureNote"
|
|
579
|
+
"alarmClosureNote": "alarm.closureNote",
|
|
580
|
+
"alarmExtraInfo": "alarm.extra_info"
|
|
580
581
|
}
|
|
581
582
|
},
|
|
582
583
|
"GENERAL": {
|
package/docs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opengate-js",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/opengate-api-npm.js",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"superagent": "^3.8.3",
|
|
29
29
|
"superagent-mocker": "^0.5.2",
|
|
30
30
|
"underscore": "^1.9.0",
|
|
31
|
-
"urlencode": "^1.1.0"
|
|
31
|
+
"urlencode": "^1.1.0",
|
|
32
|
+
"uuid": "9.0.1"
|
|
32
33
|
},
|
|
33
34
|
"scripts": {
|
|
34
35
|
"test-wip": "export NODE_OPTIONS='--max-old-space-size=8192'; gulp cucumber --tags @wip"
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"gulp-rename": "^1.2.2",
|
|
55
56
|
"gulp-sourcemaps": "^1.5.2",
|
|
56
57
|
"gulp-tag-version": "^1.3.0",
|
|
57
|
-
"gulp-
|
|
58
|
+
"gulp-terser": "^2.1.0",
|
|
58
59
|
"gulp-ver": "^0.1.0",
|
|
59
60
|
"jsdom": "^16.4.0",
|
|
60
61
|
"minimist": "^1.2.5",
|
|
@@ -10829,6 +10829,12 @@ window.esdocSearchIndex = [
|
|
|
10829
10829
|
"src/users/Users.js",
|
|
10830
10830
|
"file"
|
|
10831
10831
|
],
|
|
10832
|
+
[
|
|
10833
|
+
"src/users/users.js~user#changeapikey",
|
|
10834
|
+
"class/src/users/Users.js~User.html#instance-method-changeApiKey",
|
|
10835
|
+
"src/users/Users.js~User#changeApiKey",
|
|
10836
|
+
"method"
|
|
10837
|
+
],
|
|
10832
10838
|
[
|
|
10833
10839
|
"src/users/users.js~user#changepassword",
|
|
10834
10840
|
"class/src/users/Users.js~User.html#instance-method-changePassword",
|
|
@@ -10841,6 +10847,12 @@ window.esdocSearchIndex = [
|
|
|
10841
10847
|
"src/users/Users.js~User#constructor",
|
|
10842
10848
|
"method"
|
|
10843
10849
|
],
|
|
10850
|
+
[
|
|
10851
|
+
"src/users/users.js~user#generateapikey",
|
|
10852
|
+
"class/src/users/Users.js~User.html#instance-method-generateApiKey",
|
|
10853
|
+
"src/users/Users.js~User#generateApiKey",
|
|
10854
|
+
"method"
|
|
10855
|
+
],
|
|
10844
10856
|
[
|
|
10845
10857
|
"src/users/users.js~user#login",
|
|
10846
10858
|
"class/src/users/Users.js~User.html#instance-method-login",
|
|
@@ -10865,6 +10877,12 @@ window.esdocSearchIndex = [
|
|
|
10865
10877
|
"src/users/Users.js~User#with2FaType",
|
|
10866
10878
|
"method"
|
|
10867
10879
|
],
|
|
10880
|
+
[
|
|
10881
|
+
"src/users/users.js~user#withapikey",
|
|
10882
|
+
"class/src/users/Users.js~User.html#instance-method-withApiKey",
|
|
10883
|
+
"src/users/Users.js~User#withApiKey",
|
|
10884
|
+
"method"
|
|
10885
|
+
],
|
|
10868
10886
|
[
|
|
10869
10887
|
"src/users/users.js~user#withcountrycode",
|
|
10870
10888
|
"class/src/users/Users.js~User.html#instance-method-withCountryCode",
|