@nestia/fetcher 11.0.2 → 11.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/lib/AesPkcs5.mjs +46 -0
- package/lib/AesPkcs5.mjs.map +1 -0
- package/lib/EncryptedFetcher.mjs +83 -0
- package/lib/EncryptedFetcher.mjs.map +1 -0
- package/lib/FormDataInput.mjs +2 -0
- package/lib/FormDataInput.mjs.map +1 -0
- package/lib/HttpError.mjs +2 -0
- package/lib/HttpError.mjs.map +1 -0
- package/lib/IConnection.mjs +2 -0
- package/lib/IConnection.mjs.map +1 -0
- package/lib/IEncryptionPassword.mjs +2 -0
- package/lib/IEncryptionPassword.mjs.map +1 -0
- package/lib/IFetchEvent.mjs +2 -0
- package/lib/IFetchEvent.mjs.map +1 -0
- package/lib/IFetchRoute.mjs +2 -0
- package/lib/IFetchRoute.mjs.map +1 -0
- package/lib/IPropagation.mjs +2 -0
- package/lib/IPropagation.mjs.map +1 -0
- package/lib/NestiaSimulator.mjs +44 -0
- package/lib/NestiaSimulator.mjs.map +1 -0
- package/lib/PlainFetcher.mjs +43 -0
- package/lib/PlainFetcher.mjs.map +1 -0
- package/lib/index.d.ts +2 -4
- package/lib/index.js +2 -4
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +4 -0
- package/lib/index.mjs.map +1 -0
- package/lib/internal/FetcherBase.mjs +180 -0
- package/lib/internal/FetcherBase.mjs.map +1 -0
- package/package.json +23 -5
- package/src/index.ts +2 -4
package/lib/AesPkcs5.mjs
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility class for the AES-128/256 encryption.
|
|
5
|
+
*
|
|
6
|
+
* - AES-128/256
|
|
7
|
+
* - CBC mode
|
|
8
|
+
* - PKCS#5 Padding
|
|
9
|
+
* - Base64 Encoding
|
|
10
|
+
*
|
|
11
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
12
|
+
*/
|
|
13
|
+
var AesPkcs5;
|
|
14
|
+
(function (AesPkcs5) {
|
|
15
|
+
/**
|
|
16
|
+
* Encrypt data
|
|
17
|
+
*
|
|
18
|
+
* @param data Target data
|
|
19
|
+
* @param key Key value of the encryption.
|
|
20
|
+
* @param iv Initializer Vector for the encryption
|
|
21
|
+
* @returns Encrypted data
|
|
22
|
+
*/
|
|
23
|
+
function encrypt(data, key, iv) {
|
|
24
|
+
const bytes = key.length * 8;
|
|
25
|
+
const cipher = crypto.createCipheriv(`AES-${bytes}-CBC`, key, iv);
|
|
26
|
+
return cipher.update(data, "utf8", "base64") + cipher.final("base64");
|
|
27
|
+
}
|
|
28
|
+
AesPkcs5.encrypt = encrypt;
|
|
29
|
+
/**
|
|
30
|
+
* Decrypt data.
|
|
31
|
+
*
|
|
32
|
+
* @param data Target data
|
|
33
|
+
* @param key Key value of the decryption.
|
|
34
|
+
* @param iv Initializer Vector for the decryption
|
|
35
|
+
* @returns Decrypted data.
|
|
36
|
+
*/
|
|
37
|
+
function decrypt(data, key, iv) {
|
|
38
|
+
const bytes = key.length * 8;
|
|
39
|
+
const decipher = crypto.createDecipheriv(`AES-${bytes}-CBC`, key, iv);
|
|
40
|
+
return decipher.update(data, "base64", "utf8") + decipher.final("utf8");
|
|
41
|
+
}
|
|
42
|
+
AesPkcs5.decrypt = decrypt;
|
|
43
|
+
})(AesPkcs5 || (AesPkcs5 = {}));
|
|
44
|
+
|
|
45
|
+
export { AesPkcs5 };
|
|
46
|
+
//# sourceMappingURL=AesPkcs5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AesPkcs5.mjs","sources":["../src/AesPkcs5.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;;;;AASG;AACG,IAAW;AAAjB,CAAA,UAAiB,QAAQ,EAAA;AACvB;;;;;;;AAOG;AACH,IAAA,SAAgB,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU,EAAA;AAC3D,QAAA,MAAM,KAAK,GAAW,GAAG,CAAC,MAAM,GAAG,CAAC;AACpC,QAAA,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,CAAA,IAAA,EAAO,KAAK,CAAA,IAAA,CAAM,EAAE,GAAG,EAAE,EAAE,CAAC;AACjE,QAAA,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;IACvE;AAJgB,IAAA,QAAA,CAAA,OAAO,UAItB;AAED;;;;;;;AAOG;AACH,IAAA,SAAgB,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU,EAAA;AAC3D,QAAA,MAAM,KAAK,GAAW,GAAG,CAAC,MAAM,GAAG,CAAC;AACpC,QAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAA,IAAA,EAAO,KAAK,CAAA,IAAA,CAAM,EAAE,GAAG,EAAE,EAAE,CAAC;AACrE,QAAA,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;IACzE;AAJgB,IAAA,QAAA,CAAA,OAAO,UAItB;AACH,CAAC,EA5BgB,QAAQ,KAAR,QAAQ,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { AesPkcs5 } from './AesPkcs5.mjs';
|
|
2
|
+
import { FetcherBase } from './internal/FetcherBase.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Utility class for `fetch` functions used in `@nestia/sdk` with encryption.
|
|
6
|
+
*
|
|
7
|
+
* `EncryptedFetcher` is a utility class designed for SDK functions generated by
|
|
8
|
+
* [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote
|
|
9
|
+
* HTTP API encrypted by AES-PKCS algorithm. In other words, this is a
|
|
10
|
+
* collection of dedicated `fetch()` functions for `@nestia/sdk` with
|
|
11
|
+
* encryption.
|
|
12
|
+
*
|
|
13
|
+
* For reference, `EncryptedFetcher` class being used only when target
|
|
14
|
+
* controller method is encrypting body data by `@EncryptedRoute` or
|
|
15
|
+
* `@EncryptedBody` decorators. If those decorators are not used,
|
|
16
|
+
* {@link PlainFetcher} class would be used instead.
|
|
17
|
+
*
|
|
18
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
19
|
+
*/
|
|
20
|
+
var EncryptedFetcher;
|
|
21
|
+
(function (EncryptedFetcher) {
|
|
22
|
+
async function fetch(connection, route, input, stringify) {
|
|
23
|
+
if ((route.request?.encrypted === true || route.response?.encrypted) &&
|
|
24
|
+
connection.encryption === undefined)
|
|
25
|
+
throw new Error("Error on EncryptedFetcher.fetch(): the encryption password has not been configured.");
|
|
26
|
+
const closure = typeof connection.encryption === "function"
|
|
27
|
+
? (direction) => (headers, body) => connection.encryption({
|
|
28
|
+
headers,
|
|
29
|
+
body,
|
|
30
|
+
direction,
|
|
31
|
+
})
|
|
32
|
+
: () => () => connection.encryption;
|
|
33
|
+
return FetcherBase.request({
|
|
34
|
+
className: "EncryptedFetcher",
|
|
35
|
+
encode: route.request?.encrypted === true
|
|
36
|
+
? (input, headers) => {
|
|
37
|
+
const p = closure("encode")(headers, input);
|
|
38
|
+
return AesPkcs5.encrypt((stringify ?? JSON.stringify)(input), p.key, p.iv);
|
|
39
|
+
}
|
|
40
|
+
: (input) => input,
|
|
41
|
+
decode: route.response?.encrypted === true
|
|
42
|
+
? (input, headers) => {
|
|
43
|
+
const p = closure("decode")(headers, input);
|
|
44
|
+
const s = AesPkcs5.decrypt(input, p.key, p.iv);
|
|
45
|
+
return s.length ? JSON.parse(s) : s;
|
|
46
|
+
}
|
|
47
|
+
: (input) => input,
|
|
48
|
+
})(connection, route, input, stringify);
|
|
49
|
+
}
|
|
50
|
+
EncryptedFetcher.fetch = fetch;
|
|
51
|
+
async function propagate(connection, route, input, stringify) {
|
|
52
|
+
if ((route.request?.encrypted === true || route.response?.encrypted) &&
|
|
53
|
+
connection.encryption === undefined)
|
|
54
|
+
throw new Error("Error on EncryptedFetcher.propagate(): the encryption password has not been configured.");
|
|
55
|
+
const closure = typeof connection.encryption === "function"
|
|
56
|
+
? (direction) => (headers, body) => connection.encryption({
|
|
57
|
+
headers,
|
|
58
|
+
body,
|
|
59
|
+
direction,
|
|
60
|
+
})
|
|
61
|
+
: () => () => connection.encryption;
|
|
62
|
+
return FetcherBase.propagate({
|
|
63
|
+
className: "EncryptedFetcher",
|
|
64
|
+
encode: route.request?.encrypted === true
|
|
65
|
+
? (input, headers) => {
|
|
66
|
+
const p = closure("encode")(headers, input);
|
|
67
|
+
return AesPkcs5.encrypt((stringify ?? JSON.stringify)(input), p.key, p.iv);
|
|
68
|
+
}
|
|
69
|
+
: (input) => input,
|
|
70
|
+
decode: route.response?.encrypted === true
|
|
71
|
+
? (input, headers) => {
|
|
72
|
+
const p = closure("decode")(headers, input);
|
|
73
|
+
const s = AesPkcs5.decrypt(input, p.key, p.iv);
|
|
74
|
+
return s.length ? JSON.parse(s) : s;
|
|
75
|
+
}
|
|
76
|
+
: (input) => input,
|
|
77
|
+
})(connection, route, input, stringify);
|
|
78
|
+
}
|
|
79
|
+
EncryptedFetcher.propagate = propagate;
|
|
80
|
+
})(EncryptedFetcher || (EncryptedFetcher = {}));
|
|
81
|
+
|
|
82
|
+
export { EncryptedFetcher };
|
|
83
|
+
//# sourceMappingURL=EncryptedFetcher.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EncryptedFetcher.mjs","sources":["../src/EncryptedFetcher.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAOA;;;;;;;;;;;;;;;AAeG;AACG,IAAW;AAAjB,CAAA,UAAiB,gBAAgB,EAAA;IAuCxB,eAAe,KAAK,CACzB,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC,EAAA;AAE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B,MAAM,CAAC,GAAwB,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC;AAChE,oBAAA,MAAM,CAAC,GAAW,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;AACtD,oBAAA,OAAO,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;gBACrC;AACF,kBAAE,CAAC,KAAK,KAAK,KAAK;SACvB,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAoB;IAC5D;AAjDsB,IAAA,gBAAA,CAAA,SAAS,YAiD9B;AACH,CAAC,EAxJgB,gBAAgB,KAAhB,gBAAgB,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormDataInput.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpError.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IConnection.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEncryptionPassword.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IFetchEvent.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IFetchRoute.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IPropagation.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { HttpError } from '@typia/utils';
|
|
2
|
+
|
|
3
|
+
var NestiaSimulator;
|
|
4
|
+
(function (NestiaSimulator) {
|
|
5
|
+
NestiaSimulator.assert = (props) => {
|
|
6
|
+
return {
|
|
7
|
+
param: param(props),
|
|
8
|
+
query: query(props),
|
|
9
|
+
body: body(props),
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
const param = (props) => (name) => (task) => {
|
|
13
|
+
validate((exp) => `URL parameter "${name}" is not ${exp.expected} type.`)(props)(task);
|
|
14
|
+
};
|
|
15
|
+
const query = (props) => (task) => validate(() => "Request query parameters are not following the promised type.")(props)(task);
|
|
16
|
+
const body = (props) => (task) => validate(() => "Request body is not following the promised type.")(props)(task);
|
|
17
|
+
const validate = (message, path) => (props) => (task) => {
|
|
18
|
+
try {
|
|
19
|
+
task();
|
|
20
|
+
}
|
|
21
|
+
catch (exp) {
|
|
22
|
+
if (isTypeGuardError(exp))
|
|
23
|
+
throw new HttpError(props.method, props.host + props.path, 400, {
|
|
24
|
+
"Content-Type": props.contentType,
|
|
25
|
+
}, JSON.stringify({
|
|
26
|
+
method: exp.method,
|
|
27
|
+
path: exp.path,
|
|
28
|
+
expected: exp.expected,
|
|
29
|
+
value: exp.value,
|
|
30
|
+
message: message(exp),
|
|
31
|
+
}));
|
|
32
|
+
throw exp;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
})(NestiaSimulator || (NestiaSimulator = {}));
|
|
36
|
+
const isTypeGuardError = (input) => "string" === typeof input.method &&
|
|
37
|
+
(undefined === input.path || "string" === typeof input.path) &&
|
|
38
|
+
"string" === typeof input.expected &&
|
|
39
|
+
"string" === typeof input.name &&
|
|
40
|
+
"string" === typeof input.message &&
|
|
41
|
+
(undefined === input.stack || "string" === typeof input.stack);
|
|
42
|
+
|
|
43
|
+
export { NestiaSimulator };
|
|
44
|
+
//# sourceMappingURL=NestiaSimulator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NestiaSimulator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S,CAAC;oBACb,MAAM,EAAE,GAAG,CAAC,MAAM;AAClB,oBAAA,IAAI,EAAU,GAAG,CAAC,IAAI;oBACtB,QAAQ,EAAE,GAAG,CAAC,QAAQ;oBACtB,KAAK,EAAE,GAAG,CAAC,KAAK;AAChB,oBAAA,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC;AACtB,iBAAA,CAAC,CACH;AACH,YAAA,MAAM,GAAG;QACX;AACF,IAAA,CAAC;AACL,CAAC,EAhEgB,eAAe,KAAf,eAAe,GAAA,EAAA,CAAA,CAAA;AAkEhC,MAAM,gBAAgB,GAAG,CAAC,KAAU,KAClC,QAAQ,KAAK,OAAO,KAAK,CAAC,MAAM;AAChC,KAAC,SAAS,KAAK,KAAK,CAAC,IAAI,IAAI,QAAQ,KAAK,OAAO,KAAK,CAAC,IAAI,CAAC;AAC5D,IAAA,QAAQ,KAAK,OAAO,KAAK,CAAC,QAAQ;AAClC,IAAA,QAAQ,KAAK,OAAO,KAAK,CAAC,IAAI;AAC9B,IAAA,QAAQ,KAAK,OAAO,KAAK,CAAC,OAAO;AACjC,KAAC,SAAS,KAAK,KAAK,CAAC,KAAK,IAAI,QAAQ,KAAK,OAAO,KAAK,CAAC,KAAK,CAAC;;;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { FetcherBase } from './internal/FetcherBase.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility class for `fetch` functions used in `@nestia/sdk`.
|
|
5
|
+
*
|
|
6
|
+
* `PlainFetcher` is a utility class designed for SDK functions generated by
|
|
7
|
+
* [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote
|
|
8
|
+
* HTTP sever API. In other words, this is a collection of dedicated `fetch()`
|
|
9
|
+
* functions for `@nestia/sdk`.
|
|
10
|
+
*
|
|
11
|
+
* For reference, `PlainFetcher` class does not encrypt or decrypt the body data
|
|
12
|
+
* at all. It just delivers plain data without any post processing. If you've
|
|
13
|
+
* defined a controller method through `@EncryptedRoute` or `@EncryptedBody`
|
|
14
|
+
* decorator, then {@liink EncryptedFetcher} class would be used instead.
|
|
15
|
+
*
|
|
16
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
17
|
+
*/
|
|
18
|
+
var PlainFetcher;
|
|
19
|
+
(function (PlainFetcher) {
|
|
20
|
+
async function fetch(connection, route, input, stringify) {
|
|
21
|
+
if (route.request?.encrypted === true || route.response?.encrypted === true)
|
|
22
|
+
throw new Error("Error on PlainFetcher.fetch(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead.");
|
|
23
|
+
return FetcherBase.request({
|
|
24
|
+
className: "PlainFetcher",
|
|
25
|
+
encode: (input) => input,
|
|
26
|
+
decode: (input) => input,
|
|
27
|
+
})(connection, route, input, stringify);
|
|
28
|
+
}
|
|
29
|
+
PlainFetcher.fetch = fetch;
|
|
30
|
+
async function propagate(connection, route, input, stringify) {
|
|
31
|
+
if (route.request?.encrypted === true || route.response?.encrypted === true)
|
|
32
|
+
throw new Error("Error on PlainFetcher.propagate(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead.");
|
|
33
|
+
return FetcherBase.propagate({
|
|
34
|
+
className: "PlainFetcher",
|
|
35
|
+
encode: (input) => input,
|
|
36
|
+
decode: (input) => input,
|
|
37
|
+
})(connection, route, input, stringify);
|
|
38
|
+
}
|
|
39
|
+
PlainFetcher.propagate = propagate;
|
|
40
|
+
})(PlainFetcher || (PlainFetcher = {}));
|
|
41
|
+
|
|
42
|
+
export { PlainFetcher };
|
|
43
|
+
//# sourceMappingURL=PlainFetcher.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlainFetcher.mjs","sources":["../src/PlainFetcher.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA;;;;;;;;;;;;;;AAcG;AACG,IAAW;AAAjB,CAAA,UAAiB,YAAY,EAAA;IAuCpB,eAAe,KAAK,CACzB,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC,EAAA;AAEpC,QAAA,IAAI,KAAK,CAAC,OAAO,EAAE,SAAS,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,EAAE,SAAS,KAAK,IAAI;AACzE,YAAA,MAAM,IAAI,KAAK,CACb,4GAA4G,CAC7G;QACH,OAAO,WAAW,CAAC,OAAO,CAAC;AACzB,YAAA,SAAS,EAAE,cAAc;AACzB,YAAA,MAAM,EAAE,CAAC,KAAK,KAAK,KAAK;AACxB,YAAA,MAAM,EAAE,CAAC,KAAK,KAAK,KAAK;SACzB,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC;IACzC;AAfsB,IAAA,YAAA,CAAA,KAAK,QAe1B;IAcM,eAAe,SAAS,CAC7B,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC,EAAA;AAEpC,QAAA,IAAI,KAAK,CAAC,OAAO,EAAE,SAAS,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,EAAE,SAAS,KAAK,IAAI;AACzE,YAAA,MAAM,IAAI,KAAK,CACb,gHAAgH,CACjH;QACH,OAAO,WAAW,CAAC,SAAS,CAAC;AAC3B,YAAA,SAAS,EAAE,cAAc;AACzB,YAAA,MAAM,EAAE,CAAC,KAAK,KAAK,KAAK;AACxB,YAAA,MAAM,EAAE,CAAC,KAAK,KAAK,KAAK;SACzB,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAoB;IAC5D;AAfsB,IAAA,YAAA,CAAA,SAAS,YAe9B;AACH,CAAC,EApFgB,YAAY,KAAZ,YAAY,GAAA,EAAA,CAAA,CAAA;;;;"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
export * from "./AesPkcs5";
|
|
2
|
-
export * from "./EncryptedFetcher";
|
|
3
|
-
export * from "./FormDataInput";
|
|
4
|
-
export * from "./HttpError";
|
|
5
1
|
export * from "./IConnection";
|
|
6
2
|
export * from "./IEncryptionPassword";
|
|
7
3
|
export * from "./IFetchEvent";
|
|
8
4
|
export * from "./IFetchRoute";
|
|
9
5
|
export * from "./IPropagation";
|
|
6
|
+
export * from "./FormDataInput";
|
|
7
|
+
export * from "./HttpError";
|
|
10
8
|
export * from "./NestiaSimulator";
|
|
11
9
|
export * from "./PlainFetcher";
|
package/lib/index.js
CHANGED
|
@@ -14,15 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./AesPkcs5"), exports);
|
|
18
|
-
__exportStar(require("./EncryptedFetcher"), exports);
|
|
19
|
-
__exportStar(require("./FormDataInput"), exports);
|
|
20
|
-
__exportStar(require("./HttpError"), exports);
|
|
21
17
|
__exportStar(require("./IConnection"), exports);
|
|
22
18
|
__exportStar(require("./IEncryptionPassword"), exports);
|
|
23
19
|
__exportStar(require("./IFetchEvent"), exports);
|
|
24
20
|
__exportStar(require("./IFetchRoute"), exports);
|
|
25
21
|
__exportStar(require("./IPropagation"), exports);
|
|
22
|
+
__exportStar(require("./FormDataInput"), exports);
|
|
23
|
+
__exportStar(require("./HttpError"), exports);
|
|
26
24
|
__exportStar(require("./NestiaSimulator"), exports);
|
|
27
25
|
__exportStar(require("./PlainFetcher"), exports);
|
|
28
26
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,wDAAsC;AACtC,gDAA8B;AAC9B,gDAA8B;AAC9B,iDAA+B;AAC/B,kDAAgC;AAEhC,8CAA4B;AAC5B,oDAAkC;AAClC,iDAA+B"}
|
package/lib/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { HttpError } from '@typia/utils';
|
|
2
|
+
|
|
3
|
+
/** @internal */
|
|
4
|
+
var FetcherBase;
|
|
5
|
+
(function (FetcherBase) {
|
|
6
|
+
FetcherBase.request = (props) => async (connection, route, input, stringify) => {
|
|
7
|
+
const result = await _Propagate("fetch")(props)(connection, route, input, stringify);
|
|
8
|
+
if (result.success === false)
|
|
9
|
+
throw new HttpError(route.method, route.path, result.status, result.headers, result.data);
|
|
10
|
+
return result.data;
|
|
11
|
+
};
|
|
12
|
+
FetcherBase.propagate = (props) => async (connection, route, input, stringify) => _Propagate("propagate")(props)(connection, route, input, stringify);
|
|
13
|
+
/** @internal */
|
|
14
|
+
const _Propagate = (method) => (props) => async (connection, route, input, stringify) => {
|
|
15
|
+
//----
|
|
16
|
+
// REQUEST MESSAGE
|
|
17
|
+
//----
|
|
18
|
+
// METHOD & HEADERS
|
|
19
|
+
const headers = {
|
|
20
|
+
...(connection.headers ?? {}),
|
|
21
|
+
};
|
|
22
|
+
if (input !== undefined) {
|
|
23
|
+
if (route.request?.type === undefined)
|
|
24
|
+
throw new Error(`Error on ${props.className}.fetch(): no content-type being configured.`);
|
|
25
|
+
else if (route.request.type !== "multipart/form-data")
|
|
26
|
+
headers["Content-Type"] = route.request.type;
|
|
27
|
+
}
|
|
28
|
+
else if (input === undefined && headers["Content-Type"] !== undefined)
|
|
29
|
+
delete headers["Content-Type"];
|
|
30
|
+
// INIT REQUEST DATA
|
|
31
|
+
const init = {
|
|
32
|
+
...(connection.options ?? {}),
|
|
33
|
+
method: route.method,
|
|
34
|
+
headers: (() => {
|
|
35
|
+
const output = [];
|
|
36
|
+
for (const [key, value] of Object.entries(headers))
|
|
37
|
+
if (value === undefined)
|
|
38
|
+
continue;
|
|
39
|
+
else if (Array.isArray(value))
|
|
40
|
+
for (const v of value)
|
|
41
|
+
output.push([key, String(v)]);
|
|
42
|
+
else
|
|
43
|
+
output.push([key, String(value)]);
|
|
44
|
+
return output;
|
|
45
|
+
})(),
|
|
46
|
+
};
|
|
47
|
+
// CONSTRUCT BODY DATA
|
|
48
|
+
if (input !== undefined)
|
|
49
|
+
init.body = props.encode(
|
|
50
|
+
// BODY TRANSFORM
|
|
51
|
+
route.request?.type === "application/x-www-form-urlencoded"
|
|
52
|
+
? request_query_body(input)
|
|
53
|
+
: route.request?.type === "multipart/form-data"
|
|
54
|
+
? request_form_data_body(input)
|
|
55
|
+
: route.request?.type !== "text/plain"
|
|
56
|
+
? (stringify ?? JSON.stringify)(input)
|
|
57
|
+
: input, headers);
|
|
58
|
+
//----
|
|
59
|
+
// RESPONSE MESSAGE
|
|
60
|
+
//----
|
|
61
|
+
// URL SPECIFICATION
|
|
62
|
+
const path = connection.host[connection.host.length - 1] !== "/" &&
|
|
63
|
+
route.path[0] !== "/"
|
|
64
|
+
? `/${route.path}`
|
|
65
|
+
: route.path;
|
|
66
|
+
const url = new URL(`${connection.host}${path}`);
|
|
67
|
+
// DO FETCH
|
|
68
|
+
const event = {
|
|
69
|
+
route,
|
|
70
|
+
path,
|
|
71
|
+
status: null,
|
|
72
|
+
input,
|
|
73
|
+
output: undefined,
|
|
74
|
+
started_at: new Date(),
|
|
75
|
+
respond_at: null,
|
|
76
|
+
completed_at: null,
|
|
77
|
+
};
|
|
78
|
+
try {
|
|
79
|
+
// TRY FETCH
|
|
80
|
+
const response = await (connection.fetch ?? fetch)(url.href, init);
|
|
81
|
+
event.respond_at = new Date();
|
|
82
|
+
event.status = response.status;
|
|
83
|
+
// CONSTRUCT RESULT DATA
|
|
84
|
+
const result = {
|
|
85
|
+
success: response.status === 200 ||
|
|
86
|
+
response.status === 201 ||
|
|
87
|
+
response.status === route.status,
|
|
88
|
+
status: response.status,
|
|
89
|
+
headers: response_headers_to_object(response.headers),
|
|
90
|
+
data: undefined,
|
|
91
|
+
};
|
|
92
|
+
if (result.success === false) {
|
|
93
|
+
// WHEN FAILED
|
|
94
|
+
result.data = await response.text();
|
|
95
|
+
const type = response.headers.get("content-type");
|
|
96
|
+
if (method !== "fetch" &&
|
|
97
|
+
type &&
|
|
98
|
+
type.indexOf("application/json") !== -1)
|
|
99
|
+
try {
|
|
100
|
+
result.data = JSON.parse(result.data);
|
|
101
|
+
}
|
|
102
|
+
catch { }
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// WHEN SUCCESS
|
|
106
|
+
if (route.method === "HEAD")
|
|
107
|
+
result.data = undefined;
|
|
108
|
+
else if (route.response?.type === "application/json") {
|
|
109
|
+
const text = await response.text();
|
|
110
|
+
result.data = text.length ? JSON.parse(text) : undefined;
|
|
111
|
+
}
|
|
112
|
+
else if (route.response?.type === "application/x-www-form-urlencoded") {
|
|
113
|
+
const query = new URLSearchParams(await response.text());
|
|
114
|
+
result.data = route.parseQuery ? route.parseQuery(query) : query;
|
|
115
|
+
}
|
|
116
|
+
else
|
|
117
|
+
result.data = props.decode(await response.text(), result.headers);
|
|
118
|
+
}
|
|
119
|
+
event.output = result.data;
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
catch (exp) {
|
|
123
|
+
throw exp;
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
event.completed_at = new Date();
|
|
127
|
+
if (connection.logger)
|
|
128
|
+
try {
|
|
129
|
+
await connection.logger(event);
|
|
130
|
+
}
|
|
131
|
+
catch { }
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
})(FetcherBase || (FetcherBase = {}));
|
|
135
|
+
/** @internal */
|
|
136
|
+
const request_query_body = (input) => {
|
|
137
|
+
const q = new URLSearchParams();
|
|
138
|
+
for (const [key, value] of Object.entries(input))
|
|
139
|
+
if (value === undefined)
|
|
140
|
+
continue;
|
|
141
|
+
else if (Array.isArray(value))
|
|
142
|
+
value.forEach((elem) => q.append(key, String(elem)));
|
|
143
|
+
else
|
|
144
|
+
q.set(key, String(value));
|
|
145
|
+
return q;
|
|
146
|
+
};
|
|
147
|
+
/** @internal */
|
|
148
|
+
const request_form_data_body = (input) => {
|
|
149
|
+
const encoded = new FormData();
|
|
150
|
+
const append = (key) => (value) => {
|
|
151
|
+
if (value === undefined)
|
|
152
|
+
return;
|
|
153
|
+
else if (typeof File === "function" && value instanceof File)
|
|
154
|
+
encoded.append(key, value, value.name);
|
|
155
|
+
else
|
|
156
|
+
encoded.append(key, value);
|
|
157
|
+
};
|
|
158
|
+
for (const [key, value] of Object.entries(input))
|
|
159
|
+
if (Array.isArray(value))
|
|
160
|
+
value.map(append(key));
|
|
161
|
+
else
|
|
162
|
+
append(key)(value);
|
|
163
|
+
return encoded;
|
|
164
|
+
};
|
|
165
|
+
/** @internal */
|
|
166
|
+
const response_headers_to_object = (headers) => {
|
|
167
|
+
const output = {};
|
|
168
|
+
headers.forEach((value, key) => {
|
|
169
|
+
if (key === "set-cookie") {
|
|
170
|
+
output[key] ??= [];
|
|
171
|
+
output[key].push(...value.split(";").map((str) => str.trim()));
|
|
172
|
+
}
|
|
173
|
+
else
|
|
174
|
+
output[key] = value;
|
|
175
|
+
});
|
|
176
|
+
return output;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export { FetcherBase };
|
|
180
|
+
//# sourceMappingURL=FetcherBase.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FetcherBase.mjs","sources":["../../src/internal/FetcherBase.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAMA;AACM,IAAW;AAAjB,CAAA,UAAiB,WAAW,EAAA;AAab,IAAA,WAAA,CAAA,OAAO,GAClB,CAAC,KAAa,KACd,OACE,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC,KACjB;AACnB,QAAA,MAAM,MAAM,GAA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C,YAAA,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;AACzB,IAAA,OAAO,OAAO;AAChB,CAAC;AAED;AACA,MAAM,0BAA0B,GAAG,CACjC,OAAgB,KACqB;IACrC,MAAM,MAAM,GAAsC,EAAE;IACpD,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,KAAI;AAC7B,QAAA,IAAI,GAAG,KAAK,YAAY,EAAE;AACxB,YAAA,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE;YACjB,MAAM,CAAC,GAAG,CAAc,CAAC,IAAI,CAC5B,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC,CAC7C;QACH;;AAAO,YAAA,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK;AAC5B,IAAA,CAAC,CAAC;AACF,IAAA,OAAO,MAAM;AACf,CAAC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/fetcher",
|
|
3
|
-
"version": "11.0
|
|
3
|
+
"version": "11.2.0",
|
|
4
4
|
"description": "Fetcher library of Nestia SDK",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"types": "./lib/index.d.ts",
|
|
9
|
+
"import": "./lib/index.mjs",
|
|
9
10
|
"default": "./lib/index.js"
|
|
10
11
|
},
|
|
12
|
+
"./lib/AesPkcs5": {
|
|
13
|
+
"types": "./lib/AesPkcs5.d.ts",
|
|
14
|
+
"import": "./lib/AesPkcs5.mjs",
|
|
15
|
+
"default": "./lib/AesPkcs5.js"
|
|
16
|
+
},
|
|
17
|
+
"./lib/EncryptedFetcher": {
|
|
18
|
+
"types": "./lib/EncryptedFetcher.d.ts",
|
|
19
|
+
"import": "./lib/EncryptedFetcher.mjs",
|
|
20
|
+
"default": "./lib/EncryptedFetcher.js"
|
|
21
|
+
},
|
|
11
22
|
"./package.json": "./package.json"
|
|
12
23
|
},
|
|
13
24
|
"repository": {
|
|
@@ -26,13 +37,20 @@
|
|
|
26
37
|
},
|
|
27
38
|
"homepage": "https://nestia.io",
|
|
28
39
|
"dependencies": {
|
|
29
|
-
"@typia/interface": "
|
|
30
|
-
"@typia/utils": "
|
|
40
|
+
"@typia/interface": "12.1.0",
|
|
41
|
+
"@typia/utils": "12.1.0"
|
|
31
42
|
},
|
|
32
43
|
"devDependencies": {
|
|
44
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
45
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
46
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
33
47
|
"@types/node": "^25.3.3",
|
|
34
48
|
"rimraf": "^6.1.3",
|
|
35
|
-
"
|
|
49
|
+
"rollup": "^4.56.0",
|
|
50
|
+
"rollup-plugin-auto-external": "^2.0.0",
|
|
51
|
+
"rollup-plugin-node-externals": "^8.1.2",
|
|
52
|
+
"tinyglobby": "^0.2.16",
|
|
53
|
+
"typescript": "~6.0.3"
|
|
36
54
|
},
|
|
37
55
|
"files": [
|
|
38
56
|
"README.md",
|
|
@@ -45,7 +63,7 @@
|
|
|
45
63
|
"access": "public"
|
|
46
64
|
},
|
|
47
65
|
"scripts": {
|
|
48
|
-
"build": "rimraf lib && tsc",
|
|
66
|
+
"build": "rimraf lib && tsc && rollup -c",
|
|
49
67
|
"dev": "rimraf lib && tsc --watch"
|
|
50
68
|
},
|
|
51
69
|
"types": "lib/index.d.ts"
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
export * from "./AesPkcs5";
|
|
2
|
-
export * from "./EncryptedFetcher";
|
|
3
|
-
export * from "./FormDataInput";
|
|
4
|
-
export * from "./HttpError";
|
|
5
1
|
export * from "./IConnection";
|
|
6
2
|
export * from "./IEncryptionPassword";
|
|
7
3
|
export * from "./IFetchEvent";
|
|
8
4
|
export * from "./IFetchRoute";
|
|
9
5
|
export * from "./IPropagation";
|
|
6
|
+
export * from "./FormDataInput";
|
|
10
7
|
|
|
8
|
+
export * from "./HttpError";
|
|
11
9
|
export * from "./NestiaSimulator";
|
|
12
10
|
export * from "./PlainFetcher";
|