telos-autocors 1.0.1 → 1.0.3
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/README.md +4 -4
- package/package.json +1 -1
- package/apintUtils.js +0 -114
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
***You Shall Pass!***
|
|
6
6
|
|
|
7
|
-
AutoCORS is a JavaScript IO library, which, among other things, provides a set utilities, built
|
|
7
|
+
AutoCORS is a JavaScript IO library, which, among other things, provides a set of utilities, built
|
|
8
8
|
upon associated conventions, which enable in-browser HTTP requests to be automatically routed
|
|
9
9
|
through CORS proxies.
|
|
10
10
|
|
|
@@ -36,12 +36,12 @@ The body field, if present, contains a string specifying the body of the HTTP re
|
|
|
36
36
|
|
|
37
37
|
An HTTP JSON GET request to example.com:
|
|
38
38
|
|
|
39
|
-
{ "request": { "method: "GET", uri: "https://example.com/" } }
|
|
39
|
+
{ "request": { "method": "GET", uri: "https://example.com/" } }
|
|
40
40
|
|
|
41
41
|
An HTTP JSON POST request to example.com:
|
|
42
42
|
|
|
43
43
|
{
|
|
44
|
-
"request": { "method: "POST", uri: "https://example.com/" },
|
|
44
|
+
"request": { "method": "POST", uri: "https://example.com/" },
|
|
45
45
|
"headers": {
|
|
46
46
|
"Host": "example.com",
|
|
47
47
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
@@ -54,7 +54,7 @@ An HTTP JSON POST request to example.com:
|
|
|
54
54
|
|
|
55
55
|
AutoCORS may be used on any page via the AutoCORS script.
|
|
56
56
|
|
|
57
|
-
Once included,
|
|
57
|
+
Once included, the script shall place an object with the alias "autoCORS" into the global namespace
|
|
58
58
|
of the page.
|
|
59
59
|
|
|
60
60
|
The default functionality of AutoCORS can be activated by running:
|
package/package.json
CHANGED
package/apintUtils.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
var apintUtils = {
|
|
2
|
-
buildAPInt: (apint, path) => {
|
|
3
|
-
|
|
4
|
-
apint = JSON.parse(JSON.stringify(apint));
|
|
5
|
-
path = path != null ? path : [];
|
|
6
|
-
|
|
7
|
-
if(apint.packages == null)
|
|
8
|
-
return apint;
|
|
9
|
-
|
|
10
|
-
Object.keys(apint.packages).forEach(key => {
|
|
11
|
-
|
|
12
|
-
if(typeof apint.packages[key] == "string") {
|
|
13
|
-
|
|
14
|
-
if(path.includes(apint.packages[key]))
|
|
15
|
-
return;
|
|
16
|
-
|
|
17
|
-
apint.packages[key] = apintUtils.buildAPInt(
|
|
18
|
-
use(apint.packages[key]),
|
|
19
|
-
path.concat(apint.packages[key])
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
else {
|
|
24
|
-
|
|
25
|
-
apint.packages[key] = apintUtils.buildAPInt(
|
|
26
|
-
apint.packages[key], path
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
return apint;
|
|
32
|
-
},
|
|
33
|
-
queryUtilities: (apint, path, properties, inheritance) => {
|
|
34
|
-
|
|
35
|
-
path = path != null ? path : [];
|
|
36
|
-
|
|
37
|
-
if(typeof path == "string")
|
|
38
|
-
path = path.split(".").map(item => item.toLowerCase());
|
|
39
|
-
|
|
40
|
-
inheritance = inheritance != null ?
|
|
41
|
-
JSON.parse(JSON.stringify(inheritance)) : { };
|
|
42
|
-
|
|
43
|
-
properties = properties != null ? properties : { };
|
|
44
|
-
|
|
45
|
-
if(apint.properties != null)
|
|
46
|
-
Object.assign(inheritance, apint.properties);
|
|
47
|
-
|
|
48
|
-
let utilities = [];
|
|
49
|
-
|
|
50
|
-
if(path.length <= 1 && apint.utilities != null) {
|
|
51
|
-
|
|
52
|
-
Object.keys(apint.utilities).forEach(key => {
|
|
53
|
-
|
|
54
|
-
let utility = JSON.parse(JSON.stringify(apint.utilities[key]));
|
|
55
|
-
|
|
56
|
-
utility.properties = Object.assign(
|
|
57
|
-
Object.assign({ }, inheritance),
|
|
58
|
-
utility.properties != null ? utility.properties : { }
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
let match = true;
|
|
62
|
-
|
|
63
|
-
Object.keys(properties).forEach((item) => {
|
|
64
|
-
|
|
65
|
-
if(JSON.stringify(properties[item]) !=
|
|
66
|
-
JSON.stringify(utility.properties[item])) {
|
|
67
|
-
|
|
68
|
-
match = false;
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
if(match)
|
|
73
|
-
utilities.push(utility);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if(apint.packages != null) {
|
|
78
|
-
|
|
79
|
-
Object.keys(apint.packages).forEach(key => {
|
|
80
|
-
|
|
81
|
-
if(typeof apint.packages[key] == "string")
|
|
82
|
-
return;
|
|
83
|
-
|
|
84
|
-
if(path.length > 0) {
|
|
85
|
-
|
|
86
|
-
if(key.toLowerCase() == path[0])
|
|
87
|
-
path = path.slice(1);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
utilities = utilities.concat(
|
|
91
|
-
apintUtils.queryUtilities(
|
|
92
|
-
apint.packages[key], path, properties, inheritance
|
|
93
|
-
)
|
|
94
|
-
);
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return utilities;
|
|
99
|
-
},
|
|
100
|
-
loadUtility: (apint, query) => {
|
|
101
|
-
|
|
102
|
-
let utility = apintUtils.queryUtilities(apint, query)[0];
|
|
103
|
-
|
|
104
|
-
if(utility == null)
|
|
105
|
-
return null;
|
|
106
|
-
|
|
107
|
-
return use(
|
|
108
|
-
Array.isArray(utility.source) ? utility.source[0] : utility.source
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
if(typeof module == "object")
|
|
114
|
-
module.exports = apintUtils;
|