celitech-sdk 1.1.75 → 1.1.76
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/.manifest.json +9 -9
- package/README.md +2 -2
- package/dist/http/hooks/custom-hook.d.ts +1 -1
- package/dist/http/hooks/custom-hook.d.ts.map +1 -1
- package/dist/http/hooks/custom-hook.js +23 -24
- package/dist/http/hooks/custom-hook.js.map +1 -1
- package/examples/package.json +1 -1
- package/package.json +1 -1
- package/src/http/hooks/custom-hook.ts +27 -26
package/.manifest.json
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"liblabVersion": "2.1.23",
|
3
|
-
"date": "2024-07-
|
3
|
+
"date": "2024-07-24T20:35:09.860Z",
|
4
4
|
"config": {
|
5
|
-
"apiId":
|
5
|
+
"apiId": 958,
|
6
6
|
"sdkName": "Celitech",
|
7
|
-
"sdkVersion": "1.1.
|
7
|
+
"sdkVersion": "1.1.76",
|
8
8
|
"liblabVersion": "2",
|
9
9
|
"deliveryMethods": ["zip"],
|
10
10
|
"languages": ["typescript"],
|
11
|
-
"apiVersion": "1.1.
|
11
|
+
"apiVersion": "1.1.76",
|
12
12
|
"specFilePath": "swagger.yaml",
|
13
13
|
"languageOptions": {
|
14
14
|
"python": {
|
@@ -26,7 +26,7 @@
|
|
26
26
|
"pypiPackageName": "celitech-sdk",
|
27
27
|
"githubRepoName": "CelitechSDKPython",
|
28
28
|
"liblabVersion": "2",
|
29
|
-
"sdkVersion": "1.1.
|
29
|
+
"sdkVersion": "1.1.76"
|
30
30
|
},
|
31
31
|
"php": {
|
32
32
|
"packageName": "celitech-sdk/sdk",
|
@@ -42,7 +42,7 @@
|
|
42
42
|
],
|
43
43
|
"githubRepoName": "CelitechSDKPHP",
|
44
44
|
"liblabVersion": "2",
|
45
|
-
"sdkVersion": "1.1.
|
45
|
+
"sdkVersion": "1.1.76"
|
46
46
|
},
|
47
47
|
"typescript": {
|
48
48
|
"bundle": false,
|
@@ -61,7 +61,7 @@
|
|
61
61
|
],
|
62
62
|
"githubRepoName": "CelitechSDKTypeScript",
|
63
63
|
"liblabVersion": "2",
|
64
|
-
"sdkVersion": "1.1.
|
64
|
+
"sdkVersion": "1.1.76"
|
65
65
|
}
|
66
66
|
},
|
67
67
|
"publishing": {
|
@@ -101,10 +101,10 @@
|
|
101
101
|
},
|
102
102
|
"multiTenant": true,
|
103
103
|
"hooksLocation": {
|
104
|
-
"bucketKey": "
|
104
|
+
"bucketKey": "6380/hooks.zip",
|
105
105
|
"bucketName": "prod-liblab-api-stack-hooks"
|
106
106
|
},
|
107
|
-
"specUrl": "https://prod-liblab-api-stack-specs.s3.us-east-1.amazonaws.com/
|
107
|
+
"specUrl": "https://prod-liblab-api-stack-specs.s3.us-east-1.amazonaws.com/958/open-api-spec.yaml?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA5P3QKKDKGVNIJ2H7%2F20240724%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240724T203504Z&X-Amz-Expires=43200&X-Amz-Signature=4497e4e2eee7384abccec4c2d4e2fcb3ebaa7802938725acea013e971d94b37c&X-Amz-SignedHeaders=host&x-id=GetObject",
|
108
108
|
"includeWatermark": false,
|
109
109
|
"language": "typescript",
|
110
110
|
"deliveryMethod": "zip",
|
package/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
# Celitech TypeScript SDK 1.1.
|
1
|
+
# Celitech TypeScript SDK 1.1.76
|
2
2
|
|
3
3
|
Welcome to the Celitech SDK documentation. This guide will help you get started with integrating and using the Celitech SDK in your project.
|
4
4
|
|
5
5
|
## Versions
|
6
6
|
|
7
7
|
- API version: `1.1.0`
|
8
|
-
- SDK version: `1.1.
|
8
|
+
- SDK version: `1.1.76`
|
9
9
|
|
10
10
|
## About the API
|
11
11
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Hook } from './hook';
|
2
2
|
import { HttpRequest, HttpResponse, HttpError } from './hook';
|
3
3
|
export declare class CustomHook implements Hook {
|
4
|
+
getToken(clientId: string, clientSecret: string): Promise<any>;
|
4
5
|
beforeRequest(request: HttpRequest, params: Map<string, string>): Promise<HttpRequest>;
|
5
|
-
getToken(input: any): Promise<any>;
|
6
6
|
afterResponse(request: HttpRequest, response: HttpResponse<any>, params: Map<string, string>): Promise<HttpResponse<any>>;
|
7
7
|
onError(request: HttpRequest, response: HttpResponse<any>, params: Map<string, string>): Promise<HttpError>;
|
8
8
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"custom-hook.d.ts","sourceRoot":"","sources":["../../../src/http/hooks/custom-hook.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAK9D,qBAAa,UAAW,YAAW,IAAI;
|
1
|
+
{"version":3,"file":"custom-hook.d.ts","sourceRoot":"","sources":["../../../src/http/hooks/custom-hook.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAK9D,qBAAa,UAAW,YAAW,IAAI;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAsBvD,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IA+CtF,aAAa,CACxB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,EAC3B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAIhB,OAAO,CAClB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,EAC3B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,OAAO,CAAC,SAAS,CAAC;CAGtB"}
|
@@ -13,12 +13,29 @@ exports.CustomHook = void 0;
|
|
13
13
|
let CURRENT_TOKEN = '';
|
14
14
|
let CURRENT_EXPIRY = -1;
|
15
15
|
class CustomHook {
|
16
|
+
getToken(clientId, clientSecret) {
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
18
|
+
const tokenUrl = 'https://auth.celitech.net/oauth2/token';
|
19
|
+
const headers = {
|
20
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
21
|
+
};
|
22
|
+
const body = {
|
23
|
+
client_id: clientId,
|
24
|
+
client_secret: clientSecret,
|
25
|
+
grant_type: 'client_credentials',
|
26
|
+
};
|
27
|
+
const response = yield fetch(tokenUrl, {
|
28
|
+
method: 'POST',
|
29
|
+
headers: headers,
|
30
|
+
body: new URLSearchParams(body),
|
31
|
+
});
|
32
|
+
return response.json();
|
33
|
+
});
|
34
|
+
}
|
16
35
|
beforeRequest(request, params) {
|
17
36
|
return __awaiter(this, void 0, void 0, function* () {
|
18
37
|
console.log('request', request);
|
19
38
|
console.log('params', params);
|
20
|
-
if (request.path.endsWith('/oauth/token'))
|
21
|
-
return request;
|
22
39
|
const clientId = params.get('clientId') || '';
|
23
40
|
const clientSecret = params.get('clientSecret') || '';
|
24
41
|
console.log('clientId', clientId);
|
@@ -27,16 +44,13 @@ class CustomHook {
|
|
27
44
|
throw new Error('Missing clientId and/or clientSecret constructor parameters');
|
28
45
|
}
|
29
46
|
if (!CURRENT_TOKEN || CURRENT_EXPIRY < Date.now()) {
|
30
|
-
// Prepare the request payload for fecthing a fresh Oauth token
|
31
|
-
const input = {
|
32
|
-
client_id: clientId || '',
|
33
|
-
client_secret: clientSecret || '',
|
34
|
-
grant_type: 'client_credentials',
|
35
|
-
};
|
36
47
|
// Fetch a fresh Oauth token
|
37
48
|
// Retrieve the new access token and expiry, and set them to the global variables
|
38
|
-
const tokenResponse = yield this.getToken(
|
49
|
+
const tokenResponse = yield this.getToken(clientId, clientSecret);
|
39
50
|
console.log('tokenResponse', tokenResponse);
|
51
|
+
if (!tokenResponse.error) {
|
52
|
+
throw new Error(tokenResponse.error);
|
53
|
+
}
|
40
54
|
const { expires_in, access_token } = tokenResponse;
|
41
55
|
if (!expires_in || !access_token) {
|
42
56
|
throw new Error('There is an issue with getting the oauth token');
|
@@ -54,21 +68,6 @@ class CustomHook {
|
|
54
68
|
return request;
|
55
69
|
});
|
56
70
|
}
|
57
|
-
getToken(input) {
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
59
|
-
const tokenUrl = 'https://auth.celitech.net/oauth2/token';
|
60
|
-
const response = yield fetch(tokenUrl, {
|
61
|
-
method: 'POST',
|
62
|
-
headers: {
|
63
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
64
|
-
},
|
65
|
-
body: new URLSearchParams(input),
|
66
|
-
}).catch((error) => {
|
67
|
-
throw new Error('Error in posting the request:' + error);
|
68
|
-
});
|
69
|
-
return response.json();
|
70
|
-
});
|
71
|
-
}
|
72
71
|
afterResponse(request, response, params) {
|
73
72
|
return __awaiter(this, void 0, void 0, function* () {
|
74
73
|
return response;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"custom-hook.js","sourceRoot":"","sources":["../../../src/http/hooks/custom-hook.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,IAAI,aAAa,GAAG,EAAE,CAAC;AACvB,IAAI,cAAc,GAAG,CAAC,CAAC,CAAC;AAExB,MAAa,UAAU;
|
1
|
+
{"version":3,"file":"custom-hook.js","sourceRoot":"","sources":["../../../src/http/hooks/custom-hook.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,IAAI,aAAa,GAAG,EAAE,CAAC;AACvB,IAAI,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tB,UAAK,GAAL,KAAK,CAAQ;QACb,aAAQ,GAAR,QAAQ,CAAc;IAC5B,CAAC;CACL"}
|
package/examples/package.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "celitech-sdk",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.76",
|
4
4
|
"description": "Welcome to the CELITECH API documentation! Useful links: [Homepage](https://www.celitech.com) | [Support email](mailto:support@celitech.com) | [Blog](https://www.celitech.com/blog/) ",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -6,12 +6,32 @@ let CURRENT_TOKEN = '';
|
|
6
6
|
let CURRENT_EXPIRY = -1;
|
7
7
|
|
8
8
|
export class CustomHook implements Hook {
|
9
|
+
async getToken(clientId: string, clientSecret: string): Promise<any> {
|
10
|
+
const tokenUrl = 'https://auth.celitech.net/oauth2/token';
|
11
|
+
|
12
|
+
const headers = {
|
13
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
14
|
+
};
|
15
|
+
|
16
|
+
const body = {
|
17
|
+
client_id: clientId,
|
18
|
+
client_secret: clientSecret,
|
19
|
+
grant_type: 'client_credentials',
|
20
|
+
};
|
21
|
+
|
22
|
+
const response = await fetch(tokenUrl, {
|
23
|
+
method: 'POST',
|
24
|
+
headers: headers,
|
25
|
+
body: new URLSearchParams(body),
|
26
|
+
});
|
27
|
+
|
28
|
+
return response.json();
|
29
|
+
}
|
30
|
+
|
9
31
|
public async beforeRequest(request: HttpRequest, params: Map<string, string>): Promise<HttpRequest> {
|
10
32
|
console.log('request', request);
|
11
33
|
console.log('params', params);
|
12
34
|
|
13
|
-
if (request.path.endsWith('/oauth/token')) return request;
|
14
|
-
|
15
35
|
const clientId = params.get('clientId') || '';
|
16
36
|
const clientSecret = params.get('clientSecret') || '';
|
17
37
|
|
@@ -23,19 +43,16 @@ export class CustomHook implements Hook {
|
|
23
43
|
}
|
24
44
|
|
25
45
|
if (!CURRENT_TOKEN || CURRENT_EXPIRY < Date.now()) {
|
26
|
-
// Prepare the request payload for fecthing a fresh Oauth token
|
27
|
-
const input = {
|
28
|
-
client_id: clientId || '',
|
29
|
-
client_secret: clientSecret || '',
|
30
|
-
grant_type: 'client_credentials',
|
31
|
-
};
|
32
|
-
|
33
46
|
// Fetch a fresh Oauth token
|
34
47
|
// Retrieve the new access token and expiry, and set them to the global variables
|
35
|
-
const tokenResponse = await this.getToken(
|
48
|
+
const tokenResponse = await this.getToken(clientId, clientSecret);
|
36
49
|
|
37
50
|
console.log('tokenResponse', tokenResponse);
|
38
51
|
|
52
|
+
if (!tokenResponse.error) {
|
53
|
+
throw new Error(tokenResponse.error);
|
54
|
+
}
|
55
|
+
|
39
56
|
const { expires_in, access_token } = tokenResponse;
|
40
57
|
|
41
58
|
if (!expires_in || !access_token) {
|
@@ -58,22 +75,6 @@ export class CustomHook implements Hook {
|
|
58
75
|
return request;
|
59
76
|
}
|
60
77
|
|
61
|
-
async getToken(input: any): Promise<any> {
|
62
|
-
const tokenUrl = 'https://auth.celitech.net/oauth2/token';
|
63
|
-
|
64
|
-
const response = await fetch(tokenUrl, {
|
65
|
-
method: 'POST',
|
66
|
-
headers: {
|
67
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
68
|
-
},
|
69
|
-
body: new URLSearchParams(input),
|
70
|
-
}).catch((error) => {
|
71
|
-
throw new Error('Error in posting the request:' + error);
|
72
|
-
});
|
73
|
-
|
74
|
-
return response.json();
|
75
|
-
}
|
76
|
-
|
77
78
|
public async afterResponse(
|
78
79
|
request: HttpRequest,
|
79
80
|
response: HttpResponse<any>,
|