@magda/auth-api-client 2.0.0-alpha.1 → 2.0.0-alpha.4
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/index.d.ts +68 -30
- package/dist/index.js +182 -65
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -14,15 +14,6 @@ declare class ApiClient {
|
|
|
14
14
|
* @memberof ApiClient
|
|
15
15
|
*/
|
|
16
16
|
getUser(userId: string): Promise<Maybe<RequiredKeys<User, "id">>>;
|
|
17
|
-
/**
|
|
18
|
-
* Get the data of a user.
|
|
19
|
-
* (Deprecated) This is the public facing API and will return less fields.
|
|
20
|
-
*
|
|
21
|
-
* @param {string} userId
|
|
22
|
-
* @returns {Promise<Maybe<User>>}
|
|
23
|
-
* @memberof ApiClient
|
|
24
|
-
*/
|
|
25
|
-
getUserPublic(userId: string): Promise<Maybe<RequiredKeys<User, "id">>>;
|
|
26
17
|
/**
|
|
27
18
|
* Lookup user by source (identity provider) & sourceId (identity ID)
|
|
28
19
|
*
|
|
@@ -35,11 +26,11 @@ declare class ApiClient {
|
|
|
35
26
|
/**
|
|
36
27
|
* create a user
|
|
37
28
|
*
|
|
38
|
-
* @param {
|
|
39
|
-
* @returns {Promise<
|
|
29
|
+
* @param {CreateUserData} user
|
|
30
|
+
* @returns {Promise<UserRecord>}
|
|
40
31
|
* @memberof ApiClient
|
|
41
32
|
*/
|
|
42
|
-
createUser(user:
|
|
33
|
+
createUser(user: CreateUserData): Promise<UserRecord>;
|
|
43
34
|
/**
|
|
44
35
|
* Add Roles to a user.
|
|
45
36
|
* Returns a list of current role ids of the user.
|
|
@@ -135,10 +126,22 @@ declare class ApiClient {
|
|
|
135
126
|
* @memberof ApiClient
|
|
136
127
|
*/
|
|
137
128
|
getAllOrgUnitChildren(nodeId: string): Promise<OrgUnit[]>;
|
|
129
|
+
createOrgNode(parentNodeId: string, node: Partial<Omit<OrgUnitRecord, "id" | "createBy" | "createTime" | "editBy" | "editTime" | "left" | "right">>): Promise<OrgUnit>;
|
|
130
|
+
createRole(name: string, desc?: string): Promise<Role>;
|
|
131
|
+
createRolePermission(roleId: string, permissionData: CreateRolePermissionInputData): Promise<PermissionRecord>;
|
|
132
|
+
createPermission(permissionData: CreateRolePermissionInputData): Promise<PermissionRecord>;
|
|
133
|
+
getOperationByUri(opUri: string): Promise<OperationRecord>;
|
|
134
|
+
getResourceByUri(resUri: string): Promise<ResourceRecord>;
|
|
138
135
|
private handleGetResult;
|
|
139
136
|
}
|
|
140
137
|
export default ApiClient;
|
|
141
138
|
|
|
139
|
+
declare interface CreateRolePermissionInputData extends Omit<PermissionRecord, "id" | "owner_id" | "create_by" | "create_time" | "edit_by" | "edit_time"> {
|
|
140
|
+
operationIds: string[];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
declare type CreateUserData = Partial<Omit<UserRecord, "email" | "displayName" | "id">> & Pick<UserRecord, "displayName" | "email">;
|
|
144
|
+
|
|
142
145
|
declare interface Eq<T> {
|
|
143
146
|
equals(t: T): boolean;
|
|
144
147
|
}
|
|
@@ -206,22 +209,33 @@ export declare interface Operation {
|
|
|
206
209
|
description?: string;
|
|
207
210
|
}
|
|
208
211
|
|
|
212
|
+
declare type OperationRecord = {
|
|
213
|
+
id: string;
|
|
214
|
+
uri: string;
|
|
215
|
+
name: string;
|
|
216
|
+
description: string;
|
|
217
|
+
resource_id: string;
|
|
218
|
+
};
|
|
219
|
+
|
|
209
220
|
declare interface OptionalMaybePatterns<T, U> {
|
|
210
221
|
just?: (t: T) => U;
|
|
211
222
|
nothing?: () => U;
|
|
212
223
|
}
|
|
213
224
|
|
|
214
|
-
export declare
|
|
215
|
-
id?: string;
|
|
216
|
-
name?: string;
|
|
217
|
-
description?: string;
|
|
225
|
+
export declare type OrgUnit = Partial<OrgUnitRecord> & {
|
|
218
226
|
relationship?: OrgUnitRelationshipType;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
declare interface OrgUnitRecord {
|
|
230
|
+
id: string;
|
|
231
|
+
name: string;
|
|
232
|
+
description: string;
|
|
233
|
+
left: number;
|
|
234
|
+
right: number;
|
|
235
|
+
createBy: string;
|
|
236
|
+
createTime: Date;
|
|
237
|
+
editBy: string;
|
|
238
|
+
editTime: Date;
|
|
225
239
|
}
|
|
226
240
|
|
|
227
241
|
export declare type OrgUnitRelationshipType = "ancestor" | "descendant" | "equal" | "unrelated";
|
|
@@ -242,20 +256,37 @@ export declare interface Permission {
|
|
|
242
256
|
editTime?: Date;
|
|
243
257
|
}
|
|
244
258
|
|
|
245
|
-
|
|
246
|
-
id
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
259
|
+
declare interface PermissionRecord {
|
|
260
|
+
id: string;
|
|
261
|
+
name: string;
|
|
262
|
+
description: string;
|
|
263
|
+
resource_id: string;
|
|
264
|
+
user_ownership_constraint: boolean;
|
|
265
|
+
org_unit_ownership_constraint: boolean;
|
|
266
|
+
pre_authorised_constraint: boolean;
|
|
267
|
+
owner_id: string;
|
|
268
|
+
create_time: string;
|
|
269
|
+
create_by: string;
|
|
270
|
+
edit_time: string;
|
|
271
|
+
edit_by: string;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export declare type PublicUser = Partial<Pick<UserRecord, "id" | "photoURL" | "orgUnitId">> & Omit<UserRecord, "id" | "photoURL" | "orgUnitId" | "email" | "source" | "sourceId"> & {
|
|
250
275
|
roles?: Role[];
|
|
251
276
|
permissions?: Permission[];
|
|
252
277
|
managingOrgUnitIds?: string[];
|
|
253
|
-
orgUnitId?: string;
|
|
254
278
|
orgUnit?: OrgUnit;
|
|
255
|
-
}
|
|
279
|
+
};
|
|
256
280
|
|
|
257
281
|
declare type RequiredKeys<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
258
282
|
|
|
283
|
+
declare type ResourceRecord = {
|
|
284
|
+
id: string;
|
|
285
|
+
uri: string;
|
|
286
|
+
name: string;
|
|
287
|
+
description: string;
|
|
288
|
+
};
|
|
289
|
+
|
|
259
290
|
export declare interface Role {
|
|
260
291
|
id: string;
|
|
261
292
|
name: string;
|
|
@@ -267,7 +298,14 @@ export declare interface Role {
|
|
|
267
298
|
editTime?: Date;
|
|
268
299
|
}
|
|
269
300
|
|
|
270
|
-
export declare
|
|
301
|
+
export declare type User = PublicUser & Pick<UserRecord, "email" | "source" | "sourceId">;
|
|
302
|
+
|
|
303
|
+
declare interface UserRecord {
|
|
304
|
+
id: string;
|
|
305
|
+
displayName: string;
|
|
306
|
+
photoURL: string;
|
|
307
|
+
isAdmin: boolean;
|
|
308
|
+
orgUnitId: string;
|
|
271
309
|
email: string;
|
|
272
310
|
source: string;
|
|
273
311
|
sourceId: string;
|
package/dist/index.js
CHANGED
|
@@ -1806,7 +1806,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
|
|
1806
1806
|
* URI.js - Mutating URLs
|
|
1807
1807
|
* IPv6 Support
|
|
1808
1808
|
*
|
|
1809
|
-
* Version: 1.19.
|
|
1809
|
+
* Version: 1.19.11
|
|
1810
1810
|
*
|
|
1811
1811
|
* Author: Rodney Rehm
|
|
1812
1812
|
* Web: http://medialize.github.io/URI.js/
|
|
@@ -1998,7 +1998,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
|
|
1998
1998
|
* URI.js - Mutating URLs
|
|
1999
1999
|
* Second Level Domain (SLD) Support
|
|
2000
2000
|
*
|
|
2001
|
-
* Version: 1.19.
|
|
2001
|
+
* Version: 1.19.11
|
|
2002
2002
|
*
|
|
2003
2003
|
* Author: Rodney Rehm
|
|
2004
2004
|
* Web: http://medialize.github.io/URI.js/
|
|
@@ -2281,9 +2281,10 @@ const isomorphic_fetch_1 = __importDefault(__webpack_require__(30));
|
|
|
2281
2281
|
const tsmonad_1 = __webpack_require__(15);
|
|
2282
2282
|
const lodash_1 = __importDefault(__webpack_require__(59));
|
|
2283
2283
|
const buildJwt_1 = __importDefault(__webpack_require__(60));
|
|
2284
|
-
const
|
|
2285
|
-
const
|
|
2286
|
-
const
|
|
2284
|
+
const addTrailingSlash_1 = __importDefault(__webpack_require__(79));
|
|
2285
|
+
const urijs_1 = __importDefault(__webpack_require__(80));
|
|
2286
|
+
const ServerError_1 = __importDefault(__webpack_require__(81));
|
|
2287
|
+
const isUuid_1 = __importDefault(__webpack_require__(82));
|
|
2287
2288
|
class ApiClient {
|
|
2288
2289
|
constructor(
|
|
2289
2290
|
// e.g. http://authorization-api/v0
|
|
@@ -2295,14 +2296,29 @@ class ApiClient {
|
|
|
2295
2296
|
if (jwtSecret && userId) {
|
|
2296
2297
|
this.jwt = buildJwt_1.default(jwtSecret, userId);
|
|
2297
2298
|
}
|
|
2298
|
-
this.
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2299
|
+
if (this.jwt) {
|
|
2300
|
+
this.requestInitOption = {
|
|
2301
|
+
headers: {
|
|
2302
|
+
"X-Magda-Session": this.jwt
|
|
2303
|
+
}
|
|
2304
|
+
};
|
|
2305
|
+
}
|
|
2303
2306
|
}
|
|
2304
2307
|
getMergeRequestInitOption(extraOptions = null) {
|
|
2305
|
-
|
|
2308
|
+
let defaultContentTypeCfg = {};
|
|
2309
|
+
if ((extraOptions === null || extraOptions === void 0 ? void 0 : extraOptions.body) &&
|
|
2310
|
+
(!(extraOptions === null || extraOptions === void 0 ? void 0 : extraOptions.headers) ||
|
|
2311
|
+
(typeof extraOptions.headers === "object" &&
|
|
2312
|
+
Object.keys(extraOptions.headers)
|
|
2313
|
+
.map((key) => key.toLowerCase())
|
|
2314
|
+
.indexOf("content-type") == -1))) {
|
|
2315
|
+
defaultContentTypeCfg = {
|
|
2316
|
+
headers: {
|
|
2317
|
+
"Content-Type": "application/json"
|
|
2318
|
+
}
|
|
2319
|
+
};
|
|
2320
|
+
}
|
|
2321
|
+
return lodash_1.default.merge({}, this.requestInitOption, extraOptions, defaultContentTypeCfg);
|
|
2306
2322
|
}
|
|
2307
2323
|
processJsonResponse(res) {
|
|
2308
2324
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -2310,8 +2326,8 @@ class ApiClient {
|
|
|
2310
2326
|
return (yield res.json());
|
|
2311
2327
|
}
|
|
2312
2328
|
else {
|
|
2313
|
-
const responseText =
|
|
2314
|
-
throw new
|
|
2329
|
+
const responseText = yield res.text();
|
|
2330
|
+
throw new ServerError_1.default(`Error: ${res.statusText}. ${responseText.replace(/<(.|\n)*?>/g, "")}`, res.status);
|
|
2315
2331
|
}
|
|
2316
2332
|
});
|
|
2317
2333
|
}
|
|
@@ -2323,19 +2339,6 @@ class ApiClient {
|
|
|
2323
2339
|
* @memberof ApiClient
|
|
2324
2340
|
*/
|
|
2325
2341
|
getUser(userId) {
|
|
2326
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2327
|
-
return yield this.handleGetResult(isomorphic_fetch_1.default(`${this.baseUrl}private/users/${userId}`, this.getMergeRequestInitOption()));
|
|
2328
|
-
});
|
|
2329
|
-
}
|
|
2330
|
-
/**
|
|
2331
|
-
* Get the data of a user.
|
|
2332
|
-
* (Deprecated) This is the public facing API and will return less fields.
|
|
2333
|
-
*
|
|
2334
|
-
* @param {string} userId
|
|
2335
|
-
* @returns {Promise<Maybe<User>>}
|
|
2336
|
-
* @memberof ApiClient
|
|
2337
|
-
*/
|
|
2338
|
-
getUserPublic(userId) {
|
|
2339
2342
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2340
2343
|
return yield this.handleGetResult(isomorphic_fetch_1.default(`${this.baseUrl}public/users/${userId}`, this.getMergeRequestInitOption()));
|
|
2341
2344
|
});
|
|
@@ -2350,20 +2353,39 @@ class ApiClient {
|
|
|
2350
2353
|
*/
|
|
2351
2354
|
lookupUser(source, sourceId) {
|
|
2352
2355
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2353
|
-
|
|
2356
|
+
if (!source) {
|
|
2357
|
+
throw new ServerError_1.default("source cannot be empty!", 400);
|
|
2358
|
+
}
|
|
2359
|
+
if (!sourceId) {
|
|
2360
|
+
throw new ServerError_1.default("sourceId cannot be empty!", 400);
|
|
2361
|
+
}
|
|
2362
|
+
const uri = urijs_1.default(`${this.baseUrl}public/users`).search({
|
|
2363
|
+
source,
|
|
2364
|
+
sourceId,
|
|
2365
|
+
limit: 1
|
|
2366
|
+
});
|
|
2367
|
+
const res = yield isomorphic_fetch_1.default(uri.toString(), this.getMergeRequestInitOption());
|
|
2368
|
+
if (!res.ok) {
|
|
2369
|
+
throw new ServerError_1.default(yield res.text(), res.status);
|
|
2370
|
+
}
|
|
2371
|
+
const data = yield res.json();
|
|
2372
|
+
if (!(data === null || data === void 0 ? void 0 : data.length)) {
|
|
2373
|
+
return tsmonad_1.Maybe.nothing();
|
|
2374
|
+
}
|
|
2375
|
+
return tsmonad_1.Maybe.just(data[0]);
|
|
2354
2376
|
});
|
|
2355
2377
|
}
|
|
2356
2378
|
/**
|
|
2357
2379
|
* create a user
|
|
2358
2380
|
*
|
|
2359
|
-
* @param {
|
|
2360
|
-
* @returns {Promise<
|
|
2381
|
+
* @param {CreateUserData} user
|
|
2382
|
+
* @returns {Promise<UserRecord>}
|
|
2361
2383
|
* @memberof ApiClient
|
|
2362
2384
|
*/
|
|
2363
2385
|
createUser(user) {
|
|
2364
2386
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2365
2387
|
try {
|
|
2366
|
-
const res = yield isomorphic_fetch_1.default(`${this.baseUrl}
|
|
2388
|
+
const res = yield isomorphic_fetch_1.default(`${this.baseUrl}public/users`, this.getMergeRequestInitOption({
|
|
2367
2389
|
method: "POST",
|
|
2368
2390
|
headers: {
|
|
2369
2391
|
"Content-Type": "application/json"
|
|
@@ -2371,10 +2393,10 @@ class ApiClient {
|
|
|
2371
2393
|
body: JSON.stringify(user)
|
|
2372
2394
|
}));
|
|
2373
2395
|
if (res.status >= 400) {
|
|
2374
|
-
throw new Error(`Encountered error ${res.status} when
|
|
2396
|
+
throw new Error(`Encountered error ${res.status}: ${yield res.text()} when creating new user to ${this.baseUrl}public/users`);
|
|
2375
2397
|
}
|
|
2376
2398
|
const resData = yield res.json();
|
|
2377
|
-
return
|
|
2399
|
+
return resData;
|
|
2378
2400
|
}
|
|
2379
2401
|
catch (e) {
|
|
2380
2402
|
console.error(e);
|
|
@@ -2393,7 +2415,7 @@ class ApiClient {
|
|
|
2393
2415
|
*/
|
|
2394
2416
|
addUserRoles(userId, roleIds) {
|
|
2395
2417
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2396
|
-
const res = yield isomorphic_fetch_1.default(`${this.baseUrl}public/
|
|
2418
|
+
const res = yield isomorphic_fetch_1.default(`${this.baseUrl}public/users/${userId}/roles`, this.getMergeRequestInitOption({
|
|
2397
2419
|
method: "POST",
|
|
2398
2420
|
headers: {
|
|
2399
2421
|
"Content-Type": "application/json"
|
|
@@ -2432,7 +2454,7 @@ class ApiClient {
|
|
|
2432
2454
|
*/
|
|
2433
2455
|
getUserRoles(userId) {
|
|
2434
2456
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2435
|
-
const res = yield isomorphic_fetch_1.default(`${this.baseUrl}public/
|
|
2457
|
+
const res = yield isomorphic_fetch_1.default(`${this.baseUrl}public/users/${userId}/roles`, this.getMergeRequestInitOption());
|
|
2436
2458
|
return yield this.processJsonResponse(res);
|
|
2437
2459
|
});
|
|
2438
2460
|
}
|
|
@@ -2445,7 +2467,7 @@ class ApiClient {
|
|
|
2445
2467
|
*/
|
|
2446
2468
|
getUserPermissions(userId) {
|
|
2447
2469
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2448
|
-
const res = yield isomorphic_fetch_1.default(`${this.baseUrl}public/
|
|
2470
|
+
const res = yield isomorphic_fetch_1.default(`${this.baseUrl}public/users/${userId}/permissions`, this.getMergeRequestInitOption());
|
|
2449
2471
|
return yield this.processJsonResponse(res);
|
|
2450
2472
|
});
|
|
2451
2473
|
}
|
|
@@ -2458,7 +2480,7 @@ class ApiClient {
|
|
|
2458
2480
|
*/
|
|
2459
2481
|
getRolePermissions(roleId) {
|
|
2460
2482
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2461
|
-
const res = yield isomorphic_fetch_1.default(`${this.baseUrl}public/
|
|
2483
|
+
const res = yield isomorphic_fetch_1.default(`${this.baseUrl}public/roles/${roleId}/permissions`, this.getMergeRequestInitOption());
|
|
2462
2484
|
return yield this.processJsonResponse(res);
|
|
2463
2485
|
});
|
|
2464
2486
|
}
|
|
@@ -2568,6 +2590,70 @@ class ApiClient {
|
|
|
2568
2590
|
return yield this.processJsonResponse(res);
|
|
2569
2591
|
});
|
|
2570
2592
|
}
|
|
2593
|
+
createOrgNode(parentNodeId, node) {
|
|
2594
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2595
|
+
const uri = urijs_1.default(`${this.baseUrl}public/orgunits`)
|
|
2596
|
+
.segmentCoded(parentNodeId)
|
|
2597
|
+
.segmentCoded("insert");
|
|
2598
|
+
const res = yield isomorphic_fetch_1.default(uri.toString(), this.getMergeRequestInitOption({
|
|
2599
|
+
method: "post",
|
|
2600
|
+
body: JSON.stringify(node)
|
|
2601
|
+
}));
|
|
2602
|
+
return yield this.processJsonResponse(res);
|
|
2603
|
+
});
|
|
2604
|
+
}
|
|
2605
|
+
createRole(name, desc) {
|
|
2606
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2607
|
+
const uri = urijs_1.default(`${this.baseUrl}public/roles`);
|
|
2608
|
+
const res = yield isomorphic_fetch_1.default(uri.toString(), this.getMergeRequestInitOption({
|
|
2609
|
+
method: "post",
|
|
2610
|
+
body: JSON.stringify({
|
|
2611
|
+
name,
|
|
2612
|
+
description: desc ? desc : ""
|
|
2613
|
+
})
|
|
2614
|
+
}));
|
|
2615
|
+
return yield this.processJsonResponse(res);
|
|
2616
|
+
});
|
|
2617
|
+
}
|
|
2618
|
+
createRolePermission(roleId, permissionData) {
|
|
2619
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2620
|
+
if (!isUuid_1.default(roleId)) {
|
|
2621
|
+
throw new ServerError_1.default(`roleId: ${roleId} is not a valid UUID.`);
|
|
2622
|
+
}
|
|
2623
|
+
const uri = urijs_1.default(`${this.baseUrl}public/roles`)
|
|
2624
|
+
.segmentCoded(roleId)
|
|
2625
|
+
.segmentCoded("permissions");
|
|
2626
|
+
const res = yield isomorphic_fetch_1.default(uri.toString(), this.getMergeRequestInitOption({
|
|
2627
|
+
method: "post",
|
|
2628
|
+
body: JSON.stringify(permissionData)
|
|
2629
|
+
}));
|
|
2630
|
+
return yield this.processJsonResponse(res);
|
|
2631
|
+
});
|
|
2632
|
+
}
|
|
2633
|
+
createPermission(permissionData) {
|
|
2634
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2635
|
+
const uri = urijs_1.default(`${this.baseUrl}public/permissions`);
|
|
2636
|
+
const res = yield isomorphic_fetch_1.default(uri.toString(), this.getMergeRequestInitOption({
|
|
2637
|
+
method: "post",
|
|
2638
|
+
body: JSON.stringify(permissionData)
|
|
2639
|
+
}));
|
|
2640
|
+
return yield this.processJsonResponse(res);
|
|
2641
|
+
});
|
|
2642
|
+
}
|
|
2643
|
+
getOperationByUri(opUri) {
|
|
2644
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2645
|
+
const uri = urijs_1.default(`${this.baseUrl}public/operations/byUri/${opUri}`);
|
|
2646
|
+
const res = yield isomorphic_fetch_1.default(uri.toString(), this.getMergeRequestInitOption());
|
|
2647
|
+
return yield this.processJsonResponse(res);
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2650
|
+
getResourceByUri(resUri) {
|
|
2651
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2652
|
+
const uri = urijs_1.default(`${this.baseUrl}public/resources/byUri/${resUri}`);
|
|
2653
|
+
const res = yield isomorphic_fetch_1.default(uri.toString(), this.getMergeRequestInitOption());
|
|
2654
|
+
return yield this.processJsonResponse(res);
|
|
2655
|
+
});
|
|
2656
|
+
}
|
|
2571
2657
|
handleGetResult(promise) {
|
|
2572
2658
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2573
2659
|
return promise
|
|
@@ -27562,29 +27648,6 @@ module.exports = once;
|
|
|
27562
27648
|
|
|
27563
27649
|
"use strict";
|
|
27564
27650
|
|
|
27565
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27566
|
-
class GenericError extends Error {
|
|
27567
|
-
constructor(message = "Unknown Error", statusCode = 500) {
|
|
27568
|
-
super(message);
|
|
27569
|
-
this.statusCode = statusCode;
|
|
27570
|
-
}
|
|
27571
|
-
toData() {
|
|
27572
|
-
return {
|
|
27573
|
-
isError: true,
|
|
27574
|
-
errorCode: this.statusCode,
|
|
27575
|
-
errorMessage: this.message
|
|
27576
|
-
};
|
|
27577
|
-
}
|
|
27578
|
-
}
|
|
27579
|
-
exports.default = GenericError;
|
|
27580
|
-
//# sourceMappingURL=GenericError.js.map
|
|
27581
|
-
|
|
27582
|
-
/***/ }),
|
|
27583
|
-
/* 80 */
|
|
27584
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
27585
|
-
|
|
27586
|
-
"use strict";
|
|
27587
|
-
|
|
27588
27651
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27589
27652
|
function addTrailingSlash(url) {
|
|
27590
27653
|
if (!url) {
|
|
@@ -27601,13 +27664,13 @@ exports.default = addTrailingSlash;
|
|
|
27601
27664
|
//# sourceMappingURL=addTrailingSlash.js.map
|
|
27602
27665
|
|
|
27603
27666
|
/***/ }),
|
|
27604
|
-
/*
|
|
27667
|
+
/* 80 */
|
|
27605
27668
|
/***/ (function(module, exports, __webpack_require__) {
|
|
27606
27669
|
|
|
27607
27670
|
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
|
27608
27671
|
* URI.js - Mutating URLs
|
|
27609
27672
|
*
|
|
27610
|
-
* Version: 1.19.
|
|
27673
|
+
* Version: 1.19.11
|
|
27611
27674
|
*
|
|
27612
27675
|
* Author: Rodney Rehm
|
|
27613
27676
|
* Web: http://medialize.github.io/URI.js/
|
|
@@ -27687,7 +27750,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
27687
27750
|
return /^[0-9]+$/.test(value);
|
|
27688
27751
|
}
|
|
27689
27752
|
|
|
27690
|
-
URI.version = '1.19.
|
|
27753
|
+
URI.version = '1.19.11';
|
|
27691
27754
|
|
|
27692
27755
|
var p = URI.prototype;
|
|
27693
27756
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
@@ -27845,6 +27908,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
27845
27908
|
// balanced parens inclusion (), [], {}, <>
|
|
27846
27909
|
parens: /(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g,
|
|
27847
27910
|
};
|
|
27911
|
+
URI.leading_whitespace_expression = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/
|
|
27912
|
+
// https://infra.spec.whatwg.org/#ascii-tab-or-newline
|
|
27913
|
+
URI.ascii_tab_whitespace = /[\u0009\u000A\u000D]+/g
|
|
27848
27914
|
// http://www.iana.org/assignments/uri-schemes.html
|
|
27849
27915
|
// http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports
|
|
27850
27916
|
URI.defaultPorts = {
|
|
@@ -28100,6 +28166,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
28100
28166
|
preventInvalidHostname: URI.preventInvalidHostname
|
|
28101
28167
|
};
|
|
28102
28168
|
}
|
|
28169
|
+
|
|
28170
|
+
string = string.replace(URI.leading_whitespace_expression, '')
|
|
28171
|
+
// https://infra.spec.whatwg.org/#ascii-tab-or-newline
|
|
28172
|
+
string = string.replace(URI.ascii_tab_whitespace, '')
|
|
28173
|
+
|
|
28103
28174
|
// [protocol"://"[username[":"password]"@"]hostname[":"port]"/"?][path]["?"querystring]["#"fragment]
|
|
28104
28175
|
|
|
28105
28176
|
// extract fragment
|
|
@@ -28118,6 +28189,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
28118
28189
|
string = string.substring(0, pos);
|
|
28119
28190
|
}
|
|
28120
28191
|
|
|
28192
|
+
// slashes and backslashes have lost all meaning for the web protocols (https, http, wss, ws)
|
|
28193
|
+
string = string.replace(/^(https?|ftp|wss?)?:+[/\\]*/i, '$1://');
|
|
28194
|
+
// slashes and backslashes have lost all meaning for scheme relative URLs
|
|
28195
|
+
string = string.replace(/^[/\\]{2,}/i, '//');
|
|
28196
|
+
|
|
28121
28197
|
// extract protocol
|
|
28122
28198
|
if (string.substring(0, 2) === '//') {
|
|
28123
28199
|
// relative-scheme
|
|
@@ -28132,7 +28208,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
28132
28208
|
if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) {
|
|
28133
28209
|
// : may be within the path
|
|
28134
28210
|
parts.protocol = undefined;
|
|
28135
|
-
} else if (string.substring(pos + 1, pos + 3) === '//') {
|
|
28211
|
+
} else if (string.substring(pos + 1, pos + 3).replace(/\\/g, '/') === '//') {
|
|
28136
28212
|
string = string.substring(pos + 3);
|
|
28137
28213
|
|
|
28138
28214
|
// extract "user:pass@host:port"
|
|
@@ -28264,7 +28340,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
28264
28340
|
// no "=" is null according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#collect-url-parameters
|
|
28265
28341
|
value = v.length ? URI.decodeQuery(v.join('='), escapeQuerySpace) : null;
|
|
28266
28342
|
|
|
28267
|
-
if (
|
|
28343
|
+
if (name === '__proto__') {
|
|
28344
|
+
// ignore attempt at exploiting JavaScript internals
|
|
28345
|
+
continue;
|
|
28346
|
+
} else if (hasOwn.call(items, name)) {
|
|
28268
28347
|
if (typeof items[name] === 'string' || items[name] === null) {
|
|
28269
28348
|
items[name] = [items[name]];
|
|
28270
28349
|
}
|
|
@@ -28357,7 +28436,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
28357
28436
|
var t = '';
|
|
28358
28437
|
var unique, key, i, length;
|
|
28359
28438
|
for (key in data) {
|
|
28360
|
-
if (
|
|
28439
|
+
if (key === '__proto__') {
|
|
28440
|
+
// ignore attempt at exploiting JavaScript internals
|
|
28441
|
+
continue;
|
|
28442
|
+
} else if (hasOwn.call(data, key)) {
|
|
28361
28443
|
if (isArray(data[key])) {
|
|
28362
28444
|
unique = {};
|
|
28363
28445
|
for (i = 0, length = data[key].length; i < length; i++) {
|
|
@@ -29951,6 +30033,41 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
29951
30033
|
}));
|
|
29952
30034
|
|
|
29953
30035
|
|
|
30036
|
+
/***/ }),
|
|
30037
|
+
/* 81 */
|
|
30038
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
30039
|
+
|
|
30040
|
+
"use strict";
|
|
30041
|
+
|
|
30042
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30043
|
+
class ServerError extends Error {
|
|
30044
|
+
constructor(message = "Unknown Error", statusCode = 500) {
|
|
30045
|
+
super(message);
|
|
30046
|
+
this.statusCode = statusCode;
|
|
30047
|
+
}
|
|
30048
|
+
toData() {
|
|
30049
|
+
return {
|
|
30050
|
+
isError: true,
|
|
30051
|
+
errorCode: this.statusCode,
|
|
30052
|
+
errorMessage: this.message
|
|
30053
|
+
};
|
|
30054
|
+
}
|
|
30055
|
+
}
|
|
30056
|
+
exports.default = ServerError;
|
|
30057
|
+
//# sourceMappingURL=ServerError.js.map
|
|
30058
|
+
|
|
30059
|
+
/***/ }),
|
|
30060
|
+
/* 82 */
|
|
30061
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
30062
|
+
|
|
30063
|
+
"use strict";
|
|
30064
|
+
|
|
30065
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30066
|
+
const uuidRegEx = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
30067
|
+
const isUuid = (id) => typeof id === "string" && uuidRegEx.test(id);
|
|
30068
|
+
exports.default = isUuid;
|
|
30069
|
+
//# sourceMappingURL=isUuid.js.map
|
|
30070
|
+
|
|
29954
30071
|
/***/ })
|
|
29955
30072
|
/******/ ]);
|
|
29956
30073
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magda/auth-api-client",
|
|
3
3
|
"description": "MAGDA Auth API Client",
|
|
4
|
-
"version": "2.0.0-alpha.
|
|
4
|
+
"version": "2.0.0-alpha.4",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prebuild": "rimraf dist tsconfig.tsbuildinfo",
|
|
7
7
|
"build": "webpack && api-extractor run -l",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"main": "dist/index.js",
|
|
13
13
|
"types": "dist/index.d.ts",
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@magda/typescript-common": "^2.0.0-alpha.
|
|
15
|
+
"@magda/typescript-common": "^2.0.0-alpha.4",
|
|
16
16
|
"@microsoft/api-extractor": "^7.7.8",
|
|
17
17
|
"ts-loader": "^6.2.1",
|
|
18
18
|
"typescript": "^3.7.2",
|