@inweb/client 25.10.0 → 25.11.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 +278 -10
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +1 -1
- package/dist/client.module.js +108 -3
- package/dist/client.module.js.map +1 -1
- package/lib/Api/Client.d.ts +74 -16
- package/lib/Api/OAuthClient.d.ts +108 -0
- package/lib/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/Api/Client.ts +135 -12
- package/src/Api/OAuthClient.ts +210 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
import { IHttpClient } from "./IHttpClient";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Provides properties and methods for obtaining information about a OAuth 2.0 client that have
|
|
28
|
+
* access the Open Cloud Server API.
|
|
29
|
+
*/
|
|
30
|
+
export class OAuthClient {
|
|
31
|
+
private _data: any;
|
|
32
|
+
public httpClient: IHttpClient;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param data - Raw client data received from the server. For more information, see
|
|
36
|
+
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#OAuthClient | Open Cloud OAuth Clients API}.
|
|
37
|
+
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
38
|
+
*/
|
|
39
|
+
constructor(data: any, httpClient: IHttpClient) {
|
|
40
|
+
this.httpClient = httpClient;
|
|
41
|
+
this.data = data;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private internalGet(): Promise<Response> {
|
|
45
|
+
return this.httpClient.get(`/oauth/clients/${this.clientId}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
protected internalPost(relativePath: string, body?: BodyInit | object): Promise<Response> {
|
|
49
|
+
return this.httpClient.post(`/oauth/clients/${this.clientId}${relativePath}`, body);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private internalPut(body?: BodyInit | object): Promise<Response> {
|
|
53
|
+
return this.httpClient.put(`/oauth/clients/${this.clientId}`, body);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private internalDelete(): Promise<Response> {
|
|
57
|
+
return this.httpClient.delete(`/oauth/clients/${this.clientId}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* OAuth 2.0 server authorization endpoint.
|
|
62
|
+
*/
|
|
63
|
+
get authUrl(): string {
|
|
64
|
+
return this.data.authUrl;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* OAuth 2.0 server token endpoint.
|
|
69
|
+
*/
|
|
70
|
+
get accessTokenUrl(): string {
|
|
71
|
+
return this.data.accessTokenUrl;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Unique client ID.
|
|
76
|
+
*
|
|
77
|
+
* @readonly
|
|
78
|
+
*/
|
|
79
|
+
get clientId(): string {
|
|
80
|
+
return this.data.clientId;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Client creation time (UTC) in the format specified in
|
|
85
|
+
* {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
|
|
86
|
+
*/
|
|
87
|
+
get createdAt(): string {
|
|
88
|
+
return this.data.createdAt;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Client application description.
|
|
93
|
+
*/
|
|
94
|
+
get description(): string {
|
|
95
|
+
return this.data.description;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
set description(value: string) {
|
|
99
|
+
this._data.description = value;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Client data received from the server. For more information, see
|
|
104
|
+
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#OAuthClient | Open Cloud OAuth Clients API}.
|
|
105
|
+
*
|
|
106
|
+
* @readonly
|
|
107
|
+
*/
|
|
108
|
+
get data(): any {
|
|
109
|
+
return this._data;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
set data(value: any) {
|
|
113
|
+
this._data = value;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Client application name.
|
|
118
|
+
*/
|
|
119
|
+
get name(): string {
|
|
120
|
+
return this.data.name;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
set name(value: string) {
|
|
124
|
+
this._data.name = value;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The endpoint to which the OAuth 2.0 server sends the response.
|
|
129
|
+
*/
|
|
130
|
+
get redirectUrl(): string {
|
|
131
|
+
return this.data.redirectUrl;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
set redirectUrl(value: string) {
|
|
135
|
+
this.data.redirectUrl = value;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Client secret.
|
|
140
|
+
*
|
|
141
|
+
* @readonly
|
|
142
|
+
*/
|
|
143
|
+
get secret(): string {
|
|
144
|
+
return this.data.secret;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Client last update time (UTC) in the format specified in
|
|
149
|
+
* {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
|
|
150
|
+
*/
|
|
151
|
+
get updatedAt(): string {
|
|
152
|
+
return this.data.updatedAt;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Reloads clien data from the server.
|
|
157
|
+
*/
|
|
158
|
+
async checkout(): Promise<this> {
|
|
159
|
+
const response = await this.internalGet();
|
|
160
|
+
this.data = await response.json();
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Updates client data on the server.
|
|
166
|
+
*
|
|
167
|
+
* Only administrators can update OAuth clients. If the current logged in user is not an
|
|
168
|
+
* administrator, an exception will be thrown.
|
|
169
|
+
*
|
|
170
|
+
* @param data - Raw client data. For more information, see
|
|
171
|
+
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#OAuthClient | Open Cloud OAuth Clients API}.
|
|
172
|
+
*/
|
|
173
|
+
async update(data: any): Promise<this> {
|
|
174
|
+
const response = await this.internalPut(data);
|
|
175
|
+
this.data = await response.json();
|
|
176
|
+
return this;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Deletes a client from the server.
|
|
181
|
+
*
|
|
182
|
+
* Only administrators can delete OAuth clients. If the current logged in user is not an
|
|
183
|
+
* administrator, an exception will be thrown.
|
|
184
|
+
*
|
|
185
|
+
* @returns Returns the raw data of a deleted client. For more information, see
|
|
186
|
+
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#OAuthClient | Open Cloud OAuth Clients API}.
|
|
187
|
+
*/
|
|
188
|
+
delete(): Promise<any> {
|
|
189
|
+
return this.internalDelete().then((response) => response.json());
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Saves client properties changes to the server. Call this method to update client data on
|
|
194
|
+
* the server after any property changes.
|
|
195
|
+
*
|
|
196
|
+
* Only administrators can update OAuth clients. If the current logged in user is not an
|
|
197
|
+
* administrator, an exception will be thrown.
|
|
198
|
+
*/
|
|
199
|
+
save(): Promise<this> {
|
|
200
|
+
return this.update(this.data);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Revokes the access tokens for all users of the client application.
|
|
205
|
+
*/
|
|
206
|
+
async revoke(): Promise<this> {
|
|
207
|
+
await this.internalPost("/revoke");
|
|
208
|
+
return this;
|
|
209
|
+
}
|
|
210
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -43,6 +43,7 @@ export { IRoleActions } from "./Api/IRole";
|
|
|
43
43
|
export { IShortUserDesc } from "./Api/IUser";
|
|
44
44
|
export { Member } from "./Api/Member";
|
|
45
45
|
export { Model } from "./Api/Model";
|
|
46
|
+
export { OAuthClient } from "./Api/OAuthClient";
|
|
46
47
|
export { Permission } from "./Api/Permission";
|
|
47
48
|
export { Project } from "./Api/Project";
|
|
48
49
|
export { Role } from "./Api/Role";
|