akamai-edgegrid 3.1.4 → 3.2.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/CHANGELOG.md +5 -0
- package/index.d.ts +33 -0
- package/index.test-d.ts +19 -0
- package/package.json +3 -2
- package/src/api.js +6 -0
- package/test1/bundle.json +0 -5
- package/test1/main.js +0 -15
- package/test1 2/bundle.json +0 -5
- package/test1 2/main.js +0 -15
- package/test5/bundle.json +0 -5
- package/test5/main.js +0 -15
package/CHANGELOG.md
CHANGED
package/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AxiosError, AxiosResponse } from "axios";
|
|
2
|
+
|
|
3
|
+
declare class EdgeGrid {
|
|
4
|
+
constructor(clientTokenOrOptions: string | object,
|
|
5
|
+
clientSecret?: string,
|
|
6
|
+
accessToken?: string,
|
|
7
|
+
host?: string,
|
|
8
|
+
debug?: boolean);
|
|
9
|
+
|
|
10
|
+
request: object;
|
|
11
|
+
config: object;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Sends the request and invokes the callback function.
|
|
15
|
+
*
|
|
16
|
+
* @param {Function} callback The callback function.
|
|
17
|
+
* @return EdgeGrid object (self)
|
|
18
|
+
*/
|
|
19
|
+
send(callback: (error: AxiosError, response?: AxiosResponse, body?: string) => void): EdgeGrid;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Builds the request using the properties of the local config Object.
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} req The request Object. Can optionally contain a
|
|
25
|
+
* 'headersToSign' property: An ordered list header names
|
|
26
|
+
* that will be included in the signature. This will be
|
|
27
|
+
* provided by specific APIs.
|
|
28
|
+
* @return EdgeGrid object (self)
|
|
29
|
+
*/
|
|
30
|
+
auth(req: object): EdgeGrid;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export = EdgeGrid;
|
package/index.test-d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { expectType } from 'tsd';
|
|
2
|
+
import EdgeGrid = require('.')
|
|
3
|
+
|
|
4
|
+
const eg = new EdgeGrid({
|
|
5
|
+
path: '/path/to/.edgerc',
|
|
6
|
+
section: 'section-name'
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
expectType<EdgeGrid>(eg)
|
|
10
|
+
|
|
11
|
+
var req = {
|
|
12
|
+
path: '/diagnostic-tools/v1/locations',
|
|
13
|
+
method: 'GET',
|
|
14
|
+
headers: {},
|
|
15
|
+
body: 'bodyData'
|
|
16
|
+
}
|
|
17
|
+
expectType<EdgeGrid>(eg.auth(req))
|
|
18
|
+
|
|
19
|
+
expectType<EdgeGrid>(eg.send((error, resp, body) => console.log(body)))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "akamai-edgegrid",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Authentication handler for the Akamai OPEN EdgeGrid Authentication scheme in Node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"mocha": "^9.1.3",
|
|
33
|
-
"nock": "^13.2.2"
|
|
33
|
+
"nock": "^13.2.2",
|
|
34
|
+
"tsd": "^0.20.0"
|
|
34
35
|
}
|
|
35
36
|
}
|
package/src/api.js
CHANGED
|
@@ -90,6 +90,12 @@ EdgeGrid.prototype.auth = function (req) {
|
|
|
90
90
|
return this;
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Sends the request and invokes the callback function.
|
|
95
|
+
*
|
|
96
|
+
* @param {Function} callback The callback function.
|
|
97
|
+
* @return EdgeGrid object (self)
|
|
98
|
+
*/
|
|
93
99
|
EdgeGrid.prototype.send = function (callback) {
|
|
94
100
|
axios(this.request).then(response => {
|
|
95
101
|
callback(null, response, JSON.stringify(response.data));
|
package/test1/bundle.json
DELETED
package/test1/main.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export function onClientRequest(request) {
|
|
2
|
-
request.addHeader('EW_CLIENT_REQ', 'Automation Client Req');
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function onClientResponse(request, response) {
|
|
6
|
-
response.addHeader('EW_CLIENT_RSP', 'Automation Client Rsp');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function onOriginResponse(request, response) {
|
|
10
|
-
response.addHeader('EW_ORIGIN_RSP', 'Automation Origin Rsp');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function onOriginRequest(request) {
|
|
14
|
-
request.addHeader('EW_ORIGIN_REQ', 'Automation Origin Req');
|
|
15
|
-
}
|
package/test1 2/bundle.json
DELETED
package/test1 2/main.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export function onClientRequest(request) {
|
|
2
|
-
request.addHeader('EW_CLIENT_REQ', 'Automation Client Req');
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function onClientResponse(request, response) {
|
|
6
|
-
response.addHeader('EW_CLIENT_RSP', 'Automation Client Rsp');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function onOriginResponse(request, response) {
|
|
10
|
-
response.addHeader('EW_ORIGIN_RSP', 'Automation Origin Rsp');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function onOriginRequest(request) {
|
|
14
|
-
request.addHeader('EW_ORIGIN_REQ', 'Automation Origin Req');
|
|
15
|
-
}
|
package/test5/bundle.json
DELETED
package/test5/main.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export function onClientRequest(request) {
|
|
2
|
-
request.addHeader('EW_CLIENT_REQ', 'Automation Client Req');
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function onClientResponse(request, response) {
|
|
6
|
-
response.addHeader('EW_CLIENT_RSP', 'Automation Client Rsp');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function onOriginResponse(request, response) {
|
|
10
|
-
response.addHeader('EW_ORIGIN_RSP', 'Automation Origin Rsp');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function onOriginRequest(request) {
|
|
14
|
-
request.addHeader('EW_ORIGIN_REQ', 'Automation Origin Req');
|
|
15
|
-
}
|