attlaz-client 1.13.11 → 1.13.13
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.
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import { UserAuthProvider } from '../Model/User/UserAuthProvider.js';
|
|
2
|
-
import { OAuthClientToken } from '../Http/OAuthClientToken.js';
|
|
3
2
|
import { Endpoint } from './Endpoint.js';
|
|
4
3
|
import { User } from '../Model/User.js';
|
|
5
4
|
import { CollectionResult } from '../Model/Result/CollectionResult.js';
|
|
6
5
|
export declare class UserEndpoint extends Endpoint {
|
|
7
6
|
getUser(): Promise<User | null>;
|
|
8
|
-
authenticateByAuthProvider(providerType: string, data: {
|
|
9
|
-
code: string;
|
|
10
|
-
state: string;
|
|
11
|
-
}): Promise<OAuthClientToken>;
|
|
12
|
-
createAuthProvider(providerType: string, data: {
|
|
13
|
-
code: string;
|
|
14
|
-
state: string;
|
|
15
|
-
}): Promise<boolean>;
|
|
16
7
|
removeAuthProvider(providerId: number): Promise<boolean>;
|
|
17
8
|
getAuthProviders(): Promise<CollectionResult<UserAuthProvider>>;
|
|
18
9
|
getPermissions(): Promise<CollectionResult<{
|
|
@@ -1,60 +1,33 @@
|
|
|
1
1
|
import { UserAuthProvider } from '../Model/User/UserAuthProvider.js';
|
|
2
|
-
import { OAuthClientToken } from '../Http/OAuthClientToken.js';
|
|
3
2
|
import { Endpoint } from './Endpoint.js';
|
|
4
3
|
import { User } from '../Model/User.js';
|
|
5
|
-
import { Utils } from '../Utils.js';
|
|
6
4
|
export class UserEndpoint extends Endpoint {
|
|
7
5
|
async getUser() {
|
|
8
6
|
const cmd = '/users';
|
|
9
7
|
const rawUser = await this.requestObject(cmd, null, User.parse);
|
|
10
8
|
return rawUser.getData();
|
|
11
9
|
}
|
|
12
|
-
async
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
console.error('Failed to perform social auth: ', e);
|
|
34
|
-
}
|
|
35
|
-
throw e;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async createAuthProvider(providerType, data) {
|
|
39
|
-
try {
|
|
40
|
-
const parser = (raw) => raw;
|
|
41
|
-
const result = await this.requestObject('/users/auth/providers', {
|
|
42
|
-
provider_type: providerType, code: data.code, state: data.state
|
|
43
|
-
}, parser, 'POST');
|
|
44
|
-
const re = result.getData();
|
|
45
|
-
if (re === null) {
|
|
46
|
-
console.log('create auth provider wrong data', { result, parsed: re });
|
|
47
|
-
throw new Error('Unable to create auth provider: wrong response from API');
|
|
48
|
-
}
|
|
49
|
-
return re.created;
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
if (this.httpClient.isDebugEnabled()) {
|
|
53
|
-
console.error('Failed to assign auth provider: ', e);
|
|
54
|
-
}
|
|
55
|
-
throw e;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
10
|
+
// public async createAuthProvider(providerType: string, data: { code: string; state: string }): Promise<boolean> {
|
|
11
|
+
// try {
|
|
12
|
+
// const parser = (raw: any): { created: boolean } => raw;
|
|
13
|
+
// const result: ObjectResult<{
|
|
14
|
+
// created: boolean
|
|
15
|
+
// }> = await this.requestObject('/users/auth/providers', {
|
|
16
|
+
// provider_type: providerType, code: data.code, state: data.state
|
|
17
|
+
// }, parser, 'POST');
|
|
18
|
+
// const re: { created: boolean } | null = result.getData();
|
|
19
|
+
// if (re === null) {
|
|
20
|
+
// console.log('create auth provider wrong data', {result, parsed: re});
|
|
21
|
+
// throw new Error('Unable to create auth provider: wrong response from API');
|
|
22
|
+
// }
|
|
23
|
+
// return re.created;
|
|
24
|
+
// } catch (e) {
|
|
25
|
+
// if (this.httpClient.isDebugEnabled()) {
|
|
26
|
+
// console.error('Failed to assign auth provider: ', e);
|
|
27
|
+
// }
|
|
28
|
+
// throw e;
|
|
29
|
+
// }
|
|
30
|
+
// }
|
|
58
31
|
async removeAuthProvider(providerId) {
|
|
59
32
|
try {
|
|
60
33
|
const parser = (raw) => ({ deleted: raw.deleted });
|