@nestia/fetcher 12.0.0-dev.20260521.1 → 12.0.0-dev.20260521.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/package.json +1 -1
- package/lib/AesPkcs5.js +0 -49
- package/lib/AesPkcs5.js.map +0 -1
- package/lib/EncryptedFetcher.js +0 -98
- package/lib/EncryptedFetcher.js.map +0 -1
- package/lib/FormDataInput.js +0 -3
- package/lib/FormDataInput.js.map +0 -1
- package/lib/HttpError.js +0 -6
- package/lib/HttpError.js.map +0 -1
- package/lib/IConnection.js +0 -3
- package/lib/IConnection.js.map +0 -1
- package/lib/IEncryptionPassword.js +0 -3
- package/lib/IEncryptionPassword.js.map +0 -1
- package/lib/IFetchEvent.js +0 -21
- package/lib/IFetchEvent.js.map +0 -1
- package/lib/IFetchRoute.js +0 -3
- package/lib/IFetchRoute.js.map +0 -1
- package/lib/IPropagation.js +0 -3
- package/lib/IPropagation.js.map +0 -1
- package/lib/NestiaSimulator.js +0 -44
- package/lib/NestiaSimulator.js.map +0 -1
- package/lib/PlainFetcher.js +0 -58
- package/lib/PlainFetcher.js.map +0 -1
- package/lib/index.js +0 -26
- package/lib/index.js.map +0 -1
- package/lib/internal/FetcherBase.js +0 -186
- package/lib/internal/FetcherBase.js.map +0 -1
package/package.json
CHANGED
package/lib/AesPkcs5.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AesPkcs5 = void 0;
|
|
7
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
/**
|
|
9
|
-
* Utility class for the AES-128/256 encryption.
|
|
10
|
-
*
|
|
11
|
-
* - AES-128/256
|
|
12
|
-
* - CBC mode
|
|
13
|
-
* - PKCS#5 Padding
|
|
14
|
-
* - Base64 Encoding
|
|
15
|
-
*
|
|
16
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
17
|
-
*/
|
|
18
|
-
var AesPkcs5;
|
|
19
|
-
(function (AesPkcs5) {
|
|
20
|
-
/**
|
|
21
|
-
* Encrypt data
|
|
22
|
-
*
|
|
23
|
-
* @param data Target data
|
|
24
|
-
* @param key Key value of the encryption.
|
|
25
|
-
* @param iv Initializer Vector for the encryption
|
|
26
|
-
* @returns Encrypted data
|
|
27
|
-
*/
|
|
28
|
-
function encrypt(data, key, iv) {
|
|
29
|
-
const bytes = key.length * 8;
|
|
30
|
-
const cipher = crypto_1.default.createCipheriv(`AES-${bytes}-CBC`, key, iv);
|
|
31
|
-
return cipher.update(data, "utf8", "base64") + cipher.final("base64");
|
|
32
|
-
}
|
|
33
|
-
AesPkcs5.encrypt = encrypt;
|
|
34
|
-
/**
|
|
35
|
-
* Decrypt data.
|
|
36
|
-
*
|
|
37
|
-
* @param data Target data
|
|
38
|
-
* @param key Key value of the decryption.
|
|
39
|
-
* @param iv Initializer Vector for the decryption
|
|
40
|
-
* @returns Decrypted data.
|
|
41
|
-
*/
|
|
42
|
-
function decrypt(data, key, iv) {
|
|
43
|
-
const bytes = key.length * 8;
|
|
44
|
-
const decipher = crypto_1.default.createDecipheriv(`AES-${bytes}-CBC`, key, iv);
|
|
45
|
-
return decipher.update(data, "base64", "utf8") + decipher.final("utf8");
|
|
46
|
-
}
|
|
47
|
-
AesPkcs5.decrypt = decrypt;
|
|
48
|
-
})(AesPkcs5 || (exports.AesPkcs5 = AesPkcs5 = {}));
|
|
49
|
-
//# sourceMappingURL=AesPkcs5.js.map
|
package/lib/AesPkcs5.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AesPkcs5.js","sourceRoot":"","sources":["../src/AesPkcs5.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B;;;;;;;;;GASG;AACH,IAAiB,QAAQ,CA4BxB;AA5BD,WAAiB,QAAQ;IACvB;;;;;;;OAOG;IACH,SAAgB,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU;QAC3D,MAAM,KAAK,GAAW,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,gBAAM,CAAC,cAAc,CAAC,OAAO,KAAK,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QAClE,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxE,CAAC;IAJe,SAAA,OAAO,UAItB,CAAA;IAED;;;;;;;OAOG;IACH,SAAgB,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU;QAC3D,MAAM,KAAK,GAAW,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,MAAM,QAAQ,GAAG,gBAAM,CAAC,gBAAgB,CAAC,OAAO,KAAK,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QACtE,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1E,CAAC;IAJe,SAAA,OAAO,UAItB,CAAA;AACH,CAAC,EA5BgB,QAAQ,aAAR,QAAQ,GAAR,QAAQ,QA4BxB"}
|
package/lib/EncryptedFetcher.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.EncryptedFetcher = void 0;
|
|
13
|
-
const AesPkcs5_1 = require("./AesPkcs5");
|
|
14
|
-
const FetcherBase_1 = require("./internal/FetcherBase");
|
|
15
|
-
/**
|
|
16
|
-
* Utility class for `fetch` functions used in `@nestia/sdk` with encryption.
|
|
17
|
-
*
|
|
18
|
-
* `EncryptedFetcher` is a utility class designed for SDK functions generated by
|
|
19
|
-
* [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote
|
|
20
|
-
* HTTP API encrypted by AES-PKCS algorithm. In other words, this is a
|
|
21
|
-
* collection of dedicated `fetch()` functions for `@nestia/sdk` with
|
|
22
|
-
* encryption.
|
|
23
|
-
*
|
|
24
|
-
* For reference, `EncryptedFetcher` class being used only when target
|
|
25
|
-
* controller method is encrypting body data by `@EncryptedRoute` or
|
|
26
|
-
* `@EncryptedBody` decorators. If those decorators are not used,
|
|
27
|
-
* {@link PlainFetcher} class would be used instead.
|
|
28
|
-
*
|
|
29
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
30
|
-
*/
|
|
31
|
-
var EncryptedFetcher;
|
|
32
|
-
(function (EncryptedFetcher) {
|
|
33
|
-
function fetch(connection, route, input, stringify) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
var _a, _b, _c, _d;
|
|
36
|
-
if ((((_a = route.request) === null || _a === void 0 ? void 0 : _a.encrypted) === true || ((_b = route.response) === null || _b === void 0 ? void 0 : _b.encrypted)) &&
|
|
37
|
-
connection.encryption === undefined)
|
|
38
|
-
throw new Error("Error on EncryptedFetcher.fetch(): the encryption password has not been configured.");
|
|
39
|
-
const closure = typeof connection.encryption === "function"
|
|
40
|
-
? (direction) => (headers, body) => connection.encryption({
|
|
41
|
-
headers,
|
|
42
|
-
body,
|
|
43
|
-
direction,
|
|
44
|
-
})
|
|
45
|
-
: () => () => connection.encryption;
|
|
46
|
-
return FetcherBase_1.FetcherBase.request({
|
|
47
|
-
className: "EncryptedFetcher",
|
|
48
|
-
encode: ((_c = route.request) === null || _c === void 0 ? void 0 : _c.encrypted) === true
|
|
49
|
-
? (input, headers) => {
|
|
50
|
-
const p = closure("encode")(headers, input);
|
|
51
|
-
return AesPkcs5_1.AesPkcs5.encrypt((stringify !== null && stringify !== void 0 ? stringify : JSON.stringify)(input), p.key, p.iv);
|
|
52
|
-
}
|
|
53
|
-
: (input) => input,
|
|
54
|
-
decode: ((_d = route.response) === null || _d === void 0 ? void 0 : _d.encrypted) === true
|
|
55
|
-
? (input, headers) => {
|
|
56
|
-
const p = closure("decode")(headers, input);
|
|
57
|
-
const s = AesPkcs5_1.AesPkcs5.decrypt(input, p.key, p.iv);
|
|
58
|
-
return s.length ? JSON.parse(s) : s;
|
|
59
|
-
}
|
|
60
|
-
: (input) => input,
|
|
61
|
-
})(connection, route, input, stringify);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
EncryptedFetcher.fetch = fetch;
|
|
65
|
-
function propagate(connection, route, input, stringify) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
var _a, _b, _c, _d;
|
|
68
|
-
if ((((_a = route.request) === null || _a === void 0 ? void 0 : _a.encrypted) === true || ((_b = route.response) === null || _b === void 0 ? void 0 : _b.encrypted)) &&
|
|
69
|
-
connection.encryption === undefined)
|
|
70
|
-
throw new Error("Error on EncryptedFetcher.propagate(): the encryption password has not been configured.");
|
|
71
|
-
const closure = typeof connection.encryption === "function"
|
|
72
|
-
? (direction) => (headers, body) => connection.encryption({
|
|
73
|
-
headers,
|
|
74
|
-
body,
|
|
75
|
-
direction,
|
|
76
|
-
})
|
|
77
|
-
: () => () => connection.encryption;
|
|
78
|
-
return FetcherBase_1.FetcherBase.propagate({
|
|
79
|
-
className: "EncryptedFetcher",
|
|
80
|
-
encode: ((_c = route.request) === null || _c === void 0 ? void 0 : _c.encrypted) === true
|
|
81
|
-
? (input, headers) => {
|
|
82
|
-
const p = closure("encode")(headers, input);
|
|
83
|
-
return AesPkcs5_1.AesPkcs5.encrypt((stringify !== null && stringify !== void 0 ? stringify : JSON.stringify)(input), p.key, p.iv);
|
|
84
|
-
}
|
|
85
|
-
: (input) => input,
|
|
86
|
-
decode: ((_d = route.response) === null || _d === void 0 ? void 0 : _d.encrypted) === true
|
|
87
|
-
? (input, headers) => {
|
|
88
|
-
const p = closure("decode")(headers, input);
|
|
89
|
-
const s = AesPkcs5_1.AesPkcs5.decrypt(input, p.key, p.iv);
|
|
90
|
-
return s.length ? JSON.parse(s) : s;
|
|
91
|
-
}
|
|
92
|
-
: (input) => input,
|
|
93
|
-
})(connection, route, input, stringify);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
EncryptedFetcher.propagate = propagate;
|
|
97
|
-
})(EncryptedFetcher || (exports.EncryptedFetcher = EncryptedFetcher = {}));
|
|
98
|
-
//# sourceMappingURL=EncryptedFetcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EncryptedFetcher.js","sourceRoot":"","sources":["../src/EncryptedFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsC;AAKtC,wDAAqD;AAErD;;;;;;;;;;;;;;;GAeG;AACH,IAAiB,gBAAgB,CAwJhC;AAxJD,WAAiB,gBAAgB;IAuC/B,SAAsB,KAAK,CACzB,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC;;;YAEpC,IACE,CAAC,CAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,SAAS,MAAK,IAAI,KAAI,MAAA,KAAK,CAAC,QAAQ,0CAAE,SAAS,CAAA,CAAC;gBAChE,UAAU,CAAC,UAAU,KAAK,SAA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,CACrB,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,EACpC,CAAC,CAAC,GAAG,EACL,CAAC,CAAC,EAAE,CACL,CAAC;oBACJ,CAAC;oBACH,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;gBACtB,MAAM,EACJ,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,SAAS,MAAK,IAAI;oBAChC,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;wBACjB,MAAM,CAAC,GAAwB,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;wBACjE,MAAM,CAAC,GAAW,mBAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;wBACvD,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACtC,CAAC;oBACH,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;aACvB,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAoB,CAAC;QAC7D,CAAC;KAAA;IAjDqB,iBAAA,SAAS,YAiD9B,CAAA;AACH,CAAC,EAxJgB,gBAAgB,aAAhB,gBAAgB,GAAhB,gBAAgB,QAwJhC"}
|
package/lib/FormDataInput.js
DELETED
package/lib/FormDataInput.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormDataInput.js","sourceRoot":"","sources":["../src/FormDataInput.ts"],"names":[],"mappings":""}
|
package/lib/HttpError.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpError = void 0;
|
|
4
|
-
var utils_1 = require("@typia/utils");
|
|
5
|
-
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return utils_1.HttpError; } });
|
|
6
|
-
//# sourceMappingURL=HttpError.js.map
|
package/lib/HttpError.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpError.js","sourceRoot":"","sources":["../src/HttpError.ts"],"names":[],"mappings":";;;AAAA,sCAAyC;AAAhC,kGAAA,SAAS,OAAA"}
|
package/lib/IConnection.js
DELETED
package/lib/IConnection.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IConnection.js","sourceRoot":"","sources":["../src/IConnection.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IEncryptionPassword.js","sourceRoot":"","sources":["../src/IEncryptionPassword.ts"],"names":[],"mappings":""}
|
package/lib/IFetchEvent.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// export namespace IFetchEvent {
|
|
4
|
-
// export interface IFunction {
|
|
5
|
-
// (connection: IConnection, ...args: any[]): Promise<any>;
|
|
6
|
-
// METADATA: {
|
|
7
|
-
// method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
|
|
8
|
-
// path: string;
|
|
9
|
-
// request: null | {
|
|
10
|
-
// type: string;
|
|
11
|
-
// encrypted: boolean;
|
|
12
|
-
// };
|
|
13
|
-
// response: null | {
|
|
14
|
-
// type: string;
|
|
15
|
-
// encrypted: boolean;
|
|
16
|
-
// };
|
|
17
|
-
// };
|
|
18
|
-
// status: null | number;
|
|
19
|
-
// }
|
|
20
|
-
// }
|
|
21
|
-
//# sourceMappingURL=IFetchEvent.js.map
|
package/lib/IFetchEvent.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IFetchEvent.js","sourceRoot":"","sources":["../src/IFetchEvent.ts"],"names":[],"mappings":";;AAaA,iCAAiC;AACjC,iCAAiC;AACjC,+DAA+D;AAC/D,kBAAkB;AAClB,kFAAkF;AAClF,sBAAsB;AACtB,0BAA0B;AAC1B,wBAAwB;AACxB,8BAA8B;AAC9B,WAAW;AACX,2BAA2B;AAC3B,wBAAwB;AACxB,8BAA8B;AAC9B,WAAW;AACX,SAAS;AACT,6BAA6B;AAC7B,MAAM;AACN,IAAI"}
|
package/lib/IFetchRoute.js
DELETED
package/lib/IFetchRoute.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IFetchRoute.js","sourceRoot":"","sources":["../src/IFetchRoute.ts"],"names":[],"mappings":""}
|
package/lib/IPropagation.js
DELETED
package/lib/IPropagation.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IPropagation.js","sourceRoot":"","sources":["../src/IPropagation.ts"],"names":[],"mappings":""}
|
package/lib/NestiaSimulator.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NestiaSimulator = void 0;
|
|
4
|
-
const HttpError_1 = require("./HttpError");
|
|
5
|
-
var NestiaSimulator;
|
|
6
|
-
(function (NestiaSimulator) {
|
|
7
|
-
NestiaSimulator.assert = (props) => {
|
|
8
|
-
return {
|
|
9
|
-
param: param(props),
|
|
10
|
-
query: query(props),
|
|
11
|
-
body: body(props),
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
const param = (props) => (name) => (task) => {
|
|
15
|
-
validate((exp) => `URL parameter "${name}" is not ${exp.expected} type.`)(props)(task);
|
|
16
|
-
};
|
|
17
|
-
const query = (props) => (task) => validate(() => "Request query parameters are not following the promised type.")(props)(task);
|
|
18
|
-
const body = (props) => (task) => validate(() => "Request body is not following the promised type.")(props)(task);
|
|
19
|
-
const validate = (message, path) => (props) => (task) => {
|
|
20
|
-
try {
|
|
21
|
-
task();
|
|
22
|
-
}
|
|
23
|
-
catch (exp) {
|
|
24
|
-
if (isTypeGuardError(exp))
|
|
25
|
-
throw new HttpError_1.HttpError(props.method, props.host + props.path, 400, {
|
|
26
|
-
"Content-Type": props.contentType,
|
|
27
|
-
}, JSON.stringify({
|
|
28
|
-
method: exp.method,
|
|
29
|
-
path: path !== null && path !== void 0 ? path : exp.path,
|
|
30
|
-
expected: exp.expected,
|
|
31
|
-
value: exp.value,
|
|
32
|
-
message: message(exp),
|
|
33
|
-
}));
|
|
34
|
-
throw exp;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
})(NestiaSimulator || (exports.NestiaSimulator = NestiaSimulator = {}));
|
|
38
|
-
const isTypeGuardError = (input) => "string" === typeof input.method &&
|
|
39
|
-
(undefined === input.path || "string" === typeof input.path) &&
|
|
40
|
-
"string" === typeof input.expected &&
|
|
41
|
-
"string" === typeof input.name &&
|
|
42
|
-
"string" === typeof input.message &&
|
|
43
|
-
(undefined === input.stack || "string" === typeof input.stack);
|
|
44
|
-
//# sourceMappingURL=NestiaSimulator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaSimulator.js","sourceRoot":"","sources":["../src/NestiaSimulator.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAExC,IAAiB,eAAe,CAgE/B;AAhED,WAAiB,eAAe;IAQjB,sBAAM,GAAG,CAAC,KAAa,EAAE,EAAE;QACtC,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;YACnB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;YACnB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC;SAClB,CAAC;IACJ,CAAC,CAAC;IACF,MAAM,KAAK,GACT,CAAC,KAAa,EAAE,EAAE,CAClB,CAAC,IAAY,EAAE,EAAE,CACjB,CAAI,IAAa,EAAQ,EAAE;QACzB,QAAQ,CAAC,CAAC,GAAG,E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eAAe,aAAf,eAAe,GAAf,eAAe,QAgE/B;AAED,MAAM,gBAAgB,GAAG,CAAC,KAAU,EAA2B,EAAE,CAC/D,QAAQ,KAAK,OAAO,KAAK,CAAC,MAAM;IAChC,CAAC,SAAS,KAAK,KAAK,CAAC,IAAI,IAAI,QAAQ,KAAK,OAAO,KAAK,CAAC,IAAI,CAAC;IAC5D,QAAQ,KAAK,OAAO,KAAK,CAAC,QAAQ;IAClC,QAAQ,KAAK,OAAO,KAAK,CAAC,IAAI;IAC9B,QAAQ,KAAK,OAAO,KAAK,CAAC,OAAO;IACjC,CAAC,SAAS,KAAK,KAAK,CAAC,KAAK,IAAI,QAAQ,KAAK,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC"}
|
package/lib/PlainFetcher.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.PlainFetcher = void 0;
|
|
13
|
-
const FetcherBase_1 = require("./internal/FetcherBase");
|
|
14
|
-
/**
|
|
15
|
-
* Utility class for `fetch` functions used in `@nestia/sdk`.
|
|
16
|
-
*
|
|
17
|
-
* `PlainFetcher` is a utility class designed for SDK functions generated by
|
|
18
|
-
* [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote
|
|
19
|
-
* HTTP sever API. In other words, this is a collection of dedicated `fetch()`
|
|
20
|
-
* functions for `@nestia/sdk`.
|
|
21
|
-
*
|
|
22
|
-
* For reference, `PlainFetcher` class does not encrypt or decrypt the body data
|
|
23
|
-
* at all. It just delivers plain data without any post processing. If you've
|
|
24
|
-
* defined a controller method through `@EncryptedRoute` or `@EncryptedBody`
|
|
25
|
-
* decorator, then {@liink EncryptedFetcher} class would be used instead.
|
|
26
|
-
*
|
|
27
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
28
|
-
*/
|
|
29
|
-
var PlainFetcher;
|
|
30
|
-
(function (PlainFetcher) {
|
|
31
|
-
function fetch(connection, route, input, stringify) {
|
|
32
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
var _a, _b;
|
|
34
|
-
if (((_a = route.request) === null || _a === void 0 ? void 0 : _a.encrypted) === true || ((_b = route.response) === null || _b === void 0 ? void 0 : _b.encrypted) === true)
|
|
35
|
-
throw new Error("Error on PlainFetcher.fetch(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead.");
|
|
36
|
-
return FetcherBase_1.FetcherBase.request({
|
|
37
|
-
className: "PlainFetcher",
|
|
38
|
-
encode: (input) => input,
|
|
39
|
-
decode: (input) => input,
|
|
40
|
-
})(connection, route, input, stringify);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
PlainFetcher.fetch = fetch;
|
|
44
|
-
function propagate(connection, route, input, stringify) {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
var _a, _b;
|
|
47
|
-
if (((_a = route.request) === null || _a === void 0 ? void 0 : _a.encrypted) === true || ((_b = route.response) === null || _b === void 0 ? void 0 : _b.encrypted) === true)
|
|
48
|
-
throw new Error("Error on PlainFetcher.propagate(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead.");
|
|
49
|
-
return FetcherBase_1.FetcherBase.propagate({
|
|
50
|
-
className: "PlainFetcher",
|
|
51
|
-
encode: (input) => input,
|
|
52
|
-
decode: (input) => input,
|
|
53
|
-
})(connection, route, input, stringify);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
PlainFetcher.propagate = propagate;
|
|
57
|
-
})(PlainFetcher || (exports.PlainFetcher = PlainFetcher = {}));
|
|
58
|
-
//# sourceMappingURL=PlainFetcher.js.map
|
package/lib/PlainFetcher.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlainFetcher.js","sourceRoot":"","sources":["../src/PlainFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,wDAAqD;AAErD;;;;;;;;;;;;;;GAcG;AACH,IAAiB,YAAY,CAoF5B;AApFD,WAAiB,YAAY;IAuC3B,SAAsB,KAAK,CACzB,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC;;;YAEpC,IAAI,CAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,SAAS,MAAK,IAAI,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,SAAS,MAAK,IAAI;gBACzE,MAAM,IAAI,KAAK,CACb,4GAA4G,CAC7G,CAAC;YACJ,OAAO,yBAAW,CAAC,OAAO,CAAC;gBACzB,SAAS,EAAE,cAAc;gBACzB,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;gBACxB,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;aACzB,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QAC1C,CAAC;KAAA;IAfqB,aAAA,KAAK,QAe1B,CAAA;IAcD,SAAsB,SAAS,CAC7B,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC;;;YAEpC,IAAI,CAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,SAAS,MAAK,IAAI,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,SAAS,MAAK,IAAI;gBACzE,MAAM,IAAI,KAAK,CACb,gHAAgH,CACjH,CAAC;YACJ,OAAO,yBAAW,CAAC,SAAS,CAAC;gBAC3B,SAAS,EAAE,cAAc;gBACzB,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;gBACxB,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;aACzB,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAoB,CAAC;QAC7D,CAAC;KAAA;IAfqB,aAAA,SAAS,YAe9B,CAAA;AACH,CAAC,EApFgB,YAAY,aAAZ,YAAY,GAAZ,YAAY,QAoF5B"}
|
package/lib/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./IConnection"), exports);
|
|
18
|
-
__exportStar(require("./IEncryptionPassword"), exports);
|
|
19
|
-
__exportStar(require("./IFetchEvent"), exports);
|
|
20
|
-
__exportStar(require("./IFetchRoute"), exports);
|
|
21
|
-
__exportStar(require("./IPropagation"), exports);
|
|
22
|
-
__exportStar(require("./FormDataInput"), exports);
|
|
23
|
-
__exportStar(require("./HttpError"), exports);
|
|
24
|
-
__exportStar(require("./NestiaSimulator"), exports);
|
|
25
|
-
__exportStar(require("./PlainFetcher"), exports);
|
|
26
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.FetcherBase = void 0;
|
|
13
|
-
const HttpError_1 = require("../HttpError");
|
|
14
|
-
/** @internal */
|
|
15
|
-
var FetcherBase;
|
|
16
|
-
(function (FetcherBase) {
|
|
17
|
-
FetcherBase.request = (props) => (connection, route, input, stringify) => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const result = yield _Propagate("fetch")(props)(connection, route, input, stringify);
|
|
19
|
-
if (result.success === false)
|
|
20
|
-
throw new HttpError_1.HttpError(route.method, route.path, result.status, result.headers, result.data);
|
|
21
|
-
return result.data;
|
|
22
|
-
});
|
|
23
|
-
FetcherBase.propagate = (props) => (connection, route, input, stringify) => __awaiter(this, void 0, void 0, function* () { return _Propagate("propagate")(props)(connection, route, input, stringify); });
|
|
24
|
-
/** @internal */
|
|
25
|
-
const _Propagate = (method) => (props) => (connection, route, input, stringify) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
var _a, _b, _c, _d, _e, _f;
|
|
27
|
-
var _g, _h, _j;
|
|
28
|
-
//----
|
|
29
|
-
// REQUEST MESSAGE
|
|
30
|
-
//----
|
|
31
|
-
// METHOD & HEADERS
|
|
32
|
-
const headers = Object.assign({}, ((_g = connection.headers) !== null && _g !== void 0 ? _g : {}));
|
|
33
|
-
if (input !== undefined) {
|
|
34
|
-
if (((_a = route.request) === null || _a === void 0 ? void 0 : _a.type) === undefined)
|
|
35
|
-
throw new Error(`Error on ${props.className}.fetch(): no content-type being configured.`);
|
|
36
|
-
else if (route.request.type !== "multipart/form-data")
|
|
37
|
-
headers["Content-Type"] = route.request.type;
|
|
38
|
-
}
|
|
39
|
-
else if (input === undefined && headers["Content-Type"] !== undefined)
|
|
40
|
-
delete headers["Content-Type"];
|
|
41
|
-
// INIT REQUEST DATA
|
|
42
|
-
const init = Object.assign(Object.assign({}, ((_h = connection.options) !== null && _h !== void 0 ? _h : {})), { method: route.method, headers: (() => {
|
|
43
|
-
const output = [];
|
|
44
|
-
for (const [key, value] of Object.entries(headers))
|
|
45
|
-
if (value === undefined)
|
|
46
|
-
continue;
|
|
47
|
-
else if (Array.isArray(value))
|
|
48
|
-
for (const v of value)
|
|
49
|
-
output.push([key, String(v)]);
|
|
50
|
-
else
|
|
51
|
-
output.push([key, String(value)]);
|
|
52
|
-
return output;
|
|
53
|
-
})() });
|
|
54
|
-
// CONSTRUCT BODY DATA
|
|
55
|
-
if (input !== undefined)
|
|
56
|
-
init.body = props.encode(
|
|
57
|
-
// BODY TRANSFORM
|
|
58
|
-
((_b = route.request) === null || _b === void 0 ? void 0 : _b.type) === "application/x-www-form-urlencoded"
|
|
59
|
-
? request_query_body(input)
|
|
60
|
-
: ((_c = route.request) === null || _c === void 0 ? void 0 : _c.type) === "multipart/form-data"
|
|
61
|
-
? request_form_data_body(input)
|
|
62
|
-
: ((_d = route.request) === null || _d === void 0 ? void 0 : _d.type) !== "text/plain"
|
|
63
|
-
? (stringify !== null && stringify !== void 0 ? stringify : JSON.stringify)(input)
|
|
64
|
-
: input, headers);
|
|
65
|
-
//----
|
|
66
|
-
// RESPONSE MESSAGE
|
|
67
|
-
//----
|
|
68
|
-
// URL SPECIFICATION
|
|
69
|
-
const path = connection.host[connection.host.length - 1] !== "/" &&
|
|
70
|
-
route.path[0] !== "/"
|
|
71
|
-
? `/${route.path}`
|
|
72
|
-
: route.path;
|
|
73
|
-
const url = new URL(`${connection.host}${path}`);
|
|
74
|
-
// DO FETCH
|
|
75
|
-
const event = {
|
|
76
|
-
route,
|
|
77
|
-
path,
|
|
78
|
-
status: null,
|
|
79
|
-
input,
|
|
80
|
-
output: undefined,
|
|
81
|
-
started_at: new Date(),
|
|
82
|
-
respond_at: null,
|
|
83
|
-
completed_at: null,
|
|
84
|
-
};
|
|
85
|
-
try {
|
|
86
|
-
// TRY FETCH
|
|
87
|
-
const response = yield ((_j = connection.fetch) !== null && _j !== void 0 ? _j : fetch)(url.href, init);
|
|
88
|
-
event.respond_at = new Date();
|
|
89
|
-
event.status = response.status;
|
|
90
|
-
// CONSTRUCT RESULT DATA
|
|
91
|
-
const result = {
|
|
92
|
-
success: response.status === 200 ||
|
|
93
|
-
response.status === 201 ||
|
|
94
|
-
response.status === route.status,
|
|
95
|
-
status: response.status,
|
|
96
|
-
headers: response_headers_to_object(response.headers),
|
|
97
|
-
data: undefined,
|
|
98
|
-
};
|
|
99
|
-
if (result.success === false) {
|
|
100
|
-
// WHEN FAILED
|
|
101
|
-
result.data = yield response.text();
|
|
102
|
-
const type = response.headers.get("content-type");
|
|
103
|
-
if (method !== "fetch" &&
|
|
104
|
-
type &&
|
|
105
|
-
type.indexOf("application/json") !== -1)
|
|
106
|
-
try {
|
|
107
|
-
result.data = JSON.parse(result.data);
|
|
108
|
-
}
|
|
109
|
-
catch (_k) { }
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
// WHEN SUCCESS
|
|
113
|
-
if (route.method === "HEAD")
|
|
114
|
-
result.data = undefined;
|
|
115
|
-
else if (((_e = route.response) === null || _e === void 0 ? void 0 : _e.type) === "application/json") {
|
|
116
|
-
const text = yield response.text();
|
|
117
|
-
result.data = text.length ? JSON.parse(text) : undefined;
|
|
118
|
-
}
|
|
119
|
-
else if (((_f = route.response) === null || _f === void 0 ? void 0 : _f.type) === "application/x-www-form-urlencoded") {
|
|
120
|
-
const query = new URLSearchParams(yield response.text());
|
|
121
|
-
result.data = route.parseQuery ? route.parseQuery(query) : query;
|
|
122
|
-
}
|
|
123
|
-
else
|
|
124
|
-
result.data = props.decode(yield response.text(), result.headers);
|
|
125
|
-
}
|
|
126
|
-
event.output = result.data;
|
|
127
|
-
return result;
|
|
128
|
-
}
|
|
129
|
-
catch (exp) {
|
|
130
|
-
throw exp;
|
|
131
|
-
}
|
|
132
|
-
finally {
|
|
133
|
-
event.completed_at = new Date();
|
|
134
|
-
if (connection.logger)
|
|
135
|
-
try {
|
|
136
|
-
yield connection.logger(event);
|
|
137
|
-
}
|
|
138
|
-
catch (_l) { }
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
})(FetcherBase || (exports.FetcherBase = FetcherBase = {}));
|
|
142
|
-
/** @internal */
|
|
143
|
-
const request_query_body = (input) => {
|
|
144
|
-
const q = new URLSearchParams();
|
|
145
|
-
for (const [key, value] of Object.entries(input))
|
|
146
|
-
if (value === undefined)
|
|
147
|
-
continue;
|
|
148
|
-
else if (Array.isArray(value))
|
|
149
|
-
value.forEach((elem) => q.append(key, String(elem)));
|
|
150
|
-
else
|
|
151
|
-
q.set(key, String(value));
|
|
152
|
-
return q;
|
|
153
|
-
};
|
|
154
|
-
/** @internal */
|
|
155
|
-
const request_form_data_body = (input) => {
|
|
156
|
-
const encoded = new FormData();
|
|
157
|
-
const append = (key) => (value) => {
|
|
158
|
-
if (value === undefined)
|
|
159
|
-
return;
|
|
160
|
-
else if (typeof File === "function" && value instanceof File)
|
|
161
|
-
encoded.append(key, value, value.name);
|
|
162
|
-
else
|
|
163
|
-
encoded.append(key, value);
|
|
164
|
-
};
|
|
165
|
-
for (const [key, value] of Object.entries(input))
|
|
166
|
-
if (Array.isArray(value))
|
|
167
|
-
value.map(append(key));
|
|
168
|
-
else
|
|
169
|
-
append(key)(value);
|
|
170
|
-
return encoded;
|
|
171
|
-
};
|
|
172
|
-
/** @internal */
|
|
173
|
-
const response_headers_to_object = (headers) => {
|
|
174
|
-
const output = {};
|
|
175
|
-
headers.forEach((value, key) => {
|
|
176
|
-
var _a;
|
|
177
|
-
if (key === "set-cookie") {
|
|
178
|
-
(_a = output[key]) !== null && _a !== void 0 ? _a : (output[key] = []);
|
|
179
|
-
output[key].push(...value.split(";").map((str) => str.trim()));
|
|
180
|
-
}
|
|
181
|
-
else
|
|
182
|
-
output[key] = value;
|
|
183
|
-
});
|
|
184
|
-
return output;
|
|
185
|
-
};
|
|
186
|
-
//# sourceMappingURL=FetcherBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FetcherBase.js","sourceRoot":"","sources":["../../src/internal/FetcherBase.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAyC;AAMzC,gBAAgB;AAChB,IAAiB,WAAW,CAyL3B;AAzLD,WAAiB,WAAW;IAab,mBAAO,GAClB,CAAC,KAAa,EAAE,EAAE,CAClB,CACE,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC,EACnB,EAAE;QACnB,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAC7C,UAAU,EACV,KAAK,EACL,KAAK,EACL,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