@nestia/fetcher 1.6.7 → 2.0.0-dev.20230830
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.js.map +1 -1
- package/lib/EncryptedFetcher.d.ts +43 -0
- package/lib/EncryptedFetcher.js +97 -0
- package/lib/EncryptedFetcher.js.map +1 -0
- package/lib/IConnection.d.ts +8 -4
- package/lib/IEncryptionPassword.d.ts +7 -6
- package/lib/PlainFetcher.d.ts +44 -0
- package/lib/PlainFetcher.js +75 -0
- package/lib/PlainFetcher.js.map +1 -0
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -3
- package/lib/index.js.map +1 -1
- package/lib/internal/FetcherBase.d.ts +11 -0
- package/lib/{Fetcher.js → internal/FetcherBase.js} +79 -105
- package/lib/internal/FetcherBase.js.map +1 -0
- package/lib/internal/IFetchRoute.d.ts +28 -0
- package/lib/internal/IFetchRoute.js +3 -0
- package/lib/internal/IFetchRoute.js.map +1 -0
- package/package.json +1 -1
- package/src/AesPkcs5.ts +0 -1
- package/src/EncryptedFetcher.ts +115 -0
- package/src/IConnection.ts +9 -5
- package/src/IEncryptionPassword.ts +8 -6
- package/src/PlainFetcher.ts +82 -0
- package/src/index.ts +0 -4
- package/src/internal/FetcherBase.ts +156 -0
- package/src/internal/IFetchRoute.ts +36 -0
- package/lib/Fetcher.d.ts +0 -73
- package/lib/Fetcher.js.map +0 -1
- package/src/Fetcher.ts +0 -262
package/lib/AesPkcs5.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AesPkcs5.js","sourceRoot":"","sources":["../src/AesPkcs5.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA4B;AAE5B;;;;;;;;;GASG;AACH,IAAiB,QAAQ,
|
|
1
|
+
{"version":3,"file":"AesPkcs5.js","sourceRoot":"","sources":["../src/AesPkcs5.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA4B;AAE5B;;;;;;;;;GASG;AACH,IAAiB,QAAQ,CAqCxB;AArCD,WAAiB,QAAQ;IACrB;;;;;;;OAOG;IACH,SAAgB,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU;QACzD,IAAM,KAAK,GAAW,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAM,MAAM,GAAkB,gBAAM,CAAC,cAAc,CAC/C,cAAO,KAAK,SAAM,EAClB,GAAG,EACH,EAAE,CACL,CAAC;QACF,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1E,CAAC;IARe,gBAAO,UAQtB,CAAA;IAED;;;;;;;OAOG;IACH,SAAgB,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU;QACzD,IAAM,KAAK,GAAW,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAM,QAAQ,GAAoB,gBAAM,CAAC,gBAAgB,CACrD,cAAO,KAAK,SAAM,EAClB,GAAG,EACH,EAAE,CACL,CAAC;QAEF,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;IATe,gBAAO,UAStB,CAAA;AACL,CAAC,EArCgB,QAAQ,wBAAR,QAAQ,QAqCxB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IConnection } from "./IConnection";
|
|
2
|
+
import { Primitive } from "./Primitive";
|
|
3
|
+
import { IFetchRoute } from "./internal/IFetchRoute";
|
|
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 collection of
|
|
10
|
+
* dedicated `fetch()` functions for `@nestia/sdk` with encryption.
|
|
11
|
+
*
|
|
12
|
+
* For reference, `EncryptedFetcher` class being used only when target controller
|
|
13
|
+
* method is encrypting body data by `@EncryptedRoute` or `@EncryptedBody` decorators.
|
|
14
|
+
* If those decorators are not used, {@link PlainFetcher} class would be used instead.
|
|
15
|
+
*
|
|
16
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
17
|
+
*/
|
|
18
|
+
export declare namespace EncryptedFetcher {
|
|
19
|
+
/**
|
|
20
|
+
* Fetch function only for `HEAD` method.
|
|
21
|
+
*
|
|
22
|
+
* @param connection Connection information for the remote HTTP server
|
|
23
|
+
* @param route Route information about the target API
|
|
24
|
+
* @return Nothing because of `HEAD` method
|
|
25
|
+
*/
|
|
26
|
+
function fetch(connection: IConnection, route: IFetchRoute<"HEAD">): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Fetch function only for `GET` method.
|
|
29
|
+
*
|
|
30
|
+
* @param connection Connection information for the remote HTTP server
|
|
31
|
+
* @param route Route information about the target API
|
|
32
|
+
* @return Response body data from the remote API
|
|
33
|
+
*/
|
|
34
|
+
function fetch<Output>(connection: IConnection, route: IFetchRoute<"GET">): Promise<Primitive<Output>>;
|
|
35
|
+
/**
|
|
36
|
+
* Fetch function for the `POST`, `PUT`, `PATCH` and `DELETE` methods.
|
|
37
|
+
*
|
|
38
|
+
* @param connection Connection information for the remote HTTP server
|
|
39
|
+
* @param route Route information about the target API
|
|
40
|
+
* @return Response body data from the remote API
|
|
41
|
+
*/
|
|
42
|
+
function fetch<Input, Output>(connection: IConnection, route: IFetchRoute<"POST" | "PUT" | "PATCH" | "DELETE">, input?: Input, stringify?: (input: Input) => string): Promise<Primitive<Output>>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.EncryptedFetcher = void 0;
|
|
40
|
+
var AesPkcs5_1 = require("./AesPkcs5");
|
|
41
|
+
var FetcherBase_1 = require("./internal/FetcherBase");
|
|
42
|
+
/**
|
|
43
|
+
* Utility class for `fetch` functions used in `@nestia/sdk` with encryption.
|
|
44
|
+
*
|
|
45
|
+
* `EncryptedFetcher` is a utility class designed for SDK functions generated by
|
|
46
|
+
* [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote
|
|
47
|
+
* HTTP API encrypted by AES-PKCS algorithm. In other words, this is a collection of
|
|
48
|
+
* dedicated `fetch()` functions for `@nestia/sdk` with encryption.
|
|
49
|
+
*
|
|
50
|
+
* For reference, `EncryptedFetcher` class being used only when target controller
|
|
51
|
+
* method is encrypting body data by `@EncryptedRoute` or `@EncryptedBody` decorators.
|
|
52
|
+
* If those decorators are not used, {@link PlainFetcher} class would be used instead.
|
|
53
|
+
*
|
|
54
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
55
|
+
*/
|
|
56
|
+
var EncryptedFetcher;
|
|
57
|
+
(function (EncryptedFetcher) {
|
|
58
|
+
function fetch(connection, route, input, stringify) {
|
|
59
|
+
var _a, _b, _c, _d;
|
|
60
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
+
var closure;
|
|
62
|
+
return __generator(this, function (_e) {
|
|
63
|
+
if ((((_a = route.request) === null || _a === void 0 ? void 0 : _a.encrypted) === true || ((_b = route.response) === null || _b === void 0 ? void 0 : _b.encrypted)) &&
|
|
64
|
+
connection.encryption === undefined)
|
|
65
|
+
throw new Error("Error on EncryptedFetcher.fetch(): the encryption password has not been configured.");
|
|
66
|
+
closure = typeof connection.encryption === "function"
|
|
67
|
+
? function (direction) {
|
|
68
|
+
return function (headers, body) {
|
|
69
|
+
return connection.encryption({
|
|
70
|
+
headers: headers,
|
|
71
|
+
body: body,
|
|
72
|
+
direction: direction,
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
: function () { return function () { return connection.encryption; }; };
|
|
77
|
+
return [2 /*return*/, FetcherBase_1.FetcherBase.fetch({
|
|
78
|
+
className: "EncryptedFetcher",
|
|
79
|
+
encode: ((_c = route.request) === null || _c === void 0 ? void 0 : _c.encrypted) === true
|
|
80
|
+
? function (input, headers) {
|
|
81
|
+
var p = closure("encode")(headers, input);
|
|
82
|
+
return AesPkcs5_1.AesPkcs5.encrypt(input, p.key, p.iv);
|
|
83
|
+
}
|
|
84
|
+
: function (input) { return input; },
|
|
85
|
+
decode: ((_d = route.response) === null || _d === void 0 ? void 0 : _d.encrypted) === true
|
|
86
|
+
? function (input, headers) {
|
|
87
|
+
var p = closure("decode")(headers, input);
|
|
88
|
+
return JSON.parse(AesPkcs5_1.AesPkcs5.decrypt(input, p.key, p.iv));
|
|
89
|
+
}
|
|
90
|
+
: function (input) { return input; },
|
|
91
|
+
})(connection, route, input, stringify)];
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
EncryptedFetcher.fetch = fetch;
|
|
96
|
+
})(EncryptedFetcher || (exports.EncryptedFetcher = EncryptedFetcher = {}));
|
|
97
|
+
//# sourceMappingURL=EncryptedFetcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EncryptedFetcher.js","sourceRoot":"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ACH,CAAC,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,EAAL,CAAK;wBAC1B,MAAM,EACF,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,SAAS,MAAK,IAAI;4BAC9B,CAAC,CAAC,UAAC,KAAK,EAAE,OAAO;gCACX,IAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gCAC5C,OAAO,IAAI,CAAC,KAAK,CACb,mBAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CACvC,CAAC;4BACN,CAAC;4BACH,CAAC,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,EAAL,CAAK;qBAC7B,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,EAAC;;;KAC3C;IArDqB,sBAAK,QAqD1B,CAAA;AACL,CAAC,EA7FgB,gBAAgB,gCAAhB,gBAAgB,QA6FhC"}
|
package/lib/IConnection.d.ts
CHANGED
|
@@ -25,10 +25,6 @@ export interface IConnection<Headers extends object = {}> {
|
|
|
25
25
|
* Header values delivered to the remote HTTP server.
|
|
26
26
|
*/
|
|
27
27
|
headers?: Record<string, IConnection.HeaderValue> & IConnection.Headerify<Headers>;
|
|
28
|
-
/**
|
|
29
|
-
* Encryption password of its closure function.
|
|
30
|
-
*/
|
|
31
|
-
encryption?: IEncryptionPassword | IEncryptionPassword.Closure;
|
|
32
28
|
/**
|
|
33
29
|
* Use simulation mode.
|
|
34
30
|
*
|
|
@@ -49,6 +45,14 @@ export interface IConnection<Headers extends object = {}> {
|
|
|
49
45
|
* Additional options for the `fetch` function.
|
|
50
46
|
*/
|
|
51
47
|
options?: IConnection.IOptions;
|
|
48
|
+
/**
|
|
49
|
+
* Encryption password of its closure function.
|
|
50
|
+
*
|
|
51
|
+
* Define it only when target backend server is encrypting body data through
|
|
52
|
+
* `@EncryptedRoute` or `@EncryptedBody` decorators of `@nestia/core` for
|
|
53
|
+
* security reason.
|
|
54
|
+
*/
|
|
55
|
+
encryption?: IEncryptionPassword | IEncryptionPassword.Closure;
|
|
52
56
|
}
|
|
53
57
|
export declare namespace IConnection {
|
|
54
58
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IConnection } from "./IConnection";
|
|
1
2
|
/**
|
|
2
3
|
* Encryption password.
|
|
3
4
|
*
|
|
@@ -30,17 +31,17 @@ export declare namespace IEncryptionPassword {
|
|
|
30
31
|
/**
|
|
31
32
|
* Encryption password getter.
|
|
32
33
|
*
|
|
33
|
-
* @param
|
|
34
|
-
* @param encoded Be encoded or to be decoded
|
|
34
|
+
* @param props Properties for predication
|
|
35
35
|
* @returns Encryption password
|
|
36
36
|
*/
|
|
37
|
-
(
|
|
37
|
+
(props: IProps): IEncryptionPassword;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Properties for the closure.
|
|
41
41
|
*/
|
|
42
|
-
interface
|
|
43
|
-
headers: Record<string,
|
|
42
|
+
interface IProps {
|
|
43
|
+
headers: Record<string, IConnection.HeaderValue | undefined>;
|
|
44
44
|
body: string;
|
|
45
|
+
direction: "encode" | "decode";
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { IConnection } from "./IConnection";
|
|
2
|
+
import { Primitive } from "./Primitive";
|
|
3
|
+
import { IFetchRoute } from "./internal/IFetchRoute";
|
|
4
|
+
/**
|
|
5
|
+
* Utility class for `fetch` functions used in `@nestia/sdk`.
|
|
6
|
+
*
|
|
7
|
+
* `PlainFetcher` 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 sever API. In other words, this is a collection of dedicated `fetch()`
|
|
10
|
+
* functions for `@nestia/sdk`.
|
|
11
|
+
*
|
|
12
|
+
* For reference, `PlainFetcher` class does not encrypt or decrypt the body data
|
|
13
|
+
* at all. It just delivers plain data without any post processing. If you've
|
|
14
|
+
* defined a controller method through `@EncryptedRoute` or `@EncryptedBody`
|
|
15
|
+
* decorator, then {@liink EncryptedFetcher} class would be used instead.
|
|
16
|
+
*
|
|
17
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
18
|
+
*/
|
|
19
|
+
export declare namespace PlainFetcher {
|
|
20
|
+
/**
|
|
21
|
+
* Fetch function only for `HEAD` method.
|
|
22
|
+
*
|
|
23
|
+
* @param connection Connection information for the remote HTTP server
|
|
24
|
+
* @param route Route information about the target API
|
|
25
|
+
* @return Nothing because of `HEAD` method
|
|
26
|
+
*/
|
|
27
|
+
function fetch(connection: IConnection, route: IFetchRoute<"HEAD">): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Fetch function only for `GET` method.
|
|
30
|
+
*
|
|
31
|
+
* @param connection Connection information for the remote HTTP server
|
|
32
|
+
* @param route Route information about the target API
|
|
33
|
+
* @return Response body data from the remote API
|
|
34
|
+
*/
|
|
35
|
+
function fetch<Output>(connection: IConnection, route: IFetchRoute<"GET">): Promise<Primitive<Output>>;
|
|
36
|
+
/**
|
|
37
|
+
* Fetch function for the `POST`, `PUT`, `PATCH` and `DELETE` methods.
|
|
38
|
+
*
|
|
39
|
+
* @param connection Connection information for the remote HTTP server
|
|
40
|
+
* @param route Route information about the target API
|
|
41
|
+
* @return Response body data from the remote API
|
|
42
|
+
*/
|
|
43
|
+
function fetch<Input, Output>(connection: IConnection, route: IFetchRoute<"POST" | "PUT" | "PATCH" | "DELETE">, input?: Input, stringify?: (input: Input) => string): Promise<Primitive<Output>>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.PlainFetcher = void 0;
|
|
40
|
+
var FetcherBase_1 = require("./internal/FetcherBase");
|
|
41
|
+
/**
|
|
42
|
+
* Utility class for `fetch` functions used in `@nestia/sdk`.
|
|
43
|
+
*
|
|
44
|
+
* `PlainFetcher` is a utility class designed for SDK functions generated by
|
|
45
|
+
* [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote
|
|
46
|
+
* HTTP sever API. In other words, this is a collection of dedicated `fetch()`
|
|
47
|
+
* functions for `@nestia/sdk`.
|
|
48
|
+
*
|
|
49
|
+
* For reference, `PlainFetcher` class does not encrypt or decrypt the body data
|
|
50
|
+
* at all. It just delivers plain data without any post processing. If you've
|
|
51
|
+
* defined a controller method through `@EncryptedRoute` or `@EncryptedBody`
|
|
52
|
+
* decorator, then {@liink EncryptedFetcher} class would be used instead.
|
|
53
|
+
*
|
|
54
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
55
|
+
*/
|
|
56
|
+
var PlainFetcher;
|
|
57
|
+
(function (PlainFetcher) {
|
|
58
|
+
function fetch(connection, route, input, stringify) {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
+
return __generator(this, function (_c) {
|
|
62
|
+
if (((_a = route.request) === null || _a === void 0 ? void 0 : _a.encrypted) === true ||
|
|
63
|
+
((_b = route.response) === null || _b === void 0 ? void 0 : _b.encrypted) === true)
|
|
64
|
+
throw new Error("Error on PlainFetcher.fetch(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead.");
|
|
65
|
+
return [2 /*return*/, FetcherBase_1.FetcherBase.fetch({
|
|
66
|
+
className: "PlainFetcher",
|
|
67
|
+
encode: function (input) { return input; },
|
|
68
|
+
decode: function (input) { return input; },
|
|
69
|
+
})(connection, route, input, stringify)];
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
PlainFetcher.fetch = fetch;
|
|
74
|
+
})(PlainFetcher || (exports.PlainFetcher = PlainFetcher = {}));
|
|
75
|
+
//# sourceMappingURL=PlainFetcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlainFetcher.js","sourceRoot":"","sources":["../src/PlainFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,sDAAqD;AAErD;;;;;;;;;;;;;;GAcG;AACH,IAAiB,YAAY,CA4D5B;AA5DD,WAAiB,YAAY;IAuCzB,SAAsB,KAAK,CACvB,UAAuB,EACvB,KAEC,EACD,KAAa,EACb,SAAoC;;;;gBAEpC,IACI,CAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,SAAS,MAAK,IAAI;oBACjC,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,SAAS,MAAK,IAAI;oBAElC,MAAM,IAAI,KAAK,CACX,4GAA4G,CAC/G,CAAC;gBACN,sBAAO,yBAAW,CAAC,KAAK,CAAC;wBACrB,SAAS,EAAE,cAAc;wBACzB,MAAM,EAAE,UAAC,KAAK,IAAK,OAAA,KAAK,EAAL,CAAK;wBACxB,MAAM,EAAE,UAAC,KAAK,IAAK,OAAA,KAAK,EAAL,CAAK;qBAC3B,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,EAAC;;;KAC3C;IApBqB,kBAAK,QAoB1B,CAAA;AACL,CAAC,EA5DgB,YAAY,4BAAZ,YAAY,QA4D5B"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -15,9 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./IConnection"), exports);
|
|
18
|
-
__exportStar(require("./IEncryptionPassword"), exports);
|
|
19
18
|
__exportStar(require("./Primitive"), exports);
|
|
20
|
-
__exportStar(require("./AesPkcs5"), exports);
|
|
21
|
-
__exportStar(require("./Fetcher"), exports);
|
|
22
19
|
__exportStar(require("./HttpError"), exports);
|
|
23
20
|
//# 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,gDAA8B;AAC9B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,8CAA4B;AAC5B,8CAA4B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IConnection } from "../IConnection";
|
|
2
|
+
import { Primitive } from "../Primitive";
|
|
3
|
+
import { IFetchRoute } from "./IFetchRoute";
|
|
4
|
+
export declare namespace FetcherBase {
|
|
5
|
+
interface IProps {
|
|
6
|
+
className: string;
|
|
7
|
+
encode: (input: string, headers: Record<string, IConnection.HeaderValue | undefined>) => string;
|
|
8
|
+
decode: (input: string, headers: Record<string, IConnection.HeaderValue | undefined>) => any;
|
|
9
|
+
}
|
|
10
|
+
const fetch: (props: IProps) => <Input, Output>(connection: IConnection, route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">, input?: Input | undefined, stringify?: ((input: Input) => string) | undefined) => Promise<Primitive<Output>>;
|
|
11
|
+
}
|
|
@@ -73,48 +73,40 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
73
73
|
}
|
|
74
74
|
return ar;
|
|
75
75
|
};
|
|
76
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
77
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
78
|
+
if (ar || !(i in from)) {
|
|
79
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
80
|
+
ar[i] = from[i];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
84
|
+
};
|
|
76
85
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
77
86
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
78
87
|
};
|
|
79
88
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
80
|
-
exports.
|
|
89
|
+
exports.FetcherBase = void 0;
|
|
81
90
|
var import2_1 = __importDefault(require("import2"));
|
|
82
|
-
var
|
|
83
|
-
var HttpError_1 = require("
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* generated SDK libraries, you don't need to handle this class directly. It may only be
|
|
94
|
-
* appeared in the source codes of the [**Nestia**](https://github.com/samchon/nestia)
|
|
95
|
-
* generated SDK libraries.
|
|
96
|
-
*
|
|
97
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
98
|
-
*/
|
|
99
|
-
var Fetcher = /** @class */ (function () {
|
|
100
|
-
function Fetcher() {
|
|
101
|
-
}
|
|
102
|
-
Fetcher.fetch = function (connection, encrypted, method, path, input, stringify) {
|
|
103
|
-
var _a, _b, _c, _d, _e;
|
|
104
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
105
|
-
var headers, init, url, response, text, content, ret;
|
|
106
|
-
return __generator(this, function (_f) {
|
|
107
|
-
switch (_f.label) {
|
|
91
|
+
var Singleton_1 = require("./Singleton");
|
|
92
|
+
var HttpError_1 = require("../HttpError");
|
|
93
|
+
var FetcherBase;
|
|
94
|
+
(function (FetcherBase) {
|
|
95
|
+
var _this = this;
|
|
96
|
+
FetcherBase.fetch = function (props) {
|
|
97
|
+
return function (connection, route, input, stringify) { return __awaiter(_this, void 0, void 0, function () {
|
|
98
|
+
var headers, init, path, url, response, _a, _b, _c, _d;
|
|
99
|
+
var _e, _f, _g, _h, _j, _k, _l, _m;
|
|
100
|
+
return __generator(this, function (_o) {
|
|
101
|
+
switch (_o.label) {
|
|
108
102
|
case 0:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
: "application/json");
|
|
117
|
-
init = __assign(__assign({}, ((_c = connection.options) !== null && _c !== void 0 ? _c : {})), { method: method, headers: (function () {
|
|
103
|
+
headers = __assign({}, ((_e = connection.headers) !== null && _e !== void 0 ? _e : {}));
|
|
104
|
+
if (input !== undefined) {
|
|
105
|
+
if (((_f = route.request) === null || _f === void 0 ? void 0 : _f.type) === undefined)
|
|
106
|
+
throw new Error("Error on ".concat(props.className, ".fetch(): no content-type being configured."));
|
|
107
|
+
headers["Content-Type"] = route.request.type;
|
|
108
|
+
}
|
|
109
|
+
init = __assign(__assign({}, ((_g = connection.options) !== null && _g !== void 0 ? _g : {})), { method: route.method, headers: (function () {
|
|
118
110
|
var e_1, _a, e_2, _b;
|
|
119
111
|
var output = [];
|
|
120
112
|
try {
|
|
@@ -148,80 +140,53 @@ var Fetcher = /** @class */ (function () {
|
|
|
148
140
|
finally { if (e_1) throw e_1.error; }
|
|
149
141
|
}
|
|
150
142
|
return output;
|
|
151
|
-
})()
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
var json = encrypted.request === true ||
|
|
156
|
-
headers["Content-Type"] !== "text/plain"
|
|
143
|
+
})(), body: input !== undefined
|
|
144
|
+
? props.encode(
|
|
145
|
+
// BODY TRANSFORM
|
|
146
|
+
((_h = route.request) === null || _h === void 0 ? void 0 : _h.type) !== "text/plain"
|
|
157
147
|
? (stringify !== null && stringify !== void 0 ? stringify : JSON.stringify)(input)
|
|
158
|
-
: String(input)
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
body: json,
|
|
165
|
-
}, true)
|
|
166
|
-
: connection.encryption;
|
|
167
|
-
return AesPkcs5_1.AesPkcs5.encrypt(json, password.key, password.iv);
|
|
168
|
-
})();
|
|
169
|
-
//----
|
|
170
|
-
// RESPONSE MESSAGE
|
|
171
|
-
//----
|
|
172
|
-
// URL SPECIFICATION
|
|
173
|
-
if (connection.host[connection.host.length - 1] !== "/" &&
|
|
174
|
-
path[0] !== "/")
|
|
175
|
-
path = "/" + path;
|
|
148
|
+
: String(input), headers)
|
|
149
|
+
: undefined });
|
|
150
|
+
path = connection.host[connection.host.length - 1] !== "/" &&
|
|
151
|
+
route.path[0] !== "/"
|
|
152
|
+
? "/".concat(route.path)
|
|
153
|
+
: route.path;
|
|
176
154
|
url = new URL("".concat(connection.host).concat(path));
|
|
177
155
|
return [4 /*yield*/, polyfill.get()];
|
|
178
|
-
case 1: return [4 /*yield*/, (
|
|
156
|
+
case 1: return [4 /*yield*/, (_o.sent())(url.href, init)];
|
|
179
157
|
case 2:
|
|
180
|
-
response =
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if ((encrypted.status !== undefined &&
|
|
186
|
-
response.status !== encrypted.status) ||
|
|
187
|
-
(encrypted.status === undefined &&
|
|
158
|
+
response = _o.sent();
|
|
159
|
+
if (!((route.status !== undefined &&
|
|
160
|
+
route.status !== null &&
|
|
161
|
+
response.status !== route.status) ||
|
|
162
|
+
((route.status === undefined || route.status === null) &&
|
|
188
163
|
response.status !== 200 &&
|
|
189
|
-
response.status !== 201))
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
?
|
|
199
|
-
: (
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
headers: headers_to_object(response.headers),
|
|
203
|
-
body: text,
|
|
204
|
-
}, false)
|
|
205
|
-
: connection.encryption;
|
|
206
|
-
return AesPkcs5_1.AesPkcs5.decrypt(text, password.key, password.iv);
|
|
207
|
-
})();
|
|
208
|
-
ret = content;
|
|
209
|
-
try {
|
|
210
|
-
// PARSE RESPONSE BODY
|
|
211
|
-
if (encrypted.response ||
|
|
212
|
-
((_e = response.headers.get("Content-Type")) !== null && _e !== void 0 ? _e : "").indexOf("application/json") !== -1)
|
|
213
|
-
ret = content.length ? JSON.parse(content) : undefined;
|
|
214
|
-
}
|
|
215
|
-
catch (_g) { }
|
|
164
|
+
response.status !== 201))) return [3 /*break*/, 4];
|
|
165
|
+
_a = HttpError_1.HttpError.bind;
|
|
166
|
+
_b = [void 0, route.method,
|
|
167
|
+
path,
|
|
168
|
+
response.status];
|
|
169
|
+
return [4 /*yield*/, response.text()];
|
|
170
|
+
case 3: throw new (_a.apply(HttpError_1.HttpError, _b.concat([_o.sent()])))();
|
|
171
|
+
case 4:
|
|
172
|
+
if (((_j = route.response) === null || _j === void 0 ? void 0 : _j.type) &&
|
|
173
|
+
((_l = ((_k = response.headers.get("content-type")) !== null && _k !== void 0 ? _k : "")) === null || _l === void 0 ? void 0 : _l.indexOf(route.response.type)) === -1)
|
|
174
|
+
throw new Error("Error on ".concat(props.className, ".fetch(): response type mismatched - expected ").concat(route.response.type, ", but ").concat(response.headers.get("content-type"), "."));
|
|
175
|
+
_o.label = 5;
|
|
176
|
+
case 5:
|
|
216
177
|
// RETURNS
|
|
217
|
-
|
|
178
|
+
if (route.method === "HEAD")
|
|
179
|
+
return [2 /*return*/, undefined];
|
|
180
|
+
else if (((_m = route.response) === null || _m === void 0 ? void 0 : _m.type) === "application/json")
|
|
181
|
+
return [2 /*return*/, response.json()];
|
|
182
|
+
_d = (_c = props).decode;
|
|
183
|
+
return [4 /*yield*/, response.text()];
|
|
184
|
+
case 6: return [2 /*return*/, _d.apply(_c, [_o.sent(), response_headers_to_object(response.headers)])];
|
|
218
185
|
}
|
|
219
186
|
});
|
|
220
|
-
});
|
|
187
|
+
}); };
|
|
221
188
|
};
|
|
222
|
-
|
|
223
|
-
}());
|
|
224
|
-
exports.Fetcher = Fetcher;
|
|
189
|
+
})(FetcherBase || (exports.FetcherBase = FetcherBase = {}));
|
|
225
190
|
var polyfill = new Singleton_1.Singleton(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
226
191
|
var _a;
|
|
227
192
|
return __generator(this, function (_b) {
|
|
@@ -242,9 +207,18 @@ var polyfill = new Singleton_1.Singleton(function () { return __awaiter(void 0,
|
|
|
242
207
|
}
|
|
243
208
|
});
|
|
244
209
|
}); });
|
|
245
|
-
function
|
|
210
|
+
var response_headers_to_object = function (headers) {
|
|
246
211
|
var output = {};
|
|
247
|
-
headers.forEach(function (value, key) {
|
|
212
|
+
headers.forEach(function (value, key) {
|
|
213
|
+
var _a;
|
|
214
|
+
var _b;
|
|
215
|
+
if (key === "set-cookie") {
|
|
216
|
+
(_b = output[key]) !== null && _b !== void 0 ? _b : (output[key] = []);
|
|
217
|
+
(_a = output[key]).push.apply(_a, __spreadArray([], __read(value.split(";").map(function (str) { return str.trim(); })), false));
|
|
218
|
+
}
|
|
219
|
+
else
|
|
220
|
+
output[key] = value;
|
|
221
|
+
});
|
|
248
222
|
return output;
|
|
249
|
-
}
|
|
250
|
-
//# sourceMappingURL=
|
|
223
|
+
};
|
|
224
|
+
//# sourceMappingURL=FetcherBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FetcherBase.js","sourceRoot":"","sources":["../../src/internal/FetcherBase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA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AAK,QAAQ;oBAC3C,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAA,EAHjD,wBAGiD;qBAE7C,CAAA,MAAM,CAAC,KAAK,KAAK,SAAS,CAAA,EAA1B,wBAA0B;gBAC1B,KAAA,MAAM,CAAA;gBAAW,qBAAM,IAAA,iBAAO,EAAC,YAAY,CAAC,EAAA;;gBAA5C,GAAO,KAAK,GAAI,CAAC,SAA2B,CAAS,CAAC,OAAO,CAAC;;oBAClE,sBAAQ,MAAc,CAAC,KAAK,EAAC;oBAEjC,sBAAO,MAAM,CAAC,KAAK,EAAC;;;KACvB,CAAC,CAAC;AAEH,IAAM,0BAA0B,GAAG,UAC/B,OAAgB;IAEhB,IAAM,MAAM,GAA4C,EAAE,CAAC;IAC3D,OAAO,CAAC,OAAO,CAAC,UAAC,KAAK,EAAE,GAAG;;;QACvB,IAAI,GAAG,KAAK,YAAY,EAAE;YACtB,MAAA,MAAM,CAAC,GAAG,qCAAV,MAAM,CAAC,GAAG,IAAM,EAAE,EAAC;YACnB,CAAA,KAAC,MAAM,CAAC,GAAG,CAAc,CAAA,CAAC,IAAI,oCACvB,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,CAAC,IAAI,EAAE,EAAV,CAAU,CAAC,WAC9C;SACL;;YAAM,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC/B,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface IFetchRoute<Method extends "HEAD" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE"> {
|
|
2
|
+
/**
|
|
3
|
+
* Method of the HTTP request.
|
|
4
|
+
*/
|
|
5
|
+
method: Method;
|
|
6
|
+
/**
|
|
7
|
+
* Path of the HTTP request.
|
|
8
|
+
*/
|
|
9
|
+
path: string;
|
|
10
|
+
/**
|
|
11
|
+
* Request body data info.
|
|
12
|
+
*/
|
|
13
|
+
request: Method extends "DELETE" | "POST" | "PUT" | "PATCH" ? IRoute.IBody | null : null;
|
|
14
|
+
/**
|
|
15
|
+
* Response body data info.
|
|
16
|
+
*/
|
|
17
|
+
response: Method extends "HEAD" ? null : IRoute.IBody;
|
|
18
|
+
/**
|
|
19
|
+
* When special status code being used.
|
|
20
|
+
*/
|
|
21
|
+
status?: null | number;
|
|
22
|
+
}
|
|
23
|
+
export declare namespace IRoute {
|
|
24
|
+
interface IBody {
|
|
25
|
+
type: "application/json" | "text/plain";
|
|
26
|
+
encrypted?: boolean;
|
|
27
|
+
}
|
|
28
|
+
}
|