@docbrasil/api-systemmanager 1.0.60 → 1.0.63
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/api/user/document.js +1 -1
- package/api/user/user.js +74 -0
- package/dist/bundle.cjs +75 -0
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +58 -252
- package/package.json +1 -1
package/doc/api.md
CHANGED
|
@@ -37,21 +37,12 @@
|
|
|
37
37
|
<dt><a href="#AdminUser">AdminUser</a></dt>
|
|
38
38
|
<dd><p>Admin Class for user, permission admin</p>
|
|
39
39
|
</dd>
|
|
40
|
-
<dt><a href="#Dispatch">Dispatch</a></dt>
|
|
41
|
-
<dd><p>Api dispatch manager</p>
|
|
42
|
-
</dd>
|
|
43
40
|
<dt><a href="#GeoLocation">GeoLocation</a></dt>
|
|
44
41
|
<dd><p>General Class for user, permission organization</p>
|
|
45
42
|
</dd>
|
|
46
43
|
<dt><a href="#Users">Users</a></dt>
|
|
47
44
|
<dd><p>API request, user permission level</p>
|
|
48
45
|
</dd>
|
|
49
|
-
<dt><a href="#Login">Login</a></dt>
|
|
50
|
-
<dd><p>Login manager</p>
|
|
51
|
-
</dd>
|
|
52
|
-
<dt><a href="#Session">Session</a></dt>
|
|
53
|
-
<dd><p>Session manager of the API</p>
|
|
54
|
-
</dd>
|
|
55
46
|
<dt><a href="#Documents">Documents</a></dt>
|
|
56
47
|
<dd><p>Class for documents, permission user</p>
|
|
57
48
|
</dd>
|
|
@@ -1130,52 +1121,6 @@ const payload = {
|
|
|
1130
1121
|
};
|
|
1131
1122
|
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1132
1123
|
```
|
|
1133
|
-
<a name="Dispatch"></a>
|
|
1134
|
-
|
|
1135
|
-
## Dispatch
|
|
1136
|
-
Api dispatch manager
|
|
1137
|
-
|
|
1138
|
-
**Kind**: global class
|
|
1139
|
-
|
|
1140
|
-
* [Dispatch](#Dispatch)
|
|
1141
|
-
* [.getContext(url, session)](#Dispatch+getContext) ⇒ <code>Promise.<object></code>
|
|
1142
|
-
* [.getClient()](#Dispatch+getClient) ⇒ <code>promise</code>
|
|
1143
|
-
|
|
1144
|
-
<a name="Dispatch+getContext"></a>
|
|
1145
|
-
|
|
1146
|
-
### dispatch.getContext(url, session) ⇒ <code>Promise.<object></code>
|
|
1147
|
-
Get the URL context
|
|
1148
|
-
|
|
1149
|
-
**Kind**: instance method of [<code>Dispatch</code>](#Dispatch)
|
|
1150
|
-
**Returns**: <code>Promise.<object></code> - The full data context of the URL
|
|
1151
|
-
**Access**: public
|
|
1152
|
-
|
|
1153
|
-
| Param | Type | Default | Description |
|
|
1154
|
-
| --- | --- | --- | --- |
|
|
1155
|
-
| url | <code>string</code> | | Full url |
|
|
1156
|
-
| session | <code>session</code> | <code></code> | Session, token JWT |
|
|
1157
|
-
|
|
1158
|
-
**Example**
|
|
1159
|
-
```js
|
|
1160
|
-
const API = require('@docbrasil/api-systemmanager');
|
|
1161
|
-
const api = new API();
|
|
1162
|
-
const retContext = await api.dispatch.getContext('http://myndware.io/login/myorg);
|
|
1163
|
-
```
|
|
1164
|
-
<a name="Dispatch+getClient"></a>
|
|
1165
|
-
|
|
1166
|
-
### dispatch.getClient() ⇒ <code>promise</code>
|
|
1167
|
-
Get client Axios
|
|
1168
|
-
|
|
1169
|
-
**Kind**: instance method of [<code>Dispatch</code>](#Dispatch)
|
|
1170
|
-
**Returns**: <code>promise</code> - return client axios
|
|
1171
|
-
**Access**: public
|
|
1172
|
-
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1173
|
-
**Example**
|
|
1174
|
-
```js
|
|
1175
|
-
const API = require('@docbrasil/api-systemmanager');
|
|
1176
|
-
const api = new API();
|
|
1177
|
-
await api.dispatch.getClient();
|
|
1178
|
-
```
|
|
1179
1124
|
<a name="GeoLocation"></a>
|
|
1180
1125
|
|
|
1181
1126
|
## GeoLocation
|
|
@@ -1237,203 +1182,6 @@ API request, user permission level
|
|
|
1237
1182
|
| options | <code>object</code> | Params of the constructor |
|
|
1238
1183
|
| options.parent | <code>object</code> | This of the pararent |
|
|
1239
1184
|
|
|
1240
|
-
<a name="Login"></a>
|
|
1241
|
-
|
|
1242
|
-
## Login
|
|
1243
|
-
Login manager
|
|
1244
|
-
|
|
1245
|
-
**Kind**: global class
|
|
1246
|
-
|
|
1247
|
-
* [Login](#Login)
|
|
1248
|
-
* [.facebook(params)](#Login+facebook) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1249
|
-
* [.google(params)](#Login+google) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1250
|
-
* [.apiKey(apikey)](#Login+apiKey) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1251
|
-
* [.userPass(params)](#Login+userPass) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1252
|
-
* [.logout(session)](#Login+logout) ⇒ <code>promise.<object></code> \| <code>boolean</code>
|
|
1253
|
-
* [.recover(username)](#Login+recover) ⇒ <code>promise.<object></code> \| <code>boolean</code>
|
|
1254
|
-
|
|
1255
|
-
<a name="Login+facebook"></a>
|
|
1256
|
-
|
|
1257
|
-
### login.facebook(params) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1258
|
-
Login with social login Facebook
|
|
1259
|
-
|
|
1260
|
-
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1261
|
-
**Returns**: <code>promise.<object></code> - data<code>object</code> - data.auth true or false if we have the user authenticaited correctly<code>object</code> - data.user the logged user
|
|
1262
|
-
**Access**: public
|
|
1263
|
-
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1264
|
-
|
|
1265
|
-
| Param | Type | Description |
|
|
1266
|
-
| --- | --- | --- |
|
|
1267
|
-
| params | <code>object</code> | Params to login Facebook |
|
|
1268
|
-
| params.accessToken | <code>string</code> | Access token of the system manager |
|
|
1269
|
-
| params.initialUserData | <code>object</code> | Object with roles default if sigin |
|
|
1270
|
-
| params.initialUserData.externalRoles | <code>array</code> | Array with permission of user |
|
|
1271
|
-
|
|
1272
|
-
**Example**
|
|
1273
|
-
```js
|
|
1274
|
-
const API = require('@docbrasil/api-systemmanager');
|
|
1275
|
-
|
|
1276
|
-
// Params of the instance
|
|
1277
|
-
const params = {...}
|
|
1278
|
-
const api = new API(params);
|
|
1279
|
-
const params = { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cC...' };
|
|
1280
|
-
const { auth, user } = await api.login.facebook(params);
|
|
1281
|
-
```
|
|
1282
|
-
<a name="Login+google"></a>
|
|
1283
|
-
|
|
1284
|
-
### login.google(params) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1285
|
-
Login with social login Google
|
|
1286
|
-
|
|
1287
|
-
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1288
|
-
**Returns**: <code>promise.<object></code> - data<code>object</code> - data.auth true or false if we have the user authenticaited correctly<code>object</code> - data.user the logged user
|
|
1289
|
-
**Access**: public
|
|
1290
|
-
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1291
|
-
|
|
1292
|
-
| Param | Type | Description |
|
|
1293
|
-
| --- | --- | --- |
|
|
1294
|
-
| params | <code>object</code> | Params to login Google |
|
|
1295
|
-
| params.accessToken | <code>string</code> | Access token of the system manager |
|
|
1296
|
-
| params.initialUserData | <code>object</code> | Object with roles default if sigin |
|
|
1297
|
-
| params.initialUserData.externalRoles | <code>array</code> | Array with permission of user |
|
|
1298
|
-
|
|
1299
|
-
**Example**
|
|
1300
|
-
```js
|
|
1301
|
-
const API = require('@docbrasil/api-systemmanager');
|
|
1302
|
-
|
|
1303
|
-
// Params of the instance
|
|
1304
|
-
const params = {...}
|
|
1305
|
-
const api = new API(params);
|
|
1306
|
-
const accessToken = 'eyJhbGciOiJIUzI1NiIsInR5cC...';
|
|
1307
|
-
const { auth, user } = await api.login.google(accessToken);
|
|
1308
|
-
```
|
|
1309
|
-
<a name="Login+apiKey"></a>
|
|
1310
|
-
|
|
1311
|
-
### login.apiKey(apikey) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1312
|
-
Login with apikey
|
|
1313
|
-
|
|
1314
|
-
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1315
|
-
**Returns**: <code>promise.<object></code> - data<code>object</code> - data.auth true or false if we have the user authenticaited correctly<code>object</code> - data.user the logged user
|
|
1316
|
-
**Access**: public
|
|
1317
|
-
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1318
|
-
|
|
1319
|
-
| Param | Type | Description |
|
|
1320
|
-
| --- | --- | --- |
|
|
1321
|
-
| apikey | <code>string</code> | Access key |
|
|
1322
|
-
|
|
1323
|
-
**Example**
|
|
1324
|
-
```js
|
|
1325
|
-
const API = require('@docbrasil/api-systemmanager');
|
|
1326
|
-
|
|
1327
|
-
// Params of the instance
|
|
1328
|
-
const params = {...}
|
|
1329
|
-
const api = new API(params);
|
|
1330
|
-
const apiKey = '043a0eb2-f5c3-4900-b781-7f229d00d092';
|
|
1331
|
-
const { auth, user } = await api.login.apiKey(apiKey);
|
|
1332
|
-
```
|
|
1333
|
-
<a name="Login+userPass"></a>
|
|
1334
|
-
|
|
1335
|
-
### login.userPass(params) ⇒ <code>promise.<object></code> \| <code>object</code> \| <code>object</code>
|
|
1336
|
-
Login with user and password
|
|
1337
|
-
|
|
1338
|
-
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1339
|
-
**Returns**: <code>promise.<object></code> - data<code>object</code> - data.auth true or false if we have the user authenticaited correctly<code>object</code> - data.user the logged user
|
|
1340
|
-
**Access**: public
|
|
1341
|
-
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1342
|
-
|
|
1343
|
-
| Param | Type | Description |
|
|
1344
|
-
| --- | --- | --- |
|
|
1345
|
-
| params | <code>object</code> | Object with user and password |
|
|
1346
|
-
| params.username | <code>string</code> | Username or email of the user |
|
|
1347
|
-
| params.password | <code>string</code> | Password of the user |
|
|
1348
|
-
| params.orgname | <code>string</code> | The organame of the user |
|
|
1349
|
-
|
|
1350
|
-
**Example**
|
|
1351
|
-
```js
|
|
1352
|
-
const API = require('@docbrasil/api-systemmanager');
|
|
1353
|
-
|
|
1354
|
-
// Params of the instance
|
|
1355
|
-
const params = {...}
|
|
1356
|
-
const api = new API(params);
|
|
1357
|
-
const params = {
|
|
1358
|
-
username: 'ana.silva@gmail.com',
|
|
1359
|
-
password: '123456'
|
|
1360
|
-
};
|
|
1361
|
-
const { auth, user } = await api.login.userPass(params);
|
|
1362
|
-
```
|
|
1363
|
-
<a name="Login+logout"></a>
|
|
1364
|
-
|
|
1365
|
-
### login.logout(session) ⇒ <code>promise.<object></code> \| <code>boolean</code>
|
|
1366
|
-
Logout user system manager
|
|
1367
|
-
|
|
1368
|
-
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1369
|
-
**Returns**: <code>promise.<object></code> - } data<code>boolean</code> - data.success true|false
|
|
1370
|
-
**Access**: public
|
|
1371
|
-
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1372
|
-
|
|
1373
|
-
| Param | Type | Description |
|
|
1374
|
-
| --- | --- | --- |
|
|
1375
|
-
| session | <code>string</code> | Session, token JWT |
|
|
1376
|
-
|
|
1377
|
-
**Example**
|
|
1378
|
-
```js
|
|
1379
|
-
const API = require('@docbrasil/api-systemmanager');
|
|
1380
|
-
|
|
1381
|
-
// Params of the instance
|
|
1382
|
-
const params = {...}
|
|
1383
|
-
const api = new API(params);
|
|
1384
|
-
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1385
|
-
const { success } = await api.login.logout(session);
|
|
1386
|
-
```
|
|
1387
|
-
<a name="Login+recover"></a>
|
|
1388
|
-
|
|
1389
|
-
### login.recover(username) ⇒ <code>promise.<object></code> \| <code>boolean</code>
|
|
1390
|
-
Recover the password
|
|
1391
|
-
|
|
1392
|
-
**Kind**: instance method of [<code>Login</code>](#Login)
|
|
1393
|
-
**Returns**: <code>promise.<object></code> - } data<code>boolean</code> - data.success true|false
|
|
1394
|
-
**Access**: public
|
|
1395
|
-
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
1396
|
-
|
|
1397
|
-
| Param | Type | Description |
|
|
1398
|
-
| --- | --- | --- |
|
|
1399
|
-
| username | <code>string</code> | The username or email |
|
|
1400
|
-
|
|
1401
|
-
**Example**
|
|
1402
|
-
```js
|
|
1403
|
-
const API = require('@docbrasil/api-systemmanager');
|
|
1404
|
-
|
|
1405
|
-
// Params of the instance
|
|
1406
|
-
const params = {...}
|
|
1407
|
-
const api = new API(params);
|
|
1408
|
-
const { success } = await api.login.recover('myusername');
|
|
1409
|
-
```
|
|
1410
|
-
<a name="Session"></a>
|
|
1411
|
-
|
|
1412
|
-
## Session
|
|
1413
|
-
Session manager of the API
|
|
1414
|
-
|
|
1415
|
-
**Kind**: global class
|
|
1416
|
-
<a name="Session+information"></a>
|
|
1417
|
-
|
|
1418
|
-
### session.information(sessionId, suSessionId) ⇒ <code>Promise</code>
|
|
1419
|
-
Show information for session, thus validating the session (Valid token JWT)
|
|
1420
|
-
|
|
1421
|
-
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
1422
|
-
**Access**: public
|
|
1423
|
-
|
|
1424
|
-
| Param | Type | Default | Description |
|
|
1425
|
-
| --- | --- | --- | --- |
|
|
1426
|
-
| sessionId | <code>string</code> | | The user session (JWT Token) |
|
|
1427
|
-
| suSessionId | <code>string</code> | <code>"sessionId"</code> | Given a JWT Token of a SU (SuperAdmin), allow to check session for another user. |
|
|
1428
|
-
|
|
1429
|
-
**Example**
|
|
1430
|
-
```js
|
|
1431
|
-
const API = require('@docbrasil/api-systemmanager');
|
|
1432
|
-
const api = new API();
|
|
1433
|
-
const sessionId = 'eyJhbFVBBiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1434
|
-
const suSessionId = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1435
|
-
await api.session.information(sessionId, suSessionId);
|
|
1436
|
-
```
|
|
1437
1185
|
<a name="Documents"></a>
|
|
1438
1186
|
|
|
1439
1187
|
## Documents
|
|
@@ -2195,6 +1943,8 @@ Class for user, permission user
|
|
|
2195
1943
|
* [User](#User)
|
|
2196
1944
|
* [.updateAvatar(params, session)](#User+updateAvatar) ⇒ <code>Promise</code>
|
|
2197
1945
|
* [.removeAvatar(session)](#User+removeAvatar) ⇒ <code>Promise</code>
|
|
1946
|
+
* [.removeSignature(session)](#User+removeSignature) ⇒ <code>Promise</code>
|
|
1947
|
+
* [.saveSignature(data, session)](#User+saveSignature) ⇒ <code>Promise</code>
|
|
2198
1948
|
* [.findByIdAndUpdate(params, session)](#User+findByIdAndUpdate) ⇒ <code>Promise.<void></code>
|
|
2199
1949
|
|
|
2200
1950
|
<a name="User+updateAvatar"></a>
|
|
@@ -2244,6 +1994,62 @@ const api = new API();
|
|
|
2244
1994
|
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2245
1995
|
await api.user.profile.removeAvatar(session);
|
|
2246
1996
|
```
|
|
1997
|
+
<a name="User+removeSignature"></a>
|
|
1998
|
+
|
|
1999
|
+
### user.removeSignature(session) ⇒ <code>Promise</code>
|
|
2000
|
+
Remove the signature of user by session
|
|
2001
|
+
|
|
2002
|
+
**Kind**: instance method of [<code>User</code>](#User)
|
|
2003
|
+
**Access**: public
|
|
2004
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
2005
|
+
|
|
2006
|
+
| Param | Type | Description |
|
|
2007
|
+
| --- | --- | --- |
|
|
2008
|
+
| session | <code>string</code> | Is token JWT of user NOT allow SU |
|
|
2009
|
+
|
|
2010
|
+
**Example**
|
|
2011
|
+
```js
|
|
2012
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
2013
|
+
const api = new API();
|
|
2014
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2015
|
+
await api.user.profile.removeSignature(session);
|
|
2016
|
+
```
|
|
2017
|
+
<a name="User+saveSignature"></a>
|
|
2018
|
+
|
|
2019
|
+
### user.saveSignature(data, session) ⇒ <code>Promise</code>
|
|
2020
|
+
Sava a new signature of user by session
|
|
2021
|
+
|
|
2022
|
+
**Kind**: instance method of [<code>User</code>](#User)
|
|
2023
|
+
**Access**: public
|
|
2024
|
+
**Author**: CloudBrasil <abernardo.br@gmail.com>
|
|
2025
|
+
|
|
2026
|
+
| Param | Type | Description |
|
|
2027
|
+
| --- | --- | --- |
|
|
2028
|
+
| data | <code>object</code> | The signature data to save |
|
|
2029
|
+
| data.type | <code>string</code> | CURSIVE or HANDWRITE |
|
|
2030
|
+
| data.file | <code>string</code> | CURSIVE the <fontname>:<name used on the signature> HANDWRITE the base 64 image (w/o the mime a base prefix) |
|
|
2031
|
+
| session | <code>string</code> | Is token JWT of user NOT allow SU |
|
|
2032
|
+
|
|
2033
|
+
**Example**
|
|
2034
|
+
```js
|
|
2035
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
2036
|
+
const api = new API();
|
|
2037
|
+
const data = {
|
|
2038
|
+
type: 'CURSIVE',
|
|
2039
|
+
file: 'allura:Mary John Heart'
|
|
2040
|
+
};
|
|
2041
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2042
|
+
await api.user.profile.saveSignature(data, session);
|
|
2043
|
+
|
|
2044
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
2045
|
+
const api = new API();
|
|
2046
|
+
const data = {
|
|
2047
|
+
type: 'HANDWRITE',
|
|
2048
|
+
file: 'iVBORw0KGgoAAAANSUhEUgAAAj...'
|
|
2049
|
+
};
|
|
2050
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2051
|
+
await api.user.profile.saveSignature(session);
|
|
2052
|
+
```
|
|
2247
2053
|
<a name="User+findByIdAndUpdate"></a>
|
|
2248
2054
|
|
|
2249
2055
|
### user.findByIdAndUpdate(params, session) ⇒ <code>Promise.<void></code>
|
package/package.json
CHANGED