@inweb/client 25.4.11 → 25.6.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/dist/client.js CHANGED
@@ -4,6 +4,125 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ODA = global.ODA || {}, global.ODA.Api = global.ODA.Api || {})));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
+ ///////////////////////////////////////////////////////////////////////////////
8
+ // Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
9
+ // All rights reserved.
10
+ //
11
+ // This software and its documentation and related materials are owned by
12
+ // the Alliance. The software may only be incorporated into application
13
+ // programs owned by members of the Alliance, subject to a signed
14
+ // Membership Agreement and Supplemental Software License Agreement with the
15
+ // Alliance. The structure and organization of this software are the valuable
16
+ // trade secrets of the Alliance and its suppliers. The software is also
17
+ // protected by copyright law and international treaty provisions. Application
18
+ // programs incorporating this software must include the following statement
19
+ // with their copyright notices:
20
+ //
21
+ // This application incorporates Open Design Alliance software pursuant to a
22
+ // license agreement with Open Design Alliance.
23
+ // Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
24
+ // All rights reserved.
25
+ //
26
+ // By use of this software, its documentation or related materials, you
27
+ // acknowledge and accept the above terms.
28
+ ///////////////////////////////////////////////////////////////////////////////
29
+ const STATUS_CODES = {
30
+ 100: "Continue",
31
+ 101: "Switching Protocols",
32
+ 102: "Processing",
33
+ 103: "Early Hints",
34
+ 200: "OK",
35
+ 201: "Created",
36
+ 202: "Accepted",
37
+ 203: "Non-Authoritative Information",
38
+ 204: "No Content",
39
+ 205: "Reset Content",
40
+ 206: "Partial Content",
41
+ 207: "Multi-Status",
42
+ 208: "Already Reported",
43
+ 226: "IM Used",
44
+ 300: "Multiple Choices",
45
+ 301: "Moved Permanently",
46
+ 302: "Found",
47
+ 303: "See Other",
48
+ 304: "Not Modified",
49
+ 305: "Use Proxy",
50
+ 307: "Temporary Redirect",
51
+ 308: "Permanent Redirect",
52
+ 400: "Bad Request",
53
+ 401: "Unauthorized",
54
+ 402: "Payment Required",
55
+ 403: "Forbidden",
56
+ 404: "Not Found",
57
+ 405: "Method Not Allowed",
58
+ 406: "Not Acceptable",
59
+ 407: "Proxy Authentication Required",
60
+ 408: "Request Time-out",
61
+ 409: "Conflict",
62
+ 410: "Gone",
63
+ 411: "Length Required",
64
+ 412: "Precondition Failed",
65
+ 413: "Payload Too Large",
66
+ 414: "URI Too Long",
67
+ 415: "Unsupported Media Type",
68
+ 416: "Range Not Satisfiable",
69
+ 417: "Expectation Failed",
70
+ 418: "I'm a teapot",
71
+ 421: "Misdirected Request",
72
+ 422: "Unprocessable Entity",
73
+ 423: "Locked",
74
+ 424: "Failed Dependency",
75
+ 425: "Too Early",
76
+ 426: "Upgrade Required",
77
+ 428: "Precondition Required",
78
+ 429: "Too Many Requests",
79
+ 431: "Header Fields Too Large",
80
+ 451: "Unavailable For Legal Reasons",
81
+ 500: "Internal Server Error",
82
+ 501: "Not Implemented",
83
+ 502: "Bad Gateway",
84
+ 503: "Service Unavailable",
85
+ 504: "Gateway Timeout",
86
+ 505: "HTTP Version Not Supported",
87
+ 506: "Variant Also Negotiates",
88
+ 507: "Insufficient Storage",
89
+ 508: "Loop Detected",
90
+ 509: "Bandwidth Limit Exceeded",
91
+ 510: "Not Extended",
92
+ 511: "Network Authentication Required",
93
+ };
94
+ function statusText(status) {
95
+ return STATUS_CODES[status] || `Error ${status}`;
96
+ }
97
+ function error400(text, _default = "400") {
98
+ try {
99
+ return JSON.parse(text).description;
100
+ }
101
+ catch {
102
+ return _default;
103
+ }
104
+ }
105
+ /**
106
+ * The `FetchError` object indicates an error when request to Open Cloud Server could not be
107
+ * performed. A `FetchError` is typically (but not exclusively) thrown when a network error
108
+ * occurs, access denied, or object not found.
109
+ */
110
+ class FetchError extends Error {
111
+ /**
112
+ * @property status - The <a href="https://developer.mozilla.org/docs/Web/HTTP/Status" target
113
+ * ="_blank">HTTP status code</a> of the response.
114
+ * @property message - Error message. Inherited from <a
115
+ * href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error"
116
+ * target ="_blank">Error</a>.
117
+ */
118
+ constructor(status, message) {
119
+ super(message || statusText(status));
120
+ this.name = "FetchError";
121
+ this.status = status;
122
+ this.statusText = statusText(status);
123
+ }
124
+ }
125
+
7
126
  ///////////////////////////////////////////////////////////////////////////////
8
127
  // Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
9
128
  // All rights reserved.
@@ -160,8 +279,6 @@
160
279
  /**
161
280
  * Returns model viewpoint list.
162
281
  *
163
- * _**Note**: Assemblу models do not support viewpoints_.
164
- *
165
282
  * @async
166
283
  */
167
284
  getViewpoints() {
@@ -172,8 +289,6 @@
172
289
  /**
173
290
  * Add new model viewpoint. To create a new viewpoint use `Viewer.createViewpoint()`.
174
291
  *
175
- * _**Note**: Assemblу models do not support viewpoints_.
176
- *
177
292
  * @async
178
293
  * @param viewpoint - Viewpoint.
179
294
  */
@@ -186,8 +301,6 @@
186
301
  /**
187
302
  * Delete model viewpoint.
188
303
  *
189
- * _**Note**: Assemblу models do not support viewpoints_.
190
- *
191
304
  * @async
192
305
  * @param guid - Viewpoint GUID.
193
306
  * @returns Returns the raw data of a deleted viewpoint.
@@ -603,124 +716,6 @@
603
716
  }
604
717
  }
605
718
 
606
- ///////////////////////////////////////////////////////////////////////////////
607
- // Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
608
- // All rights reserved.
609
- //
610
- // This software and its documentation and related materials are owned by
611
- // the Alliance. The software may only be incorporated into application
612
- // programs owned by members of the Alliance, subject to a signed
613
- // Membership Agreement and Supplemental Software License Agreement with the
614
- // Alliance. The structure and organization of this software are the valuable
615
- // trade secrets of the Alliance and its suppliers. The software is also
616
- // protected by copyright law and international treaty provisions. Application
617
- // programs incorporating this software must include the following statement
618
- // with their copyright notices:
619
- //
620
- // This application incorporates Open Design Alliance software pursuant to a
621
- // license agreement with Open Design Alliance.
622
- // Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
623
- // All rights reserved.
624
- //
625
- // By use of this software, its documentation or related materials, you
626
- // acknowledge and accept the above terms.
627
- ///////////////////////////////////////////////////////////////////////////////
628
- const STATUS_CODES = {
629
- 100: "Continue",
630
- 101: "Switching Protocols",
631
- 102: "Processing",
632
- 103: "Early Hints",
633
- 200: "OK",
634
- 201: "Created",
635
- 202: "Accepted",
636
- 203: "Non-Authoritative Information",
637
- 204: "No Content",
638
- 205: "Reset Content",
639
- 206: "Partial Content",
640
- 207: "Multi-Status",
641
- 208: "Already Reported",
642
- 226: "IM Used",
643
- 300: "Multiple Choices",
644
- 301: "Moved Permanently",
645
- 302: "Found",
646
- 303: "See Other",
647
- 304: "Not Modified",
648
- 305: "Use Proxy",
649
- 307: "Temporary Redirect",
650
- 308: "Permanent Redirect",
651
- 400: "Bad Request",
652
- 401: "Unauthorized",
653
- 402: "Payment Required",
654
- 403: "Forbidden",
655
- 404: "Not Found",
656
- 405: "Method Not Allowed",
657
- 406: "Not Acceptable",
658
- 407: "Proxy Authentication Required",
659
- 408: "Request Time-out",
660
- 409: "Conflict",
661
- 410: "Gone",
662
- 411: "Length Required",
663
- 412: "Precondition Failed",
664
- 413: "Payload Too Large",
665
- 414: "URI Too Long",
666
- 415: "Unsupported Media Type",
667
- 416: "Range Not Satisfiable",
668
- 417: "Expectation Failed",
669
- 418: "I'm a teapot",
670
- 421: "Misdirected Request",
671
- 422: "Unprocessable Entity",
672
- 423: "Locked",
673
- 424: "Failed Dependency",
674
- 425: "Too Early",
675
- 426: "Upgrade Required",
676
- 428: "Precondition Required",
677
- 429: "Too Many Requests",
678
- 431: "Header Fields Too Large",
679
- 451: "Unavailable For Legal Reasons",
680
- 500: "Internal Server Error",
681
- 501: "Not Implemented",
682
- 502: "Bad Gateway",
683
- 503: "Service Unavailable",
684
- 504: "Gateway Timeout",
685
- 505: "HTTP Version Not Supported",
686
- 506: "Variant Also Negotiates",
687
- 507: "Insufficient Storage",
688
- 508: "Loop Detected",
689
- 509: "Bandwidth Limit Exceeded",
690
- 510: "Not Extended",
691
- 511: "Network Authentication Required",
692
- };
693
- function statusText(status) {
694
- return STATUS_CODES[status] || `Error ${status}`;
695
- }
696
- function error400(text, _default = "400") {
697
- try {
698
- return JSON.parse(text).description;
699
- }
700
- catch {
701
- return _default;
702
- }
703
- }
704
- /**
705
- * The `FetchError` object indicates an error when request to Open Cloud Server could not be
706
- * performed. A `FetchError` is typically (but not exclusively) thrown when a network error
707
- * occurs, access denied, or object not found.
708
- */
709
- class FetchError extends Error {
710
- /**
711
- * @property status - The <a href="https://developer.mozilla.org/docs/Web/HTTP/Status" target
712
- * ="_blank">HTTP status code</a> of the response.
713
- * @property message - Error message. Inherited from <a
714
- * href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error"
715
- * target ="_blank">Error</a>.
716
- */
717
- constructor(status, message) {
718
- super(message || statusText(status));
719
- this.status = status;
720
- this.statusText = statusText(status);
721
- }
722
- }
723
-
724
719
  ///////////////////////////////////////////////////////////////////////////////
725
720
  /**
726
721
  * The class representing a `assembly` entity.
@@ -1425,6 +1420,7 @@
1425
1420
  constructor(serverUrl) {
1426
1421
  this.headers = {};
1427
1422
  this.signInUserId = "";
1423
+ this.signInUserIsAdmin = false;
1428
1424
  this.serverUrl = serverUrl;
1429
1425
  }
1430
1426
  get(relativePath, signal) {
@@ -1783,7 +1779,7 @@
1783
1779
  }
1784
1780
  /**
1785
1781
  * Job type. Can be `properties`, `geomerty`, `geomertyGltf`, `validation`, `clash`, `dwg`,
1786
- * `obj`, `gltf`, `glb`, `vsf`, `pdf` or `3dpdf`.
1782
+ * `obj`, `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` or custom job name.
1787
1783
  *
1788
1784
  * @readonly
1789
1785
  */
@@ -1834,7 +1830,10 @@
1834
1830
  return this;
1835
1831
  }
1836
1832
  /**
1837
- * Update job data on the server. Only admins can update job data.
1833
+ * Update job data on the server.
1834
+ *
1835
+ * Only admins can update job data, if the current logged in user does not have administrator
1836
+ * rights, an exception will be thrown.
1838
1837
  *
1839
1838
  * @async
1840
1839
  * @param data - Raw job data.
@@ -3404,8 +3403,8 @@
3404
3403
  return this.data.canCreateProject;
3405
3404
  }
3406
3405
  /**
3407
- * User account registration time (UTC) in the format specified in <a
3408
- * href="https://www.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a>.
3406
+ * Account registration time (UTC) in the format specified in
3407
+ * {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
3409
3408
  *
3410
3409
  * @readonly
3411
3410
  */
@@ -3497,8 +3496,8 @@
3497
3496
  return this.data.isEmailConfirmed;
3498
3497
  }
3499
3498
  /**
3500
- * User last update time (UTC) in the format specified in <a
3501
- * href="https://www.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a>.
3499
+ * User last update time (UTC) in the format specified in
3500
+ * {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
3502
3501
  */
3503
3502
  get lastModified() {
3504
3503
  return this.data.lastModified;
@@ -3513,8 +3512,8 @@
3513
3512
  this._data.lastName = value;
3514
3513
  }
3515
3514
  /**
3516
- * User last sign in time (UTC) in the format specified in <a
3517
- * href="https://www.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a>.
3515
+ * User last sign in time (UTC) in the format specified in
3516
+ * {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
3518
3517
  */
3519
3518
  get lastSignIn() {
3520
3519
  return this.data.lastSignIn;
@@ -3527,6 +3526,12 @@
3527
3526
  get projectsLimit() {
3528
3527
  return this.data.projectsLimit;
3529
3528
  }
3529
+ /**
3530
+ * The identity provider used to create the account. Can be `ldap`, `oauth`, `saml` or empty.
3531
+ */
3532
+ get providerType() {
3533
+ return this.data.providerType;
3534
+ }
3530
3535
  /**
3531
3536
  * The user's access token (API key). Use {@link Client.signInWithToken()} to log in using token.
3532
3537
  *
@@ -3545,47 +3550,57 @@
3545
3550
  this._data.userName = value;
3546
3551
  }
3547
3552
  /**
3548
- * Refresh user data. Only admins can checkout other users, if the current logged in user
3549
- * does not have administrator rights, hi can only checkout himself, otherwise an exception
3550
- * will be thrown.
3553
+ * Refresh user data.
3554
+ *
3555
+ * Only admins can checkout other users, if the current logged in user does not have
3556
+ * administrator rights, hi can only checkout himself, otherwise an exception will be thrown.
3551
3557
  */
3552
3558
  async checkout() {
3553
- if (this.id === this.httpClient.signInUserId) {
3559
+ if (this.httpClient.signInUserIsAdmin) {
3560
+ const response = await this.httpClient.get(`/users/${this.id}`);
3561
+ const data = await response.json();
3562
+ this.data = { id: data.id, ...data.userBrief };
3563
+ }
3564
+ else if (this.id === this.httpClient.signInUserId) {
3554
3565
  const response = await this.httpClient.get("/user");
3555
3566
  const data = await response.json();
3556
3567
  this.data = { id: this.id, ...data };
3557
3568
  }
3558
3569
  else {
3559
- const response = await this.httpClient.get(`/users/${this.id}`);
3560
- const data = await response.json();
3561
- this.data = { id: data.id, ...data.userBrief };
3570
+ return Promise.reject(new FetchError(403));
3562
3571
  }
3563
3572
  return this;
3564
3573
  }
3565
3574
  /**
3566
- * Update user data on the server. Only admins can update other users, if the current logged
3567
- * in user does not have administrator rights, hi can only update himself, otherwise an
3568
- * exception will be thrown.
3575
+ * Update user data on the server.
3576
+ *
3577
+ * Only admins can update other users, if the current logged in user does not have
3578
+ * administrator rights, hi can only update himself, otherwise an exception will be thrown.
3569
3579
  *
3570
3580
  * @async
3571
3581
  * @param data - Raw user data.
3572
3582
  */
3573
3583
  async update(data) {
3574
- if (this.id === this.httpClient.signInUserId) {
3584
+ if (this.httpClient.signInUserIsAdmin) {
3585
+ const response = await this.httpClient.put(`/users/${this.id}`, { userBrief: data });
3586
+ const newData = await response.json();
3587
+ this.data = { id: newData.id, ...newData.userBrief };
3588
+ }
3589
+ else if (this.id === this.httpClient.signInUserId) {
3575
3590
  const response = await this.httpClient.put("/user", data);
3576
3591
  const newData = await response.json();
3577
3592
  this.data = { id: this.id, ...newData };
3578
3593
  }
3579
3594
  else {
3580
- const response = await this.httpClient.put(`/users/${this.id}`, { userBrief: data });
3581
- const newData = await response.json();
3582
- this.data = { id: newData.id, ...newData.userBrief };
3595
+ return Promise.reject(new FetchError(403));
3583
3596
  }
3584
3597
  return this;
3585
3598
  }
3586
3599
  /**
3587
- * Delete a user from the server. Only admins can delete users, if the current logged in user
3588
- * does not have administrator rights, an exception will be thrown.
3600
+ * Delete a user from the server.
3601
+ *
3602
+ * Only admins can delete users, if the current logged in user does not have administrator
3603
+ * rights, an exception will be thrown.
3589
3604
  *
3590
3605
  * Admins can delete themselves or other admins. An admin can only delete himself if he is
3591
3606
  * not the last administrator.
@@ -3596,16 +3611,22 @@
3596
3611
  * @returns Returns the raw data of a deleted user.
3597
3612
  */
3598
3613
  delete() {
3599
- return this.httpClient
3600
- .delete(`/users/${this.id}`)
3601
- .then((response) => response.json())
3602
- .then((data) => {
3603
- if (this.id === this.httpClient.signInUserId) {
3604
- this.httpClient.headers = {};
3605
- this.httpClient.signInUserId = "";
3606
- }
3607
- return data;
3608
- });
3614
+ if (this.httpClient.signInUserIsAdmin) {
3615
+ return this.httpClient
3616
+ .delete(`/users/${this.id}`)
3617
+ .then((response) => response.json())
3618
+ .then((data) => {
3619
+ if (this.id === this.httpClient.signInUserId) {
3620
+ this.httpClient.headers = {};
3621
+ this.httpClient.signInUserId = "";
3622
+ this.httpClient.signInUserIsAdmin = false;
3623
+ }
3624
+ return data;
3625
+ });
3626
+ }
3627
+ else {
3628
+ return Promise.reject(new FetchError(403));
3629
+ }
3609
3630
  }
3610
3631
  /**
3611
3632
  * Save user data changes to the server. Call this method to update user data on the server
@@ -3617,44 +3638,61 @@
3617
3638
  return this.update(this.data);
3618
3639
  }
3619
3640
  /**
3620
- * Set or remove the user avatar. Only admins can set the avatar of other users, if the
3621
- * current logged in user does not have administrator rights, he can only set his own avatar,
3622
- * otherwise an exception will be thrown.
3641
+ * Set or remove the user avatar.
3642
+ *
3643
+ * Only admins can set the avatar of other users, if the current logged in user does not have
3644
+ * administrator rights, he can only set his own avatar, otherwise an exception will be thrown.
3623
3645
  *
3624
3646
  * @async
3625
- * @param image - Avatar image. Can be a <a
3626
- * href="https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs"
3627
- * target="_blank">Data URL</a> string, <a
3628
- * href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer"
3629
- * target="_blank">ArrayBuffer</a>, <a
3630
- * href="https://developer.mozilla.org/docs/Web/API/Blob/Blob" target="_blank">Blob</a> or
3631
- * Web API <a href="https://developer.mozilla.org/docs/Web/API/File"
3632
- * target="_blank">File</a> object. Setting the `image` to `null` will remove the avatar.
3647
+ * @param image - Avatar image. Can be a
3648
+ * {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL}
3649
+ * string,
3650
+ * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
3651
+ * {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob} or Web API
3652
+ * {@link https://developer.mozilla.org/docs/Web/API/File | File} object. Setting the
3653
+ * `image` to `null` will remove the avatar.
3633
3654
  */
3634
3655
  async setAvatar(image) {
3635
- if (image) {
3636
- if (this.id === this.httpClient.signInUserId) {
3637
- const response = await this.httpClient.post("/user/avatar", image);
3638
- const data = await response.json();
3639
- this.data = { id: this.id, ...data };
3640
- }
3641
- else {
3642
- const response = await this.httpClient.post(`/users/${this.id}/avatar`, image);
3643
- const data = await response.json();
3644
- this.data = { id: data.id, ...data.userBrief };
3645
- }
3656
+ if (!image) {
3657
+ await this.deleteAvatar();
3658
+ }
3659
+ else if (this.httpClient.signInUserIsAdmin) {
3660
+ const response = await this.httpClient.post(`/users/${this.id}/avatar`, image);
3661
+ const data = await response.json();
3662
+ this.data = { id: data.id, ...data.userBrief };
3663
+ }
3664
+ else if (this.id === this.httpClient.signInUserId) {
3665
+ const response = await this.httpClient.post("/user/avatar", image);
3666
+ const data = await response.json();
3667
+ this.data = { id: this.id, ...data };
3646
3668
  }
3647
3669
  else {
3648
- if (this.id === this.httpClient.signInUserId) {
3649
- const response = await this.httpClient.delete("/user/avatar");
3650
- const data = await response.json();
3651
- this.data = { id: this.id, ...data };
3652
- }
3653
- else {
3654
- const response = await this.httpClient.delete(`/users/${this.id}/avatar`);
3655
- const data = await response.json();
3656
- this.data = { id: data.id, ...data.userBrief };
3657
- }
3670
+ return Promise.reject(new FetchError(403));
3671
+ }
3672
+ return this;
3673
+ }
3674
+ /**
3675
+ * Remove the user avatar.
3676
+ *
3677
+ * Only admins can remove the avatar of other users, if the current logged in user does not
3678
+ * have administrator rights, they can only remove their own avatar, otherwise an exception
3679
+ * will be thrown.
3680
+ *
3681
+ * @async
3682
+ */
3683
+ async deleteAvatar() {
3684
+ if (this.httpClient.signInUserIsAdmin) {
3685
+ const response = await this.httpClient.delete(`/users/${this.id}/avatar`);
3686
+ const data = await response.json();
3687
+ this.data = { id: data.id, ...data.userBrief };
3688
+ }
3689
+ else if (this.id === this.httpClient.signInUserId) {
3690
+ const response = await this.httpClient.delete("/user/avatar");
3691
+ const data = await response.json();
3692
+ this.data = { id: this.id, ...data };
3693
+ }
3694
+ else {
3695
+ return Promise.reject(new FetchError(403));
3658
3696
  }
3659
3697
  return this;
3660
3698
  }
@@ -3759,7 +3797,7 @@
3759
3797
  .then((data) => ({
3760
3798
  ...data,
3761
3799
  server: data.version,
3762
- client: "25.4.11",
3800
+ client: "25.6.0",
3763
3801
  }));
3764
3802
  }
3765
3803
  /**
@@ -3831,31 +3869,19 @@
3831
3869
  const data = await response.json();
3832
3870
  return this.setCurrentUser(data);
3833
3871
  }
3834
- /**
3835
- * Get the list of server indentity providers.
3836
- *
3837
- * To sign in with the provider in your web application:
3838
- *
3839
- * - Open the `provider.url` link using `window.open()`.
3840
- * - Add a `/oauth` path (server-defined) handler to the router. In this handler, show an error
3841
- * message if the `error` search parameter is present, or log in with the `token` search parameter.
3842
- *
3843
- * @async
3844
- */
3845
- getIdentityProviders() {
3846
- return this.httpClient.get("/identity").then((response) => response.json());
3847
- }
3848
3872
  // Save the current logged in user information for internal use.
3849
3873
  setCurrentUser(data) {
3850
3874
  this._user = new User(data, this.httpClient);
3851
3875
  this.httpClient.headers = { Authorization: data.tokenInfo.token };
3852
3876
  this.httpClient.signInUserId = this._user.id;
3877
+ this.httpClient.signInUserIsAdmin = this._user.isAdmin;
3853
3878
  return this._user;
3854
3879
  }
3855
3880
  clearCurrentUser() {
3856
3881
  this._user = null;
3857
3882
  this.httpClient.headers = {};
3858
3883
  this.httpClient.signInUserId = "";
3884
+ this.httpClient.signInUserIsAdmin = false;
3859
3885
  }
3860
3886
  /**
3861
3887
  * Returns the current logged in user information. Returns `null` if the user is not logged
@@ -3867,8 +3893,43 @@
3867
3893
  return this._user;
3868
3894
  }
3869
3895
  /**
3870
- * Returns a list of server users. Only admins can get a list of users, if the current logged
3871
- * in user does not have administrator rights, an exception will be thrown.
3896
+ * Get the list of server indentity providers.
3897
+ *
3898
+ * To sign in with the provider in your web application:
3899
+ *
3900
+ * - Open the `provider.url` link using `window.open()`.
3901
+ * - Add a `/oauth` path (server-defined) handler to the router. In this handler, show an error
3902
+ * message if the `error` search parameter is present, or log in with the `token` search parameter.
3903
+ *
3904
+ * @async
3905
+ */
3906
+ getIdentityProviders() {
3907
+ return this.httpClient.get("/identity").then((response) => response.json());
3908
+ }
3909
+ /**
3910
+ * Returns the current server settings.
3911
+ *
3912
+ * @async
3913
+ */
3914
+ getServerSettings() {
3915
+ return this.httpClient.get("/settings").then((response) => response.json());
3916
+ }
3917
+ /**
3918
+ * Change server settings.
3919
+ *
3920
+ * Only admins can change server settings, if the current logged in user does not have
3921
+ * administrator rights, an exception will be thrown.
3922
+ *
3923
+ * @async
3924
+ */
3925
+ updateServerSettings(settings) {
3926
+ return this.httpClient.put("/settings", settings).then((response) => response.json());
3927
+ }
3928
+ /**
3929
+ * Returns a list of server users.
3930
+ *
3931
+ * Only admins can get a list of users, if the current logged in user does not have
3932
+ * administrator rights, an exception will be thrown.
3872
3933
  *
3873
3934
  * @async
3874
3935
  */
@@ -3880,32 +3941,38 @@
3880
3941
  .then((array) => array.map((data) => new User(data, this.httpClient)));
3881
3942
  }
3882
3943
  /**
3883
- * Returns the user information. Only admins can get other users, if the current logged in
3884
- * user does not have administrator rights, hi can only get himself, otherwise an exception
3885
- * will be thrown.
3944
+ * Returns the user information.
3945
+ *
3946
+ * Only admins can get other users, if the current logged in user does not have administrator
3947
+ * rights, hi can only get himself, otherwise an exception will be thrown.
3886
3948
  *
3887
3949
  * @async
3888
3950
  * @param userId - User ID.
3889
3951
  */
3890
3952
  getUser(userId) {
3891
- if (userId === this.httpClient.signInUserId) {
3953
+ if (this.httpClient.signInUserIsAdmin) {
3892
3954
  return this.httpClient
3893
- .get("/user")
3955
+ .get(`/users/${userId}`)
3894
3956
  .then((response) => response.json())
3895
- .then((data) => ({ id: userId, ...data }))
3957
+ .then((data) => ({ id: data.id, ...data.userBrief }))
3896
3958
  .then((data) => new User(data, this.httpClient));
3897
3959
  }
3898
- else {
3960
+ else if (userId === this.httpClient.signInUserId) {
3899
3961
  return this.httpClient
3900
- .get(`/users/${userId}`)
3962
+ .get("/user")
3901
3963
  .then((response) => response.json())
3902
- .then((data) => ({ id: data.id, ...data.userBrief }))
3964
+ .then((data) => ({ id: userId, ...data }))
3903
3965
  .then((data) => new User(data, this.httpClient));
3904
3966
  }
3967
+ else {
3968
+ return Promise.reject(new FetchError(403));
3969
+ }
3905
3970
  }
3906
3971
  /**
3907
- * Create a new user. Only admins can create users, if the current logged in user does not
3908
- * have administrator rights, an exception will be thrown.
3972
+ * Create a new user.
3973
+ *
3974
+ * Only admins can create users, if the current logged in user does not have administrator
3975
+ * rights, an exception will be thrown.
3909
3976
  *
3910
3977
  * @async
3911
3978
  * @param email - User email. Cannot be empty.
@@ -3919,7 +3986,7 @@
3919
3986
  * @param params.lastName - Last name.
3920
3987
  * @param params.canCreateProject - `true` if user is allowed to create a project.
3921
3988
  * @param params.projectsLimit - The maximum number of projects that the user can create.
3922
- * @param params.storageLimit - The size of the file storage available to the user.
3989
+ * @param params.storageLimit - The size of the file storage available to the user in bytes.
3923
3990
  */
3924
3991
  createUser(email, password, params = {}) {
3925
3992
  const { isAdmin, userName, ...rest } = params;
@@ -3938,8 +4005,10 @@
3938
4005
  .then((data) => new User(data, this.httpClient));
3939
4006
  }
3940
4007
  /**
3941
- * Delete a user from the server. Only admins can delete users, if the current logged in user
3942
- * does not have administrator rights, an exception will be thrown.
4008
+ * Delete a user from the server.
4009
+ *
4010
+ * Only admins can delete users, if the current logged in user does not have administrator
4011
+ * rights, an exception will be thrown.
3943
4012
  *
3944
4013
  * Admins can delete themselves or other admins. An admin can only delete himself if he is
3945
4014
  * not the last administrator.
@@ -3951,15 +4020,20 @@
3951
4020
  * @returns Returns the raw data of a deleted user.
3952
4021
  */
3953
4022
  deleteUser(userId) {
3954
- return this.httpClient
3955
- .delete(`/users/${userId}`)
3956
- .then((response) => response.json())
3957
- .then((data) => {
3958
- if (userId === this.httpClient.signInUserId) {
3959
- this.clearCurrentUser();
3960
- }
3961
- return data;
3962
- });
4023
+ if (this.httpClient.signInUserIsAdmin) {
4024
+ return this.httpClient
4025
+ .delete(`/users/${userId}`)
4026
+ .then((response) => response.json())
4027
+ .then((data) => {
4028
+ if (userId === this.httpClient.signInUserId) {
4029
+ this.clearCurrentUser();
4030
+ }
4031
+ return data;
4032
+ });
4033
+ }
4034
+ else {
4035
+ return Promise.reject(new FetchError(403));
4036
+ }
3963
4037
  }
3964
4038
  /**
3965
4039
  * Result for file list.
@@ -4412,9 +4486,8 @@
4412
4486
  * @param description - Project description.
4413
4487
  * @param startDate - Project start date.
4414
4488
  * @param endDate - Project end date.
4415
- * @param avatarUrl - Project preview image URL. Can be <a
4416
- * href="https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs"
4417
- * target="_blank">Data URL</a>.
4489
+ * @param avatarUrl - Project preview image URL. Can be
4490
+ * {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL}.
4418
4491
  */
4419
4492
  createProject(name, description, startDate, endDate, avatarUrl) {
4420
4493
  return this.httpClient
@@ -4452,7 +4525,7 @@
4452
4525
  }
4453
4526
 
4454
4527
  ///////////////////////////////////////////////////////////////////////////////
4455
- const version = "25.4.11";
4528
+ const version = "25.6.0";
4456
4529
 
4457
4530
  exports.Assembly = Assembly;
4458
4531
  exports.ClashTest = ClashTest;